@discover-cloud/shared 1.2.8 → 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/dist/authorization/index.d.ts +1 -1
- package/dist/authorization/index.js +1 -1
- package/dist/authorization/permission-cache.service.d.ts +104 -16
- package/dist/authorization/permission-cache.service.js +156 -143
- package/dist/authorization/permission-checker.d.ts +30 -0
- package/dist/authorization/permission-checker.js +40 -0
- package/dist/contracts/auth-service/account.dto.d.ts +30 -0
- package/dist/contracts/auth-service/account.dto.js +7 -0
- package/dist/contracts/auth-service/auth.dto.d.ts +21 -0
- package/dist/contracts/auth-service/auth.dto.js +10 -0
- package/dist/dtos/auth-service.dto.d.ts +72 -26
- package/dist/dtos/auth-service.dto.js +4 -0
- package/dist/dtos/cloud-service.dto.d.ts +51 -27
- package/dist/dtos/cloud-service.dto.js +5 -0
- package/dist/dtos/insights-service.dto.d.ts +18 -27
- package/dist/dtos/insights-service.dto.js +8 -0
- package/dist/dtos/response.dto.d.ts +7 -84
- package/dist/dtos/response.dto.js +2 -21
- package/dist/dtos/user-service.dto.d.ts +118 -13
- package/dist/enums/domain.enums.d.ts +246 -75
- package/dist/enums/domain.enums.js +305 -102
- package/dist/enums/permissions.enums.d.ts +142 -80
- package/dist/enums/permissions.enums.js +174 -133
- package/dist/errors/app-error.d.ts +13 -18
- package/dist/errors/app-error.js +14 -20
- package/dist/errors/http-errors.d.ts +105 -17
- package/dist/errors/http-errors.js +118 -33
- package/dist/http/index.d.ts +1 -0
- package/dist/http/index.js +1 -0
- package/dist/http/request-context.d.ts +8 -0
- package/dist/http/request-context.js +37 -0
- package/dist/http/service-client.d.ts +91 -38
- package/dist/http/service-client.js +102 -53
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/jwt/index.d.ts +2 -1
- package/dist/jwt/index.js +2 -1
- package/dist/jwt/machine-jwt-verifier.d.ts +21 -0
- package/dist/jwt/machine-jwt-verifier.js +84 -0
- package/dist/jwt/machine-token-client.d.ts +35 -4
- package/dist/jwt/machine-token-client.js +57 -23
- package/dist/jwt/user-jwt-verifier.d.ts +31 -0
- package/dist/jwt/user-jwt-verifier.js +101 -0
- package/dist/messaging/index.d.ts +1 -0
- package/dist/{security → messaging}/index.js +1 -1
- package/dist/messaging/rabbitmq.client.d.ts +13 -0
- package/dist/messaging/rabbitmq.client.js +127 -0
- package/dist/middleware/error-handler.middleware.d.ts +8 -28
- package/dist/middleware/error-handler.middleware.js +61 -52
- package/dist/middleware/index.d.ts +7 -5
- package/dist/middleware/index.js +7 -5
- package/dist/middleware/request-context.middleware.d.ts +17 -0
- package/dist/middleware/request-context.middleware.js +73 -0
- package/dist/middleware/require-auth.middleware.d.ts +17 -70
- package/dist/middleware/require-auth.middleware.js +24 -103
- package/dist/middleware/require-machine.middleware.d.ts +38 -0
- package/dist/middleware/require-machine.middleware.js +123 -0
- package/dist/middleware/require-org-permission-from-body.middleware.d.ts +10 -0
- package/dist/middleware/require-org-permission-from-body.middleware.js +24 -0
- package/dist/middleware/require-org-permission.middleware.d.ts +19 -0
- package/dist/middleware/require-org-permission.middleware.js +115 -0
- package/dist/middleware/require-platform-permission.middleware.d.ts +19 -0
- package/dist/middleware/require-platform-permission.middleware.js +91 -0
- package/dist/middleware/require-user.middleware.d.ts +14 -0
- package/dist/middleware/require-user.middleware.js +30 -0
- package/dist/middleware/require-workspace-permission.middleware.d.ts +20 -0
- package/dist/middleware/require-workspace-permission.middleware.js +114 -0
- package/dist/middleware/validate.middleware.d.ts +29 -29
- package/dist/middleware/validate.middleware.js +30 -32
- package/dist/types/express.types.d.ts +83 -122
- package/dist/types/express.types.js +28 -47
- package/dist/utils/date.util.d.ts +6 -0
- package/dist/utils/date.util.js +11 -0
- package/dist/utils/env.util.d.ts +6 -0
- package/dist/utils/env.util.js +19 -0
- package/dist/utils/index.d.ts +5 -4
- package/dist/utils/index.js +5 -4
- package/dist/utils/logger.util.d.ts +26 -0
- package/dist/utils/logger.util.js +53 -0
- package/dist/utils/pagination.util.d.ts +6 -0
- package/dist/utils/pagination.util.js +20 -0
- package/dist/utils/response.util.d.ts +27 -0
- package/dist/utils/response.util.js +56 -0
- package/dist/utils/slug.util.d.ts +9 -0
- package/dist/utils/slug.util.js +32 -0
- package/dist/utils/url-safety.util.d.ts +6 -0
- package/dist/utils/url-safety.util.js +72 -0
- package/package.json +3 -1
- package/dist/authorization/permissions.d.ts +0 -78
- package/dist/authorization/permissions.js +0 -174
- package/dist/context/access-context.d.ts +0 -10
- package/dist/context/access-context.js +0 -2
- package/dist/context/index.d.ts +0 -1
- package/dist/context/index.js +0 -17
- package/dist/dto/auth-service.dtos.d.ts +0 -44
- package/dist/dto/auth-service.dtos.js +0 -2
- package/dist/dto/index.d.ts +0 -3
- package/dist/dto/index.js +0 -19
- package/dist/dto/response.dtos.d.ts +0 -55
- package/dist/dto/response.dtos.js +0 -6
- package/dist/dto/user-service.dtos.d.ts +0 -50
- package/dist/dto/user-service.dtos.js +0 -2
- package/dist/enums/auth-service.enums.d.ts +0 -12
- package/dist/enums/auth-service.enums.js +0 -17
- package/dist/enums/permissions.types.d.ts +0 -12
- package/dist/enums/permissions.types.js +0 -17
- package/dist/enums/user-service.enums.d.ts +0 -32
- package/dist/enums/user-service.enums.js +0 -41
- package/dist/internal/index.d.ts +0 -4
- package/dist/internal/index.js +0 -20
- package/dist/internal/internal-jwt.service.d.ts +0 -13
- package/dist/internal/internal-jwt.service.js +0 -88
- package/dist/internal/internal-jwt.types.d.ts +0 -7
- package/dist/internal/internal-jwt.types.js +0 -2
- package/dist/internal/internal-key-manager.d.ts +0 -16
- package/dist/internal/internal-key-manager.js +0 -67
- package/dist/internal/registry.d.ts +0 -8
- package/dist/internal/registry.js +0 -34
- package/dist/internal/service-client.d.ts +0 -9
- package/dist/internal/service-client.js +0 -94
- package/dist/jwt/internal-jwt-verifier.d.ts +0 -41
- package/dist/jwt/internal-jwt-verifier.js +0 -185
- package/dist/jwt/jwt-verifier.d.ts +0 -9
- package/dist/jwt/jwt-verifier.js +0 -36
- package/dist/jwt/service-client.d.ts +0 -7
- package/dist/jwt/service-client.js +0 -87
- package/dist/middleware/authorize.d.ts +0 -3
- package/dist/middleware/authorize.js +0 -24
- package/dist/middleware/authorize.middleware.d.ts +0 -54
- package/dist/middleware/authorize.middleware.js +0 -104
- package/dist/middleware/error-handler.d.ts +0 -4
- package/dist/middleware/error-handler.js +0 -23
- package/dist/middleware/request-id.d.ts +0 -2
- package/dist/middleware/request-id.js +0 -9
- package/dist/middleware/request-id.middleware.d.ts +0 -22
- package/dist/middleware/request-id.middleware.js +0 -34
- package/dist/middleware/require-auth.d.ts +0 -10
- package/dist/middleware/require-auth.js +0 -34
- package/dist/middleware/require-human.middleware.d.ts +0 -2
- package/dist/middleware/require-human.middleware.js +0 -18
- package/dist/middleware/require-internal.middleware.d.ts +0 -18
- package/dist/middleware/require-internal.middleware.js +0 -183
- package/dist/middleware/validate.d.ts +0 -5
- package/dist/middleware/validate.js +0 -18
- package/dist/middleware/validated-merge.middleware.d.ts +0 -20
- package/dist/middleware/validated-merge.middleware.js +0 -33
- package/dist/middleware/verify-internal-jwt.d.ts +0 -7
- package/dist/middleware/verify-internal-jwt.js +0 -25
- package/dist/security/guard.d.ts +0 -10
- package/dist/security/guard.js +0 -40
- package/dist/security/index.d.ts +0 -1
- package/dist/types/express.d.ts +0 -22
- package/dist/types/express.js +0 -3
- package/dist/utils/date.utils.d.ts +0 -25
- package/dist/utils/date.utils.js +0 -30
- package/dist/utils/env.d.ts +0 -46
- package/dist/utils/env.js +0 -61
- package/dist/utils/env.utils.d.ts +0 -46
- package/dist/utils/env.utils.js +0 -61
- package/dist/utils/logger.utils.d.ts +0 -66
- package/dist/utils/logger.utils.js +0 -97
- package/dist/utils/response.d.ts +0 -4
- package/dist/utils/response.js +0 -35
- package/dist/utils/response.utils.d.ts +0 -54
- package/dist/utils/response.utils.js +0 -85
|
@@ -1,31 +1,25 @@
|
|
|
1
|
-
import { AccountStatus } from "../enums";
|
|
2
1
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* Internal data shapes produced by the auth service.
|
|
6
|
-
*
|
|
7
|
-
* SECURITY RULE: DTOs containing secrets (token, hash fields) must NEVER
|
|
8
|
-
* be returned directly in HTTP responses. They exist so internal service
|
|
9
|
-
* methods have typed return values — mappers are responsible for stripping
|
|
10
|
-
* secrets before anything reaches the wire.
|
|
11
|
-
*
|
|
12
|
-
* Secret fields are annotated with // SECRET — internal use only
|
|
13
|
-
* to make accidental exposure visible at a glance during code review.
|
|
2
|
+
* @file account.dto.ts
|
|
3
|
+
* @description Transport-safe DTOs for Account domain entities.
|
|
14
4
|
*/
|
|
15
5
|
export interface AccountDto {
|
|
16
6
|
id: string;
|
|
17
7
|
email: string;
|
|
18
8
|
isVerified: boolean;
|
|
19
|
-
status:
|
|
9
|
+
status: string;
|
|
10
|
+
mfaEnabled: boolean;
|
|
11
|
+
lastLoginAt: string | null;
|
|
20
12
|
createdAt: string;
|
|
21
13
|
updatedAt: string;
|
|
22
14
|
}
|
|
23
|
-
export interface
|
|
15
|
+
export interface SessionDto {
|
|
24
16
|
id: string;
|
|
25
17
|
accountId: string;
|
|
26
|
-
|
|
18
|
+
familyId: string;
|
|
19
|
+
ipAddress: string | null;
|
|
20
|
+
userAgent: string | null;
|
|
21
|
+
device: string | null;
|
|
27
22
|
expiresAt: string;
|
|
28
|
-
isUsed: boolean;
|
|
29
23
|
createdAt: string;
|
|
30
24
|
}
|
|
31
25
|
export interface OAuthIdentityDto {
|
|
@@ -34,24 +28,76 @@ export interface OAuthIdentityDto {
|
|
|
34
28
|
provider: string;
|
|
35
29
|
providerId: string;
|
|
36
30
|
createdAt: string;
|
|
31
|
+
}
|
|
32
|
+
export interface ServiceClientDto {
|
|
33
|
+
id: string;
|
|
34
|
+
serviceId: string;
|
|
35
|
+
name: string;
|
|
36
|
+
scopes: string[];
|
|
37
|
+
isActive: boolean;
|
|
38
|
+
lastUsedAt: string | null;
|
|
39
|
+
rotatedAt: string | null;
|
|
40
|
+
expiresAt: string | null;
|
|
41
|
+
createdById: string | null;
|
|
42
|
+
createdAt: string;
|
|
37
43
|
updatedAt: string;
|
|
38
44
|
}
|
|
39
|
-
export interface
|
|
45
|
+
export interface PlatformPermissionDto {
|
|
40
46
|
id: string;
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
47
|
+
key: string;
|
|
48
|
+
resource: string;
|
|
49
|
+
action: string;
|
|
50
|
+
category: string;
|
|
51
|
+
description: string | null;
|
|
52
|
+
serviceOwner: string | null;
|
|
53
|
+
dangerous: boolean;
|
|
45
54
|
createdAt: string;
|
|
46
55
|
}
|
|
47
|
-
export interface
|
|
56
|
+
export interface PlatformRoleDto {
|
|
57
|
+
id: string;
|
|
58
|
+
name: string;
|
|
59
|
+
type: string;
|
|
60
|
+
category: string;
|
|
61
|
+
isProtected: boolean;
|
|
62
|
+
createdById: string | null;
|
|
63
|
+
createdAt: string;
|
|
64
|
+
updatedAt: string;
|
|
65
|
+
}
|
|
66
|
+
export interface PlatformRoleWithPermissionsDto extends PlatformRoleDto {
|
|
67
|
+
permissions: PlatformPermissionDto[];
|
|
68
|
+
}
|
|
69
|
+
export interface PlatformRoleAssignmentDto {
|
|
48
70
|
id: string;
|
|
49
71
|
accountId: string;
|
|
50
|
-
|
|
72
|
+
roleId: string;
|
|
73
|
+
status: string;
|
|
74
|
+
assignedById: string | null;
|
|
75
|
+
revokedById: string | null;
|
|
51
76
|
revokedAt: string | null;
|
|
52
|
-
|
|
53
|
-
userAgent: string | null;
|
|
54
|
-
device: string | null;
|
|
77
|
+
role?: PlatformRoleDto;
|
|
55
78
|
createdAt: string;
|
|
56
79
|
updatedAt: string;
|
|
57
80
|
}
|
|
81
|
+
export interface AuthTokensDto {
|
|
82
|
+
accessToken: string;
|
|
83
|
+
refreshToken: string;
|
|
84
|
+
expiresIn: number;
|
|
85
|
+
}
|
|
86
|
+
export interface LoginResponseDto {
|
|
87
|
+
tokens: AuthTokensDto;
|
|
88
|
+
account: AccountDto;
|
|
89
|
+
mfaRequired: false;
|
|
90
|
+
}
|
|
91
|
+
export interface MfaRequiredResponseDto {
|
|
92
|
+
mfaRequired: true;
|
|
93
|
+
mfaToken: string;
|
|
94
|
+
}
|
|
95
|
+
export type LoginOrMfaResponseDto = LoginResponseDto | MfaRequiredResponseDto;
|
|
96
|
+
export interface MfaSetupDto {
|
|
97
|
+
secret: string;
|
|
98
|
+
otpauthUrl: string;
|
|
99
|
+
qrCodeDataUrl: string;
|
|
100
|
+
}
|
|
101
|
+
export interface MfaBackupCodesDto {
|
|
102
|
+
backupCodes: string[];
|
|
103
|
+
}
|
|
@@ -1,31 +1,16 @@
|
|
|
1
|
-
import { CloudProvider, CloudAccountStatus, AwsAuthMethod, GcpAuthMethod, AzureAuthMethod, SyncStatus, SyncType } from "../enums";
|
|
2
1
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* Date handling:
|
|
8
|
-
* JSON has no Date type. Domain models use Date internally; these DTOs
|
|
9
|
-
* are the serialised form at the HTTP boundary — all timestamps are ISO 8601 strings.
|
|
10
|
-
*
|
|
11
|
-
* Credential handling:
|
|
12
|
-
* CloudAccountDto intentionally omits encryptedCredentials — credentials
|
|
13
|
-
* are write-only. The connect DTOs accept credentials as `unknown` because
|
|
14
|
-
* the shape differs per provider and per authMethod; Zod schemas in the
|
|
15
|
-
* cloud service validate the concrete shape at runtime.
|
|
16
|
-
*
|
|
17
|
-
* SyncJobDto:
|
|
18
|
-
* Read-only. Sync jobs are created internally by the scheduler and exposed
|
|
19
|
-
* for status polling only — clients never POST a sync job directly.
|
|
20
|
-
*
|
|
21
|
-
* Provider push DTOs (CloudCostRecordDto, CloudResourceDto, CloudBudgetDto):
|
|
22
|
-
* Used when cloud-service pushes collected data to insights-service.
|
|
23
|
-
* They include cloudAccountId for scoping — insights-service uses this to
|
|
24
|
-
* associate records with the correct account without re-fetching.
|
|
2
|
+
* @file cloud-service.dto.ts
|
|
3
|
+
* @description Data transfer objects (DTOs) for cloud accounts,
|
|
4
|
+
* sync jobs, provider ingestion, and insights communication.
|
|
25
5
|
*/
|
|
6
|
+
import { CloudProvider, CloudAccountStatus, AwsAuthMethod, GcpAuthMethod, AzureAuthMethod, SyncStatus, SyncType } from "../enums";
|
|
7
|
+
/** Public representation of a connected cloud account. */
|
|
26
8
|
export interface CloudAccountDto {
|
|
27
9
|
id: string;
|
|
28
|
-
|
|
10
|
+
/** Workspace that owns this cloud account. */
|
|
11
|
+
workspaceId: string;
|
|
12
|
+
/** User who originally connected this account. */
|
|
13
|
+
createdBy: string;
|
|
29
14
|
alias: string;
|
|
30
15
|
provider: CloudProvider;
|
|
31
16
|
status: CloudAccountStatus;
|
|
@@ -36,24 +21,25 @@ export interface CloudAccountDto {
|
|
|
36
21
|
createdAt: string;
|
|
37
22
|
updatedAt: string;
|
|
38
23
|
}
|
|
39
|
-
/**
|
|
24
|
+
/** Request payload to connect a new AWS account. */
|
|
40
25
|
export interface ConnectAwsAccountDto {
|
|
41
26
|
alias: string;
|
|
42
27
|
authMethod: AwsAuthMethod;
|
|
43
28
|
credentials: unknown;
|
|
44
29
|
}
|
|
45
|
-
/**
|
|
30
|
+
/** Request payload to connect a new GCP account. */
|
|
46
31
|
export interface ConnectGcpAccountDto {
|
|
47
32
|
alias: string;
|
|
48
33
|
authMethod: GcpAuthMethod;
|
|
49
34
|
credentials: unknown;
|
|
50
35
|
}
|
|
51
|
-
/**
|
|
36
|
+
/** Request payload to connect a new Azure account. */
|
|
52
37
|
export interface ConnectAzureAccountDto {
|
|
53
38
|
alias: string;
|
|
54
39
|
authMethod: AzureAuthMethod;
|
|
55
40
|
credentials: unknown;
|
|
56
41
|
}
|
|
42
|
+
/** Metadata tracking a single cloud synchronization job. */
|
|
57
43
|
export interface SyncJobDto {
|
|
58
44
|
id: string;
|
|
59
45
|
cloudAccountId: string;
|
|
@@ -68,6 +54,42 @@ export interface SyncJobDto {
|
|
|
68
54
|
createdAt: string;
|
|
69
55
|
updatedAt: string;
|
|
70
56
|
}
|
|
57
|
+
/** Consolidated collection metrics normalized from a cloud provider. */
|
|
58
|
+
export interface ProviderFetchResultDto {
|
|
59
|
+
costs: ProviderCostDto[];
|
|
60
|
+
resources: ProviderResourceDto[];
|
|
61
|
+
budgets: ProviderBudgetDto[];
|
|
62
|
+
}
|
|
63
|
+
/** Normalized cost record details fetched from a cloud provider. */
|
|
64
|
+
export interface ProviderCostDto {
|
|
65
|
+
service: string;
|
|
66
|
+
region: string;
|
|
67
|
+
amount: number;
|
|
68
|
+
currency: string;
|
|
69
|
+
periodStart: string;
|
|
70
|
+
periodEnd: string;
|
|
71
|
+
usageType: string;
|
|
72
|
+
}
|
|
73
|
+
/** Normalized resource metadata details fetched from a cloud provider. */
|
|
74
|
+
export interface ProviderResourceDto {
|
|
75
|
+
resourceType: string;
|
|
76
|
+
resourceId: string;
|
|
77
|
+
region: string;
|
|
78
|
+
name: string | null;
|
|
79
|
+
status: string;
|
|
80
|
+
tags: Record<string, string>;
|
|
81
|
+
metadata: Record<string, unknown>;
|
|
82
|
+
}
|
|
83
|
+
/** Normalized budget configuration fetched from a cloud provider. */
|
|
84
|
+
export interface ProviderBudgetDto {
|
|
85
|
+
name: string;
|
|
86
|
+
limitAmount: number;
|
|
87
|
+
currency: string;
|
|
88
|
+
period: string;
|
|
89
|
+
actualSpend?: number;
|
|
90
|
+
forecastSpend?: number;
|
|
91
|
+
}
|
|
92
|
+
/** Enriched cost record details pushed to the insights service. */
|
|
71
93
|
export interface CloudCostRecordDto {
|
|
72
94
|
cloudAccountId: string;
|
|
73
95
|
provider: CloudProvider;
|
|
@@ -79,6 +101,7 @@ export interface CloudCostRecordDto {
|
|
|
79
101
|
periodEnd: string;
|
|
80
102
|
usageType: string;
|
|
81
103
|
}
|
|
104
|
+
/** Enriched resource metadata details pushed to the insights service. */
|
|
82
105
|
export interface CloudResourceDto {
|
|
83
106
|
cloudAccountId: string;
|
|
84
107
|
provider: CloudProvider;
|
|
@@ -90,6 +113,7 @@ export interface CloudResourceDto {
|
|
|
90
113
|
tags: Record<string, string>;
|
|
91
114
|
metadata: Record<string, unknown>;
|
|
92
115
|
}
|
|
116
|
+
/** Enriched budget configuration details pushed to the insights service. */
|
|
93
117
|
export interface CloudBudgetDto {
|
|
94
118
|
cloudAccountId: string;
|
|
95
119
|
name: string;
|
|
@@ -1,22 +1,12 @@
|
|
|
1
|
-
import { CloudProvider } from "../enums";
|
|
2
1
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* Push payloads — cloud-service → insights-service (internal HTTP).
|
|
8
|
-
* Carry raw provider data collected during a sync job.
|
|
9
|
-
*
|
|
10
|
-
* Record DTOs — insights-service → frontend (public HTTP).
|
|
11
|
-
* Stored/enriched records returned to clients.
|
|
12
|
-
* All timestamps are ISO 8601 strings (JSON has no Date).
|
|
2
|
+
* @file insights-service.dto.ts
|
|
3
|
+
* @description Data transfer objects (DTOs) for cost tracking, cloud resource inventory,
|
|
4
|
+
* budgets, and aggregated analytics reports in the Insights Service.
|
|
13
5
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* Summary DTOs — assembled aggregations with no corresponding domain
|
|
18
|
-
* model or mapper. Built directly from DB query results.
|
|
6
|
+
* All push payloads and query DTOs are scoped to a workspaceId — the sole
|
|
7
|
+
* multi-tenancy discriminator. userId / organizationId have been removed.
|
|
19
8
|
*/
|
|
9
|
+
import { CloudProvider } from "../enums";
|
|
20
10
|
export interface PushCostItem {
|
|
21
11
|
service: string;
|
|
22
12
|
region: string;
|
|
@@ -45,25 +35,28 @@ export interface PushBudgetItem {
|
|
|
45
35
|
}
|
|
46
36
|
export interface PushCostPayload {
|
|
47
37
|
cloudAccountId: string;
|
|
48
|
-
|
|
38
|
+
/** Workspace that owns this data — the sole tenancy scope. */
|
|
39
|
+
workspaceId: string;
|
|
49
40
|
provider: CloudProvider;
|
|
50
41
|
costs: PushCostItem[];
|
|
51
42
|
}
|
|
52
43
|
export interface PushResourcePayload {
|
|
53
44
|
cloudAccountId: string;
|
|
54
|
-
|
|
45
|
+
/** Workspace that owns this data — the sole tenancy scope. */
|
|
46
|
+
workspaceId: string;
|
|
55
47
|
provider: CloudProvider;
|
|
56
48
|
resources: PushResourceItem[];
|
|
57
49
|
}
|
|
58
50
|
export interface PushBudgetPayload {
|
|
59
51
|
cloudAccountId: string;
|
|
60
|
-
|
|
52
|
+
/** Workspace that owns this data — the sole tenancy scope. */
|
|
53
|
+
workspaceId: string;
|
|
61
54
|
budgets: PushBudgetItem[];
|
|
62
55
|
}
|
|
63
56
|
export interface CostRecordDto {
|
|
64
57
|
id: string;
|
|
65
58
|
cloudAccountId: string;
|
|
66
|
-
|
|
59
|
+
workspaceId: string;
|
|
67
60
|
provider: CloudProvider;
|
|
68
61
|
service: string;
|
|
69
62
|
region: string;
|
|
@@ -77,7 +70,7 @@ export interface CostRecordDto {
|
|
|
77
70
|
export interface ResourceRecordDto {
|
|
78
71
|
id: string;
|
|
79
72
|
cloudAccountId: string;
|
|
80
|
-
|
|
73
|
+
workspaceId: string;
|
|
81
74
|
provider: CloudProvider;
|
|
82
75
|
resourceType: string;
|
|
83
76
|
resourceId: string;
|
|
@@ -91,7 +84,7 @@ export interface ResourceRecordDto {
|
|
|
91
84
|
export interface BudgetRecordDto {
|
|
92
85
|
id: string;
|
|
93
86
|
cloudAccountId: string;
|
|
94
|
-
|
|
87
|
+
workspaceId: string;
|
|
95
88
|
name: string;
|
|
96
89
|
limitAmount: number;
|
|
97
90
|
currency: string;
|
|
@@ -104,13 +97,11 @@ export interface BudgetRecordDto {
|
|
|
104
97
|
recordedAt: string;
|
|
105
98
|
}
|
|
106
99
|
/**
|
|
107
|
-
*
|
|
108
|
-
*
|
|
109
|
-
* Date fields are fine here — this never reaches JSON serialisation.
|
|
110
|
-
* If this ever needs to cross HTTP, convert from/to to ISO 8601 strings.
|
|
100
|
+
* Parameter model for cost queries.
|
|
101
|
+
* Scoped to a workspaceId — callers must always provide this.
|
|
111
102
|
*/
|
|
112
103
|
export interface CostQueryDto {
|
|
113
|
-
|
|
104
|
+
workspaceId: string;
|
|
114
105
|
cloudAccountId?: string;
|
|
115
106
|
provider?: CloudProvider;
|
|
116
107
|
from?: Date;
|
|
@@ -1,2 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @file insights-service.dto.ts
|
|
4
|
+
* @description Data transfer objects (DTOs) for cost tracking, cloud resource inventory,
|
|
5
|
+
* budgets, and aggregated analytics reports in the Insights Service.
|
|
6
|
+
*
|
|
7
|
+
* All push payloads and query DTOs are scoped to a workspaceId — the sole
|
|
8
|
+
* multi-tenancy discriminator. userId / organizationId have been removed.
|
|
9
|
+
*/
|
|
2
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,25 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* Shared HTTP response shapes used across all services.
|
|
5
|
-
* Every response — success or error — is wrapped in the ApiSuccessResponse
|
|
6
|
-
* or ApiErrorResponse envelope so clients have a consistent shape to key on.
|
|
7
|
-
*
|
|
8
|
-
* Envelope shape:
|
|
9
|
-
* {
|
|
10
|
-
* success: true,
|
|
11
|
-
* data: T,
|
|
12
|
-
* meta: { requestId, timestamp }
|
|
13
|
-
* }
|
|
14
|
-
* or
|
|
15
|
-
* {
|
|
16
|
-
* success: false,
|
|
17
|
-
* error: { code, message, details? },
|
|
18
|
-
* meta: { requestId, timestamp }
|
|
19
|
-
* }
|
|
20
|
-
*
|
|
21
|
-
* The success() and failure() utils in shared/utils construct these
|
|
22
|
-
* envelopes — don't build them manually in controllers.
|
|
2
|
+
* @file response.dto.ts
|
|
3
|
+
* @description Shared HTTP response envelopes, pagination models, and generic response contracts.
|
|
23
4
|
*/
|
|
24
5
|
export interface ApiMeta {
|
|
25
6
|
requestId: string;
|
|
@@ -39,39 +20,9 @@ export interface ApiErrorResponse {
|
|
|
39
20
|
};
|
|
40
21
|
meta: ApiMeta;
|
|
41
22
|
}
|
|
42
|
-
/**
|
|
43
|
-
* TokensResponseDto
|
|
44
|
-
* Returned on successful login or token refresh.
|
|
45
|
-
*
|
|
46
|
-
* accessToken — short-lived JWT returned in the response body.
|
|
47
|
-
* refreshToken — long-lived token sent as an HttpOnly cookie by the auth
|
|
48
|
-
* service; it is intentionally absent from this DTO.
|
|
49
|
-
* Mobile clients that cannot use cookies should request a
|
|
50
|
-
* separate endpoint that returns the refresh token explicitly.
|
|
51
|
-
*/
|
|
52
|
-
export interface TokensResponseDto {
|
|
53
|
-
accessToken: string;
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* MessageResponseDto
|
|
57
|
-
* Use for simple confirmations where no structured data is needed.
|
|
58
|
-
* Example: { message: "Email verification sent" }
|
|
59
|
-
*/
|
|
60
23
|
export interface MessageResponseDto {
|
|
61
24
|
message: string;
|
|
62
25
|
}
|
|
63
|
-
/**
|
|
64
|
-
* ActionResponseDto
|
|
65
|
-
* Use when the client needs a machine-readable signal of what happened,
|
|
66
|
-
* e.g. for polling loops, event-driven UIs, or audit trails.
|
|
67
|
-
*
|
|
68
|
-
* action — stable machine-readable identifier, e.g. "account.suspended"
|
|
69
|
-
* message — human-readable description for display or logging
|
|
70
|
-
*
|
|
71
|
-
* Boolean-only DTOs (LoggedOutResponseDto, SuspendedResponseDto, etc.)
|
|
72
|
-
* are intentionally collapsed into this shape — a boolean that is always
|
|
73
|
-
* true on a 200 response carries no additional information.
|
|
74
|
-
*/
|
|
75
26
|
export interface ActionResponseDto {
|
|
76
27
|
action: string;
|
|
77
28
|
message: string;
|
|
@@ -84,42 +35,14 @@ export interface PaginationMeta {
|
|
|
84
35
|
hasNext: boolean;
|
|
85
36
|
hasPrev: boolean;
|
|
86
37
|
}
|
|
87
|
-
/**
|
|
88
|
-
* PaginatedResponseDto
|
|
89
|
-
* Wrap paginated list results in this before passing to success().
|
|
90
|
-
*
|
|
91
|
-
* Usage:
|
|
92
|
-
* success<PaginatedResponseDto<CloudAccountDto>>(res, req, {
|
|
93
|
-
* items: accounts,
|
|
94
|
-
* pagination: { page, pageSize, totalItems, totalPages, hasNext, hasPrev },
|
|
95
|
-
* });
|
|
96
|
-
*/
|
|
97
38
|
export interface PaginatedResponseDto<T> {
|
|
98
39
|
items: T[];
|
|
99
40
|
pagination: PaginationMeta;
|
|
100
41
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
* Internal auth service response returned after successful login.
|
|
104
|
-
*
|
|
105
|
-
* The optional cookie metadata allows controllers or gateways
|
|
106
|
-
* to apply refresh-token cookies without coupling shared DTOs
|
|
107
|
-
* to a specific HTTP framework.
|
|
108
|
-
*/
|
|
109
|
-
export interface CookieMetadataDto {
|
|
110
|
-
httpOnly?: boolean;
|
|
111
|
-
secure?: boolean;
|
|
112
|
-
sameSite?: boolean | "strict" | "lax" | "none";
|
|
113
|
-
maxAge?: number;
|
|
114
|
-
path?: string;
|
|
115
|
-
domain?: string;
|
|
116
|
-
}
|
|
117
|
-
export interface LoginResultCookieDto {
|
|
118
|
-
name: string;
|
|
119
|
-
value: string;
|
|
120
|
-
options: CookieMetadataDto;
|
|
42
|
+
export interface AuthTokenDto {
|
|
43
|
+
accessToken: string;
|
|
121
44
|
}
|
|
122
|
-
export interface
|
|
123
|
-
|
|
124
|
-
|
|
45
|
+
export interface MachineTokenDto {
|
|
46
|
+
accessToken: string;
|
|
47
|
+
expiresIn: number;
|
|
125
48
|
}
|
|
@@ -1,25 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* Shared HTTP response shapes used across all services.
|
|
6
|
-
* Every response — success or error — is wrapped in the ApiSuccessResponse
|
|
7
|
-
* or ApiErrorResponse envelope so clients have a consistent shape to key on.
|
|
8
|
-
*
|
|
9
|
-
* Envelope shape:
|
|
10
|
-
* {
|
|
11
|
-
* success: true,
|
|
12
|
-
* data: T,
|
|
13
|
-
* meta: { requestId, timestamp }
|
|
14
|
-
* }
|
|
15
|
-
* or
|
|
16
|
-
* {
|
|
17
|
-
* success: false,
|
|
18
|
-
* error: { code, message, details? },
|
|
19
|
-
* meta: { requestId, timestamp }
|
|
20
|
-
* }
|
|
21
|
-
*
|
|
22
|
-
* The success() and failure() utils in shared/utils construct these
|
|
23
|
-
* envelopes — don't build them manually in controllers.
|
|
3
|
+
* @file response.dto.ts
|
|
4
|
+
* @description Shared HTTP response envelopes, pagination models, and generic response contracts.
|
|
24
5
|
*/
|
|
25
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
/**
|
|
3
|
-
* USER SERVICE DTOs (@discover-cloud/shared)
|
|
4
|
-
* ─────────────────────────────────────────────
|
|
5
|
-
* Shapes returned by the user service over HTTP.
|
|
6
|
-
* All timestamps are ISO 8601 strings — JSON has no Date type.
|
|
7
|
-
* Domain models use Date internally; mappers convert at the boundary.
|
|
8
|
-
*/
|
|
1
|
+
import { Currency, Theme, OrganizationStatus, MembershipStatus, WorkspaceType, RoleType, RoleCategory, RoleAssignmentStatus, InviteScopeType, InviteStatus, AlertRuleOperator, AlertRuleMetric, NotificationChannelType } from '../enums';
|
|
9
2
|
export interface UserDto {
|
|
10
3
|
id: string;
|
|
11
4
|
email: string;
|
|
@@ -19,23 +12,27 @@ export interface UserProfileDto {
|
|
|
19
12
|
avatarUrl: string | null;
|
|
20
13
|
jobTitle: string | null;
|
|
21
14
|
bio: string | null;
|
|
22
|
-
timezone: string | null;
|
|
23
|
-
locale: string;
|
|
24
15
|
country: string | null;
|
|
25
16
|
pronouns: string | null;
|
|
17
|
+
phoneNumber: string | null;
|
|
26
18
|
createdAt: string;
|
|
27
19
|
updatedAt: string;
|
|
28
20
|
}
|
|
29
21
|
export interface UserPreferencesDto {
|
|
30
22
|
id: string;
|
|
31
23
|
userId: string;
|
|
24
|
+
locale: string;
|
|
25
|
+
timezone: string;
|
|
32
26
|
theme: Theme;
|
|
33
|
-
language: string;
|
|
34
27
|
currency: Currency;
|
|
35
|
-
|
|
28
|
+
emailNotifications: boolean;
|
|
36
29
|
createdAt: string;
|
|
37
30
|
updatedAt: string;
|
|
38
31
|
}
|
|
32
|
+
export interface UserWithProfileDto extends UserDto {
|
|
33
|
+
profile: UserProfileDto | null;
|
|
34
|
+
preferences: UserPreferencesDto | null;
|
|
35
|
+
}
|
|
39
36
|
export interface OrganizationDto {
|
|
40
37
|
id: string;
|
|
41
38
|
name: string;
|
|
@@ -45,12 +42,120 @@ export interface OrganizationDto {
|
|
|
45
42
|
updatedAt: string;
|
|
46
43
|
deletedAt: string | null;
|
|
47
44
|
}
|
|
45
|
+
export interface OrganizationWithMembersCountDto extends OrganizationDto {
|
|
46
|
+
membersCount: number;
|
|
47
|
+
}
|
|
48
48
|
export interface OrganizationMemberDto {
|
|
49
49
|
id: string;
|
|
50
50
|
userId: string;
|
|
51
51
|
organizationId: string;
|
|
52
|
-
role: OrganizationRole;
|
|
53
52
|
status: MembershipStatus;
|
|
54
53
|
createdAt: string;
|
|
55
54
|
updatedAt: string;
|
|
56
55
|
}
|
|
56
|
+
export interface WorkspaceDto {
|
|
57
|
+
id: string;
|
|
58
|
+
name: string;
|
|
59
|
+
slug: string;
|
|
60
|
+
type: WorkspaceType;
|
|
61
|
+
ownerUserId: string | null;
|
|
62
|
+
organizationId: string | null;
|
|
63
|
+
createdAt: string;
|
|
64
|
+
updatedAt: string;
|
|
65
|
+
deletedAt: string | null;
|
|
66
|
+
}
|
|
67
|
+
export interface WorkspaceMemberDto {
|
|
68
|
+
id: string;
|
|
69
|
+
workspaceId: string;
|
|
70
|
+
userId: string;
|
|
71
|
+
createdAt: string;
|
|
72
|
+
updatedAt: string;
|
|
73
|
+
}
|
|
74
|
+
export interface PermissionDto {
|
|
75
|
+
id: string;
|
|
76
|
+
key: string;
|
|
77
|
+
resource: string;
|
|
78
|
+
action: string;
|
|
79
|
+
description: string | null;
|
|
80
|
+
serviceOwner: string;
|
|
81
|
+
dangerous: boolean;
|
|
82
|
+
createdAt: string;
|
|
83
|
+
}
|
|
84
|
+
export interface RoleDto {
|
|
85
|
+
id: string;
|
|
86
|
+
name: string;
|
|
87
|
+
type: RoleType;
|
|
88
|
+
category: RoleCategory;
|
|
89
|
+
organizationId: string | null;
|
|
90
|
+
isProtected: boolean;
|
|
91
|
+
createdAt: string;
|
|
92
|
+
updatedAt: string;
|
|
93
|
+
}
|
|
94
|
+
export interface RoleWithPermissionsDto extends RoleDto {
|
|
95
|
+
permissions: PermissionDto[];
|
|
96
|
+
}
|
|
97
|
+
export interface WorkspaceMemberWithRolesDto {
|
|
98
|
+
member: WorkspaceMemberDto;
|
|
99
|
+
user: UserDto;
|
|
100
|
+
roles: RoleDto[];
|
|
101
|
+
}
|
|
102
|
+
export interface RoleAssignmentDto {
|
|
103
|
+
id: string;
|
|
104
|
+
userId: string;
|
|
105
|
+
roleId: string;
|
|
106
|
+
scopeType: string;
|
|
107
|
+
organizationId: string | null;
|
|
108
|
+
workspaceId: string | null;
|
|
109
|
+
status: RoleAssignmentStatus;
|
|
110
|
+
role?: RoleDto;
|
|
111
|
+
createdAt: string;
|
|
112
|
+
updatedAt: string;
|
|
113
|
+
}
|
|
114
|
+
export interface InviteDto {
|
|
115
|
+
id: string;
|
|
116
|
+
email: string;
|
|
117
|
+
token: string;
|
|
118
|
+
userId: string | null;
|
|
119
|
+
scopeType: InviteScopeType;
|
|
120
|
+
organizationId: string | null;
|
|
121
|
+
workspaceId: string | null;
|
|
122
|
+
roleId: string;
|
|
123
|
+
status: InviteStatus;
|
|
124
|
+
invitedById: string;
|
|
125
|
+
invitedAt: string;
|
|
126
|
+
expiresAt: string;
|
|
127
|
+
acceptedAt: string | null;
|
|
128
|
+
rejectedAt: string | null;
|
|
129
|
+
revokedById: string | null;
|
|
130
|
+
revokedAt: string | null;
|
|
131
|
+
createdAt: string;
|
|
132
|
+
updatedAt: string;
|
|
133
|
+
}
|
|
134
|
+
export interface AlertRuleDto {
|
|
135
|
+
id: string;
|
|
136
|
+
workspaceId: string;
|
|
137
|
+
createdById: string;
|
|
138
|
+
name: string;
|
|
139
|
+
metric: AlertRuleMetric;
|
|
140
|
+
operator: AlertRuleOperator;
|
|
141
|
+
threshold: number;
|
|
142
|
+
thresholdCurrency: Currency | null;
|
|
143
|
+
isActive: boolean;
|
|
144
|
+
createdAt: string;
|
|
145
|
+
updatedAt: string;
|
|
146
|
+
}
|
|
147
|
+
export interface AlertRuleChannelDto {
|
|
148
|
+
id: string;
|
|
149
|
+
alertRuleId: string;
|
|
150
|
+
type: NotificationChannelType;
|
|
151
|
+
destination: string;
|
|
152
|
+
createdAt: string;
|
|
153
|
+
updatedAt: string;
|
|
154
|
+
}
|
|
155
|
+
export interface AlertRuleWithChannelsDto extends AlertRuleDto {
|
|
156
|
+
channels: AlertRuleChannelDto[];
|
|
157
|
+
}
|
|
158
|
+
export interface ProvisionUserResponseDto {
|
|
159
|
+
user: UserWithProfileDto;
|
|
160
|
+
personalWorkspace: WorkspaceDto;
|
|
161
|
+
}
|