@burdenoff/be-sdk 2026.1110.3 → 2026.1110.4
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/activity/index.d.ts +165 -0
- package/dist/activity/index.js +389 -0
- package/dist/activity/index.js.map +1 -0
- package/dist/ai-credits/index.js +1 -1
- package/dist/{ai-credits-Ca-NNcVx.js → ai-credits-xxfwGpHS.js} +2 -2
- package/dist/{ai-credits-Ca-NNcVx.js.map → ai-credits-xxfwGpHS.js.map} +1 -1
- package/dist/auth/index.d.ts +1 -1
- package/dist/auth/index.js +1 -1
- package/dist/{auth-CEuBEBQN.js → auth-C5ctwSLp.js} +2 -2
- package/dist/{auth-CEuBEBQN.js.map → auth-C5ctwSLp.js.map} +1 -1
- package/dist/bootstrap/index.d.ts +74 -0
- package/dist/bootstrap/index.js +282 -0
- package/dist/bootstrap/index.js.map +1 -0
- package/dist/{client-DcZ3iGES.js → client-sAJTrb4i.js} +2 -2
- package/dist/{client-DcZ3iGES.js.map → client-sAJTrb4i.js.map} +1 -1
- package/dist/context/index.d.ts +35 -0
- package/dist/{context-CZnXf2yb.js → context/index.js} +38 -2
- package/dist/context/index.js.map +1 -0
- package/dist/database/index.js +1 -1
- package/dist/event-queue/index.d.ts +1 -1
- package/dist/explicit-activity-scope-DikJ7NAE.js +57 -0
- package/dist/explicit-activity-scope-DikJ7NAE.js.map +1 -0
- package/dist/export/index.js +1 -1
- package/dist/{export-B6fphx8a.js → export-DJXE3Osa.js} +3 -3
- package/dist/{export-B6fphx8a.js.map → export-DJXE3Osa.js.map} +1 -1
- package/dist/feature-flags/index.js +1 -1
- package/dist/{feature-flags-71oDkrUe.js → feature-flags-CP1KRgwD.js} +2 -2
- package/dist/{feature-flags-71oDkrUe.js.map → feature-flags-CP1KRgwD.js.map} +1 -1
- package/dist/files/index.js +1 -1
- package/dist/{files-DjH0099H.js → files-h5U-D2AF.js} +2 -2
- package/dist/{files-DjH0099H.js.map → files-h5U-D2AF.js.map} +1 -1
- package/dist/gateway/index.js +2 -2
- package/dist/{gateway-DBFmxWks.js → gateway-ByVo-n37.js} +2 -2
- package/dist/{gateway-DBFmxWks.js.map → gateway-ByVo-n37.js.map} +1 -1
- package/dist/graph/index.d.ts +1 -1
- package/dist/graph/index.js +1 -1
- package/dist/{graph-DDYgIryR.js → graph-CR7u4lpl.js} +2 -2
- package/dist/{graph-DDYgIryR.js.map → graph-CR7u4lpl.js.map} +1 -1
- package/dist/{graphql-DNkMkGBZ.d.ts → graphql-CUDyhibV.d.ts} +1 -1
- package/dist/{index-bZKZUvBu.d.ts → index-ADmsX0BI.d.ts} +3 -3
- package/dist/{index-BqYfCQSP.d.ts → index-B2LCaK0R.d.ts} +1 -1
- package/dist/{index-D6UeLAye.d.ts → index-CHwMhK6v.d.ts} +2 -2
- package/dist/{index-BQDsNAMR.d.ts → index-CTTwo9av.d.ts} +22 -1
- package/dist/{index-DZC-2o9R.d.ts → index-CVCyKzhB.d.ts} +2 -2
- package/dist/{index-CkT2aUr3.d.ts → index-C_GXXF32.d.ts} +2 -2
- package/dist/{index-BKwHQtHQ.d.ts → index-Cot73bdh.d.ts} +1 -1
- package/dist/{index-CnzbJZP7.d.ts → index-FRRaa6h2.d.ts} +2 -2
- package/dist/{index-N-huORcj.d.ts → index-U_tu3zUl.d.ts} +2 -2
- package/dist/index-cmR9k9ga.d.ts +26 -0
- package/dist/{index-CZTnQIRU.d.ts → index-zd_NPGJo.d.ts} +6 -141
- package/dist/index.d.ts +19 -479
- package/dist/index.js +22 -1492
- package/dist/index.js.map +1 -1
- package/dist/init/index.js +1 -1
- package/dist/{init-Dy3KhT6Y.js → init-CQPFmOOe.js} +3 -3
- package/dist/{init-Dy3KhT6Y.js.map → init-CQPFmOOe.js.map} +1 -1
- package/dist/instrumentation/index.d.ts +2 -2
- package/dist/logger/index.d.ts +1 -1
- package/dist/notifications/index.d.ts +1 -1
- package/dist/notifications/index.js +1 -1
- package/dist/{notifications-CdETrtFK.js → notifications-DY_i37WN.js} +2 -2
- package/dist/{notifications-CdETrtFK.js.map → notifications-DY_i37WN.js.map} +1 -1
- package/dist/payments/index.d.ts +144 -0
- package/dist/payments/index.js +404 -0
- package/dist/payments/index.js.map +1 -0
- package/dist/rate-limit-CBrK_U5H.js +142 -0
- package/dist/rate-limit-CBrK_U5H.js.map +1 -0
- package/dist/rbac/index.d.ts +1 -1
- package/dist/rbac/index.js +1 -1
- package/dist/{rbac-BB9l9Xph.js → rbac-Dvz0YzEt.js} +2 -2
- package/dist/{rbac-BB9l9Xph.js.map → rbac-Dvz0YzEt.js.map} +1 -1
- package/dist/resource-caps/index.d.ts +1 -1
- package/dist/search/index.d.ts +112 -0
- package/dist/search/index.js +266 -0
- package/dist/search/index.js.map +1 -0
- package/dist/security/index.d.ts +2 -0
- package/dist/security/index.js +4 -0
- package/dist/security/index.js.map +1 -0
- package/dist/security/rate-limit/index.d.ts +2 -0
- package/dist/security/rate-limit/index.js +4 -0
- package/dist/security/rate-limit/index.js.map +1 -0
- package/dist/server/index.js +3 -2
- package/dist/server/index.js.map +1 -1
- package/dist/{stub-BqwKn4eh.js → stub-BUnfMiAS.js} +3 -56
- package/dist/stub-BUnfMiAS.js.map +1 -0
- package/dist/tags/index.js +1 -1
- package/dist/{tags-B5xpbgsk.js → tags-CbijgoqR.js} +2 -2
- package/dist/{tags-B5xpbgsk.js.map → tags-CbijgoqR.js.map} +1 -1
- package/dist/telemetry/index.d.ts +2 -2
- package/dist/tracker/index.d.ts +2 -2
- package/dist/tracker/index.js +5 -3
- package/dist/{tracker-BQVoEFUo.js → tracker-PQztSlhJ.js} +9 -390
- package/dist/tracker-PQztSlhJ.js.map +1 -0
- package/dist/translation/index.d.ts +120 -0
- package/dist/translation/index.js +573 -0
- package/dist/translation/index.js.map +1 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/{types-Cj2RWXbz.js → types/index.js} +3 -3
- package/dist/types/index.js.map +1 -0
- package/dist/usage/index.d.ts +1 -1
- package/dist/usage/index.js +1 -1
- package/dist/{usage-BKFZiWQn.js → usage-BRqVP3CJ.js} +4 -4
- package/dist/{usage-BKFZiWQn.js.map → usage-BRqVP3CJ.js.map} +1 -1
- package/package.json +1 -1
- package/dist/context-CZnXf2yb.js.map +0 -1
- package/dist/stub-BqwKn4eh.js.map +0 -1
- package/dist/tracker-BQVoEFUo.js.map +0 -1
- package/dist/types-Cj2RWXbz.js.map +0 -1
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { t as BurdenoffGraphQLClient } from "../graphql-CUDyhibV.js";
|
|
2
|
+
import { m as SDKError, p as SDKContext } from "../index-CTTwo9av.js";
|
|
3
|
+
export declare enum ActivityType {
|
|
4
|
+
CREATE = "create",
|
|
5
|
+
READ = "read",
|
|
6
|
+
UPDATE = "update",
|
|
7
|
+
DELETE = "delete",
|
|
8
|
+
LOGIN = "login",
|
|
9
|
+
LOGOUT = "logout",
|
|
10
|
+
EXPORT = "export",
|
|
11
|
+
IMPORT = "import",
|
|
12
|
+
SHARE = "share",
|
|
13
|
+
DOWNLOAD = "download",
|
|
14
|
+
UPLOAD = "upload",
|
|
15
|
+
EXECUTE = "execute",
|
|
16
|
+
APPROVE = "approve",
|
|
17
|
+
REJECT = "reject",
|
|
18
|
+
CUSTOM = "custom"
|
|
19
|
+
}
|
|
20
|
+
export declare enum ActivityStatus {
|
|
21
|
+
SUCCESS = "success",
|
|
22
|
+
FAILURE = "failure",
|
|
23
|
+
PENDING = "pending",
|
|
24
|
+
WARNING = "warning"
|
|
25
|
+
}
|
|
26
|
+
export declare enum ActivitySeverity {
|
|
27
|
+
LOW = "low",
|
|
28
|
+
MEDIUM = "medium",
|
|
29
|
+
HIGH = "high",
|
|
30
|
+
CRITICAL = "critical"
|
|
31
|
+
}
|
|
32
|
+
export type ActivityActorType = 'user' | 'app' | 'service' | 'super_admin';
|
|
33
|
+
export interface LogActivityOptions {
|
|
34
|
+
userId: string;
|
|
35
|
+
activityType: ActivityType;
|
|
36
|
+
resourceType: string;
|
|
37
|
+
resourceId?: string;
|
|
38
|
+
action: string;
|
|
39
|
+
status: ActivityStatus;
|
|
40
|
+
workspaceId?: string;
|
|
41
|
+
organizationId?: string;
|
|
42
|
+
projectId?: string;
|
|
43
|
+
productId?: string;
|
|
44
|
+
description?: string;
|
|
45
|
+
targetUserId?: string;
|
|
46
|
+
teamId?: string;
|
|
47
|
+
actorType?: ActivityActorType;
|
|
48
|
+
onBehalfOf?: string;
|
|
49
|
+
dedupeKey?: string;
|
|
50
|
+
ipAddress?: string;
|
|
51
|
+
userAgent?: string;
|
|
52
|
+
metadata?: Record<string, unknown>;
|
|
53
|
+
severity?: ActivitySeverity;
|
|
54
|
+
errorMessage?: string;
|
|
55
|
+
duration?: number;
|
|
56
|
+
}
|
|
57
|
+
export interface Activity {
|
|
58
|
+
id: string;
|
|
59
|
+
userId: string;
|
|
60
|
+
activityType: ActivityType;
|
|
61
|
+
resourceType: string;
|
|
62
|
+
resourceId?: string;
|
|
63
|
+
action: string;
|
|
64
|
+
status: ActivityStatus;
|
|
65
|
+
workspaceId?: string;
|
|
66
|
+
organizationId?: string;
|
|
67
|
+
projectId?: string;
|
|
68
|
+
productId?: string;
|
|
69
|
+
description?: string;
|
|
70
|
+
targetUserId?: string;
|
|
71
|
+
actorType?: string;
|
|
72
|
+
onBehalfOf?: string;
|
|
73
|
+
ipAddress?: string;
|
|
74
|
+
userAgent?: string;
|
|
75
|
+
metadata?: Record<string, unknown>;
|
|
76
|
+
severity: ActivitySeverity;
|
|
77
|
+
errorMessage?: string;
|
|
78
|
+
duration?: number;
|
|
79
|
+
createdAt: string;
|
|
80
|
+
}
|
|
81
|
+
export interface GetActivitiesOptions {
|
|
82
|
+
workspaceId?: string;
|
|
83
|
+
userId?: string;
|
|
84
|
+
action?: string;
|
|
85
|
+
resourceType?: string;
|
|
86
|
+
resourceId?: string;
|
|
87
|
+
targetUserId?: string;
|
|
88
|
+
startDate?: string;
|
|
89
|
+
endDate?: string;
|
|
90
|
+
limit?: number;
|
|
91
|
+
offset?: number;
|
|
92
|
+
organizationId?: string;
|
|
93
|
+
projectId?: string;
|
|
94
|
+
activityType?: ActivityType;
|
|
95
|
+
status?: ActivityStatus;
|
|
96
|
+
severity?: ActivitySeverity;
|
|
97
|
+
search?: string;
|
|
98
|
+
sortBy?: 'createdAt' | 'duration' | 'severity';
|
|
99
|
+
sortOrder?: 'asc' | 'desc';
|
|
100
|
+
}
|
|
101
|
+
export interface ActivityStats {
|
|
102
|
+
totalActivities: number;
|
|
103
|
+
successCount: number;
|
|
104
|
+
failureCount: number;
|
|
105
|
+
pendingCount: number;
|
|
106
|
+
warningCount: number;
|
|
107
|
+
averageDuration?: number;
|
|
108
|
+
activitiesByType: Record<string, number>;
|
|
109
|
+
activitiesBySeverity: Record<string, number>;
|
|
110
|
+
topUsers: Array<{
|
|
111
|
+
userId: string;
|
|
112
|
+
count: number;
|
|
113
|
+
}>;
|
|
114
|
+
topResources: Array<{
|
|
115
|
+
resourceType: string;
|
|
116
|
+
count: number;
|
|
117
|
+
}>;
|
|
118
|
+
}
|
|
119
|
+
export declare class ActivityOperationUnsupportedError extends SDKError {
|
|
120
|
+
constructor(operation: string, guidance: string);
|
|
121
|
+
}
|
|
122
|
+
export declare const ACTIVITY_LOG_SELECTION = "\n id\n userId\n action\n description\n details\n timestamp\n productId\n workspaceId\n resourceType\n resourceId\n targetUserId\n ipAddress\n userAgent\n actorType\n onBehalfOf\n context {\n projectId\n custom\n }\n";
|
|
123
|
+
export declare const RECORD_ACTIVITY_MUTATION = "\n mutation RecordActivity($input: RecordActivityInput!) {\n recordActivity(input: $input) {\n \n id\n userId\n action\n description\n details\n timestamp\n productId\n workspaceId\n resourceType\n resourceId\n targetUserId\n ipAddress\n userAgent\n actorType\n onBehalfOf\n context {\n projectId\n custom\n }\n\n }\n }\n";
|
|
124
|
+
export declare const WORKSPACE_ACTIVITY_SLICE_QUERY = "\n query GetWorkspaceActivitySlice($filter: ActivityLogFilter!) {\n getWorkspaceActivitySlice(filter: $filter) {\n \n id\n userId\n action\n description\n details\n timestamp\n productId\n workspaceId\n resourceType\n resourceId\n targetUserId\n ipAddress\n userAgent\n actorType\n onBehalfOf\n context {\n projectId\n custom\n }\n\n }\n activityCount(filter: $filter)\n }\n";
|
|
125
|
+
export interface ActivityLogRecord {
|
|
126
|
+
id: string;
|
|
127
|
+
userId: string;
|
|
128
|
+
action: string;
|
|
129
|
+
description?: string | null;
|
|
130
|
+
details?: unknown;
|
|
131
|
+
timestamp: string;
|
|
132
|
+
productId?: string | null;
|
|
133
|
+
workspaceId?: string | null;
|
|
134
|
+
resourceType?: string | null;
|
|
135
|
+
resourceId?: string | null;
|
|
136
|
+
targetUserId?: string | null;
|
|
137
|
+
ipAddress?: string | null;
|
|
138
|
+
userAgent?: string | null;
|
|
139
|
+
actorType?: string | null;
|
|
140
|
+
onBehalfOf?: string | null;
|
|
141
|
+
context?: {
|
|
142
|
+
projectId?: string | null;
|
|
143
|
+
custom?: unknown;
|
|
144
|
+
} | null;
|
|
145
|
+
}
|
|
146
|
+
export declare function buildRecordActivityInput(options: LogActivityOptions, context?: SDKContext): Record<string, unknown>;
|
|
147
|
+
export declare function toActivity(record: ActivityLogRecord): Activity;
|
|
148
|
+
export declare function buildActivityLogFilter(options: GetActivitiesOptions): Record<string, unknown>;
|
|
149
|
+
export declare class ActivityModule {
|
|
150
|
+
private client;
|
|
151
|
+
private context;
|
|
152
|
+
constructor(client: BurdenoffGraphQLClient, context: SDKContext);
|
|
153
|
+
log(options: LogActivityOptions): Promise<Activity>;
|
|
154
|
+
logSuccess(userId: string, action: string, resourceType: string, resourceId?: string, metadata?: Record<string, unknown>): Promise<Activity>;
|
|
155
|
+
logFailure(userId: string, action: string, resourceType: string, errorMessage: string, resourceId?: string, metadata?: Record<string, unknown>): Promise<Activity>;
|
|
156
|
+
getActivities(options: GetActivitiesOptions): Promise<{
|
|
157
|
+
activities: Activity[];
|
|
158
|
+
total: number;
|
|
159
|
+
}>;
|
|
160
|
+
getActivity(_activityId: string): Promise<Activity>;
|
|
161
|
+
getStats(_options: Omit<GetActivitiesOptions, 'limit' | 'offset'>): Promise<ActivityStats>;
|
|
162
|
+
cleanup(_olderThanDays: number, _workspaceId?: string): Promise<number>;
|
|
163
|
+
exportToCSV(_options: GetActivitiesOptions): Promise<string>;
|
|
164
|
+
private inferActivityType;
|
|
165
|
+
}
|
|
@@ -0,0 +1,389 @@
|
|
|
1
|
+
import { SDKError, ValidationError } from "../types/index.js";
|
|
2
|
+
import { a as logger } from "../logger-B6rCpb7D.js";
|
|
3
|
+
import { n as markExplicitActivity } from "../explicit-activity-scope-DikJ7NAE.js";
|
|
4
|
+
import { randomUUID } from "node:crypto";
|
|
5
|
+
|
|
6
|
+
// src/activity/index.ts
|
|
7
|
+
/**
|
|
8
|
+
* Activity Tracking Module
|
|
9
|
+
*
|
|
10
|
+
* Audit trail writes and reads against the workspace activity owner
|
|
11
|
+
* (`wspace-activity-svc`), reached through the configured workspace internal gateway.
|
|
12
|
+
*
|
|
13
|
+
* The SDK keeps its own descriptive vocabulary (`activityType`, `status`, `severity`,
|
|
14
|
+
* `duration`, ...) for callers, but the owning subgraph's `ActivityLog` type does not have
|
|
15
|
+
* those columns. This module therefore maps between the two contracts explicitly:
|
|
16
|
+
*
|
|
17
|
+
* - writes send only fields `RecordActivityInput` defines and carry the SDK-only fields in
|
|
18
|
+
* `metadata`, which the owner persists verbatim in the row's `details` column;
|
|
19
|
+
* - reads select only fields `ActivityLog` defines and rebuild the SDK shape from the row
|
|
20
|
+
* plus those persisted `details`.
|
|
21
|
+
*
|
|
22
|
+
* Selecting a field the owner does not define fails GraphQL validation for the whole
|
|
23
|
+
* operation, so the selections below are pinned by unit tests against the published schema.
|
|
24
|
+
*/
|
|
25
|
+
let ActivityType = /* @__PURE__ */ function(ActivityType) {
|
|
26
|
+
ActivityType["CREATE"] = "create";
|
|
27
|
+
ActivityType["READ"] = "read";
|
|
28
|
+
ActivityType["UPDATE"] = "update";
|
|
29
|
+
ActivityType["DELETE"] = "delete";
|
|
30
|
+
ActivityType["LOGIN"] = "login";
|
|
31
|
+
ActivityType["LOGOUT"] = "logout";
|
|
32
|
+
ActivityType["EXPORT"] = "export";
|
|
33
|
+
ActivityType["IMPORT"] = "import";
|
|
34
|
+
ActivityType["SHARE"] = "share";
|
|
35
|
+
ActivityType["DOWNLOAD"] = "download";
|
|
36
|
+
ActivityType["UPLOAD"] = "upload";
|
|
37
|
+
ActivityType["EXECUTE"] = "execute";
|
|
38
|
+
ActivityType["APPROVE"] = "approve";
|
|
39
|
+
ActivityType["REJECT"] = "reject";
|
|
40
|
+
ActivityType["CUSTOM"] = "custom";
|
|
41
|
+
return ActivityType;
|
|
42
|
+
}({});
|
|
43
|
+
let ActivityStatus = /* @__PURE__ */ function(ActivityStatus) {
|
|
44
|
+
ActivityStatus["SUCCESS"] = "success";
|
|
45
|
+
ActivityStatus["FAILURE"] = "failure";
|
|
46
|
+
ActivityStatus["PENDING"] = "pending";
|
|
47
|
+
ActivityStatus["WARNING"] = "warning";
|
|
48
|
+
return ActivityStatus;
|
|
49
|
+
}({});
|
|
50
|
+
let ActivitySeverity = /* @__PURE__ */ function(ActivitySeverity) {
|
|
51
|
+
ActivitySeverity["LOW"] = "low";
|
|
52
|
+
ActivitySeverity["MEDIUM"] = "medium";
|
|
53
|
+
ActivitySeverity["HIGH"] = "high";
|
|
54
|
+
ActivitySeverity["CRITICAL"] = "critical";
|
|
55
|
+
return ActivitySeverity;
|
|
56
|
+
}({});
|
|
57
|
+
/** Thrown by SDK operations the current activity owner does not expose. */
|
|
58
|
+
var ActivityOperationUnsupportedError = class ActivityOperationUnsupportedError extends SDKError {
|
|
59
|
+
constructor(operation, guidance) {
|
|
60
|
+
super(`ActivityModule.${operation} is not supported by the workspace activity owner: ${guidance}`, "ACTIVITY_OPERATION_UNSUPPORTED", { operation });
|
|
61
|
+
this.name = "ActivityOperationUnsupportedError";
|
|
62
|
+
Object.setPrototypeOf(this, ActivityOperationUnsupportedError.prototype);
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* `ActivityLog` fields selected from wspace-activity-svc. Every name here must exist on the
|
|
67
|
+
* owner's published `ActivityLog` type (see tests/activity-module.test.ts).
|
|
68
|
+
*/
|
|
69
|
+
const ACTIVITY_LOG_SELECTION = `
|
|
70
|
+
id
|
|
71
|
+
userId
|
|
72
|
+
action
|
|
73
|
+
description
|
|
74
|
+
details
|
|
75
|
+
timestamp
|
|
76
|
+
productId
|
|
77
|
+
workspaceId
|
|
78
|
+
resourceType
|
|
79
|
+
resourceId
|
|
80
|
+
targetUserId
|
|
81
|
+
ipAddress
|
|
82
|
+
userAgent
|
|
83
|
+
actorType
|
|
84
|
+
onBehalfOf
|
|
85
|
+
context {
|
|
86
|
+
projectId
|
|
87
|
+
custom
|
|
88
|
+
}
|
|
89
|
+
`;
|
|
90
|
+
const RECORD_ACTIVITY_MUTATION = `
|
|
91
|
+
mutation RecordActivity($input: RecordActivityInput!) {
|
|
92
|
+
recordActivity(input: $input) {
|
|
93
|
+
${ACTIVITY_LOG_SELECTION}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
`;
|
|
97
|
+
const WORKSPACE_ACTIVITY_SLICE_QUERY = `
|
|
98
|
+
query GetWorkspaceActivitySlice($filter: ActivityLogFilter!) {
|
|
99
|
+
getWorkspaceActivitySlice(filter: $filter) {
|
|
100
|
+
${ACTIVITY_LOG_SELECTION}
|
|
101
|
+
}
|
|
102
|
+
activityCount(filter: $filter)
|
|
103
|
+
}
|
|
104
|
+
`;
|
|
105
|
+
/**
|
|
106
|
+
* Keys the SDK stores inside `metadata`/`details` for its own fields. The owner overwrites
|
|
107
|
+
* `metadata.ipAddress`/`metadata.userAgent` with the relaying request's values, so the end
|
|
108
|
+
* user's request details travel under their own keys.
|
|
109
|
+
*/
|
|
110
|
+
const SDK_DETAIL_KEYS = [
|
|
111
|
+
"activityType",
|
|
112
|
+
"status",
|
|
113
|
+
"severity",
|
|
114
|
+
"duration",
|
|
115
|
+
"organizationId",
|
|
116
|
+
"projectId",
|
|
117
|
+
"requestIpAddress",
|
|
118
|
+
"requestUserAgent",
|
|
119
|
+
"errorMessage",
|
|
120
|
+
"ipAddress",
|
|
121
|
+
"userAgent"
|
|
122
|
+
];
|
|
123
|
+
function readRecord(value) {
|
|
124
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
|
|
125
|
+
}
|
|
126
|
+
function readString(value) {
|
|
127
|
+
return typeof value === "string" && value.length > 0 ? value : void 0;
|
|
128
|
+
}
|
|
129
|
+
function readEnum(values, value, fallback) {
|
|
130
|
+
const allowed = Object.values(values);
|
|
131
|
+
return typeof value === "string" && allowed.includes(value) ? value : fallback;
|
|
132
|
+
}
|
|
133
|
+
/** Remove undefined entries so the payload only names fields the caller actually set. */
|
|
134
|
+
function compact(input) {
|
|
135
|
+
return Object.fromEntries(Object.entries(input).filter(([, value]) => value !== void 0));
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Build the wspace-activity-svc `RecordActivityInput` for an SDK activity.
|
|
139
|
+
* Exported for unit tests.
|
|
140
|
+
*/
|
|
141
|
+
function buildRecordActivityInput(options, context = {}) {
|
|
142
|
+
const severity = options.severity ?? "low";
|
|
143
|
+
const metadata = compact({
|
|
144
|
+
...options.metadata,
|
|
145
|
+
activityType: options.activityType,
|
|
146
|
+
status: options.status,
|
|
147
|
+
severity,
|
|
148
|
+
duration: options.duration,
|
|
149
|
+
errorMessage: options.errorMessage,
|
|
150
|
+
organizationId: options.organizationId,
|
|
151
|
+
projectId: options.projectId,
|
|
152
|
+
requestIpAddress: options.ipAddress,
|
|
153
|
+
requestUserAgent: options.userAgent
|
|
154
|
+
});
|
|
155
|
+
const activityContext = compact({
|
|
156
|
+
workspaceId: options.workspaceId,
|
|
157
|
+
userId: options.userId,
|
|
158
|
+
projectId: options.projectId,
|
|
159
|
+
custom: options.organizationId ? { organizationId: options.organizationId } : void 0
|
|
160
|
+
});
|
|
161
|
+
return compact({
|
|
162
|
+
action: options.action,
|
|
163
|
+
description: options.description,
|
|
164
|
+
resourceType: options.resourceType,
|
|
165
|
+
resourceId: options.resourceId,
|
|
166
|
+
workspaceId: options.workspaceId,
|
|
167
|
+
productId: options.productId ?? context.productId,
|
|
168
|
+
targetUserId: options.targetUserId,
|
|
169
|
+
teamId: options.teamId,
|
|
170
|
+
success: options.status !== "failure",
|
|
171
|
+
errorMessage: options.errorMessage,
|
|
172
|
+
actorType: options.actorType,
|
|
173
|
+
onBehalfOf: options.onBehalfOf,
|
|
174
|
+
context: activityContext,
|
|
175
|
+
metadata,
|
|
176
|
+
dedupeKey: options.dedupeKey ?? `sdk-activity:${randomUUID()}`
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Rebuild the SDK `Activity` shape from an owner row. Fields the owner has no column for are
|
|
181
|
+
* read back from the persisted `details`. Exported for unit tests.
|
|
182
|
+
*/
|
|
183
|
+
function toActivity(record) {
|
|
184
|
+
const details = readRecord(record.details) ?? {};
|
|
185
|
+
const custom = readRecord(record.context?.custom);
|
|
186
|
+
const metadata = {};
|
|
187
|
+
for (const [key, value] of Object.entries(details)) if (!SDK_DETAIL_KEYS.includes(key)) metadata[key] = value;
|
|
188
|
+
const duration = details["duration"];
|
|
189
|
+
return {
|
|
190
|
+
id: record.id,
|
|
191
|
+
userId: record.userId,
|
|
192
|
+
activityType: readEnum(ActivityType, details["activityType"], "custom"),
|
|
193
|
+
resourceType: record.resourceType ?? "",
|
|
194
|
+
resourceId: record.resourceId ?? void 0,
|
|
195
|
+
action: record.action,
|
|
196
|
+
status: readEnum(ActivityStatus, details["status"], "success"),
|
|
197
|
+
workspaceId: record.workspaceId ?? void 0,
|
|
198
|
+
organizationId: readString(details["organizationId"]) ?? readString(custom?.["organizationId"]),
|
|
199
|
+
projectId: record.context?.projectId ?? readString(details["projectId"]),
|
|
200
|
+
productId: record.productId ?? void 0,
|
|
201
|
+
description: record.description ?? void 0,
|
|
202
|
+
targetUserId: record.targetUserId ?? void 0,
|
|
203
|
+
actorType: record.actorType ?? void 0,
|
|
204
|
+
onBehalfOf: record.onBehalfOf ?? void 0,
|
|
205
|
+
ipAddress: readString(details["requestIpAddress"]) ?? record.ipAddress ?? void 0,
|
|
206
|
+
userAgent: readString(details["requestUserAgent"]) ?? record.userAgent ?? void 0,
|
|
207
|
+
metadata,
|
|
208
|
+
severity: readEnum(ActivitySeverity, details["severity"], "low"),
|
|
209
|
+
errorMessage: readString(details["errorMessage"]),
|
|
210
|
+
duration: typeof duration === "number" && Number.isFinite(duration) ? duration : void 0,
|
|
211
|
+
createdAt: record.timestamp
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Build the owner's `ActivityLogFilter` for an SDK read. Filters the owner cannot apply are
|
|
216
|
+
* rejected rather than dropped, because dropping them would return rows the caller excluded.
|
|
217
|
+
* Exported for unit tests.
|
|
218
|
+
*/
|
|
219
|
+
function buildActivityLogFilter(options) {
|
|
220
|
+
if (!options.workspaceId) throw new ValidationError("workspaceId is required to read activities");
|
|
221
|
+
const unsupported = [
|
|
222
|
+
"organizationId",
|
|
223
|
+
"projectId",
|
|
224
|
+
"activityType",
|
|
225
|
+
"status",
|
|
226
|
+
"severity",
|
|
227
|
+
"search"
|
|
228
|
+
].filter((key) => options[key] !== void 0);
|
|
229
|
+
if (options.sortBy !== void 0 && options.sortBy !== "createdAt") unsupported.push("sortBy");
|
|
230
|
+
if (options.sortOrder !== void 0 && options.sortOrder !== "desc") unsupported.push("sortOrder");
|
|
231
|
+
if (unsupported.length > 0) throw new ValidationError(`Activity filters not supported by the workspace activity owner: ${unsupported.join(", ")}`, { unsupported });
|
|
232
|
+
return compact({
|
|
233
|
+
workspaceId: options.workspaceId,
|
|
234
|
+
userId: options.userId,
|
|
235
|
+
action: options.action,
|
|
236
|
+
resourceType: options.resourceType,
|
|
237
|
+
resourceId: options.resourceId,
|
|
238
|
+
targetUserId: options.targetUserId,
|
|
239
|
+
startDate: options.startDate,
|
|
240
|
+
endDate: options.endDate,
|
|
241
|
+
limit: options.limit ?? 50,
|
|
242
|
+
offset: options.offset ?? 0
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Activity Tracking Module
|
|
247
|
+
*/
|
|
248
|
+
var ActivityModule = class {
|
|
249
|
+
client;
|
|
250
|
+
context;
|
|
251
|
+
constructor(client, context) {
|
|
252
|
+
this.client = client;
|
|
253
|
+
this.context = context;
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Log activity
|
|
257
|
+
*
|
|
258
|
+
* The write is relayed as a platform service acting for `userId`, the same identity
|
|
259
|
+
* transport `trackOperation` uses, so the owner records the end user as the actor and
|
|
260
|
+
* honours `actorType`/`onBehalfOf` from the input.
|
|
261
|
+
*/
|
|
262
|
+
async log(options) {
|
|
263
|
+
if (!options.userId) throw new ValidationError("User ID is required");
|
|
264
|
+
if (!options.activityType) throw new ValidationError("Activity type is required");
|
|
265
|
+
if (!options.resourceType) throw new ValidationError("Resource type is required");
|
|
266
|
+
if (!options.action) throw new ValidationError("Action is required");
|
|
267
|
+
if (!options.status) throw new ValidationError("Status is required");
|
|
268
|
+
markExplicitActivity();
|
|
269
|
+
logger.debug("[Activity] Logging activity", {
|
|
270
|
+
userId: options.userId,
|
|
271
|
+
action: options.action,
|
|
272
|
+
resourceType: options.resourceType
|
|
273
|
+
});
|
|
274
|
+
const input = buildRecordActivityInput(options, this.context);
|
|
275
|
+
const requestContext = {
|
|
276
|
+
...this.context,
|
|
277
|
+
actorId: options.userId,
|
|
278
|
+
actorType: "service",
|
|
279
|
+
workspaceId: options.workspaceId ?? this.context.workspaceId
|
|
280
|
+
};
|
|
281
|
+
const activity = toActivity((await this.client.query(RECORD_ACTIVITY_MUTATION, { input }, requestContext)).recordActivity);
|
|
282
|
+
logger.info("[Activity] Activity logged", { activityId: activity.id });
|
|
283
|
+
return activity;
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* Log activity with automatic status detection
|
|
287
|
+
*/
|
|
288
|
+
async logSuccess(userId, action, resourceType, resourceId, metadata) {
|
|
289
|
+
return this.log({
|
|
290
|
+
userId,
|
|
291
|
+
action,
|
|
292
|
+
resourceType,
|
|
293
|
+
resourceId,
|
|
294
|
+
activityType: this.inferActivityType(action),
|
|
295
|
+
status: "success",
|
|
296
|
+
severity: "low",
|
|
297
|
+
metadata,
|
|
298
|
+
workspaceId: this.context.workspaceId
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Log failed activity
|
|
303
|
+
*/
|
|
304
|
+
async logFailure(userId, action, resourceType, errorMessage, resourceId, metadata) {
|
|
305
|
+
return this.log({
|
|
306
|
+
userId,
|
|
307
|
+
action,
|
|
308
|
+
resourceType,
|
|
309
|
+
resourceId,
|
|
310
|
+
activityType: this.inferActivityType(action),
|
|
311
|
+
status: "failure",
|
|
312
|
+
severity: "high",
|
|
313
|
+
errorMessage,
|
|
314
|
+
metadata,
|
|
315
|
+
workspaceId: this.context.workspaceId
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* Get one workspace's activities, newest first.
|
|
320
|
+
*
|
|
321
|
+
* Reads the owner's workspace-scoped slice (`getWorkspaceActivitySlice`) together with the
|
|
322
|
+
* matching `activityCount`, so `total` counts every row the filter matches, not just the page.
|
|
323
|
+
*/
|
|
324
|
+
async getActivities(options) {
|
|
325
|
+
logger.debug("[Activity] Getting activities", options);
|
|
326
|
+
const filter = buildActivityLogFilter(options);
|
|
327
|
+
const requestContext = {
|
|
328
|
+
...this.context,
|
|
329
|
+
workspaceId: options.workspaceId
|
|
330
|
+
};
|
|
331
|
+
const response = await this.client.query(WORKSPACE_ACTIVITY_SLICE_QUERY, { filter }, requestContext);
|
|
332
|
+
return {
|
|
333
|
+
activities: response.getWorkspaceActivitySlice.map(toActivity),
|
|
334
|
+
total: response.activityCount
|
|
335
|
+
};
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* @deprecated The workspace activity owner has no read-by-id operation. Use
|
|
339
|
+
* {@link getActivities} with `resourceId`/`action` filters instead.
|
|
340
|
+
*/
|
|
341
|
+
async getActivity(_activityId) {
|
|
342
|
+
throw new ActivityOperationUnsupportedError("getActivity", "use getActivities with a workspace filter");
|
|
343
|
+
}
|
|
344
|
+
/**
|
|
345
|
+
* @deprecated The workspace activity owner has no statistics operation. Use
|
|
346
|
+
* {@link getActivities} (its `total` is the owner's `activityCount`) per filter instead.
|
|
347
|
+
*/
|
|
348
|
+
async getStats(_options) {
|
|
349
|
+
throw new ActivityOperationUnsupportedError("getStats", "use getActivities and its total per filter");
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* @deprecated Retention is enforced by the activity owner's retention policy and legal holds;
|
|
353
|
+
* there is no client-driven cleanup operation.
|
|
354
|
+
*/
|
|
355
|
+
async cleanup(_olderThanDays, _workspaceId) {
|
|
356
|
+
throw new ActivityOperationUnsupportedError("cleanup", "retention is enforced by the activity owner");
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* @deprecated The workspace activity owner exports through `exportActivityLogsSiem`
|
|
360
|
+
* (CEF/LEEF/JSON lines); there is no CSV export operation.
|
|
361
|
+
*/
|
|
362
|
+
async exportToCSV(_options) {
|
|
363
|
+
throw new ActivityOperationUnsupportedError("exportToCSV", "use the owner exportActivityLogsSiem query");
|
|
364
|
+
}
|
|
365
|
+
/**
|
|
366
|
+
* Infer activity type from action string
|
|
367
|
+
*/
|
|
368
|
+
inferActivityType(action) {
|
|
369
|
+
const actionLower = action.toLowerCase();
|
|
370
|
+
if (actionLower.includes("create") || actionLower.includes("add")) return "create";
|
|
371
|
+
if (actionLower.includes("update") || actionLower.includes("edit") || actionLower.includes("modify")) return "update";
|
|
372
|
+
if (actionLower.includes("delete") || actionLower.includes("remove")) return "delete";
|
|
373
|
+
if (actionLower.includes("read") || actionLower.includes("view") || actionLower.includes("get")) return "read";
|
|
374
|
+
if (actionLower.includes("login") || actionLower.includes("signin")) return "login";
|
|
375
|
+
if (actionLower.includes("logout") || actionLower.includes("signout")) return "logout";
|
|
376
|
+
if (actionLower.includes("export")) return "export";
|
|
377
|
+
if (actionLower.includes("import")) return "import";
|
|
378
|
+
if (actionLower.includes("share")) return "share";
|
|
379
|
+
if (actionLower.includes("download")) return "download";
|
|
380
|
+
if (actionLower.includes("upload")) return "upload";
|
|
381
|
+
if (actionLower.includes("execute") || actionLower.includes("run")) return "execute";
|
|
382
|
+
if (actionLower.includes("approve")) return "approve";
|
|
383
|
+
if (actionLower.includes("reject")) return "reject";
|
|
384
|
+
return "custom";
|
|
385
|
+
}
|
|
386
|
+
};
|
|
387
|
+
|
|
388
|
+
export { ACTIVITY_LOG_SELECTION, ActivityModule, ActivityOperationUnsupportedError, ActivitySeverity, ActivityStatus, ActivityType, RECORD_ACTIVITY_MUTATION, WORKSPACE_ACTIVITY_SLICE_QUERY, buildActivityLogFilter, buildRecordActivityInput, toActivity };
|
|
389
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/activity/index.ts"],"sourcesContent":["/**\n * Activity Tracking Module\n *\n * Audit trail writes and reads against the workspace activity owner\n * (`wspace-activity-svc`), reached through the configured workspace internal gateway.\n *\n * The SDK keeps its own descriptive vocabulary (`activityType`, `status`, `severity`,\n * `duration`, ...) for callers, but the owning subgraph's `ActivityLog` type does not have\n * those columns. This module therefore maps between the two contracts explicitly:\n *\n * - writes send only fields `RecordActivityInput` defines and carry the SDK-only fields in\n * `metadata`, which the owner persists verbatim in the row's `details` column;\n * - reads select only fields `ActivityLog` defines and rebuild the SDK shape from the row\n * plus those persisted `details`.\n *\n * Selecting a field the owner does not define fails GraphQL validation for the whole\n * operation, so the selections below are pinned by unit tests against the published schema.\n */\n\nimport { randomUUID } from 'node:crypto';\nimport type { BurdenoffGraphQLClient } from '../client/graphql.js';\nimport type { SDKContext } from '../types/index.js';\nimport { SDKError, ValidationError } from '../types/index.js';\nimport { logger } from '../logger/index.js';\nimport { markExplicitActivity } from './explicit-activity-scope.js';\n\nexport enum ActivityType {\n CREATE = 'create',\n READ = 'read',\n UPDATE = 'update',\n DELETE = 'delete',\n LOGIN = 'login',\n LOGOUT = 'logout',\n EXPORT = 'export',\n IMPORT = 'import',\n SHARE = 'share',\n DOWNLOAD = 'download',\n UPLOAD = 'upload',\n EXECUTE = 'execute',\n APPROVE = 'approve',\n REJECT = 'reject',\n CUSTOM = 'custom',\n}\n\nexport enum ActivityStatus {\n SUCCESS = 'success',\n FAILURE = 'failure',\n PENDING = 'pending',\n WARNING = 'warning',\n}\n\nexport enum ActivitySeverity {\n LOW = 'low',\n MEDIUM = 'medium',\n HIGH = 'high',\n CRITICAL = 'critical',\n}\n\n/** Kinds of actor the activity owner records (the gateway `x-actor-type` vocabulary). */\nexport type ActivityActorType = 'user' | 'app' | 'service' | 'super_admin';\n\nexport interface LogActivityOptions {\n /** User performing the action */\n userId: string;\n /** Type of activity */\n activityType: ActivityType;\n /** Resource type being acted upon */\n resourceType: string;\n /** Resource ID */\n resourceId?: string;\n /** Action performed */\n action: string;\n /** Activity status */\n status: ActivityStatus;\n /** Workspace context */\n workspaceId?: string;\n /** Organization context */\n organizationId?: string;\n /** Project context */\n projectId?: string;\n /** Product that emitted the activity (defaults to the SDK context's productId) */\n productId?: string;\n /** Human-readable description (the owner generates one when omitted) */\n description?: string;\n /** User affected by the action, when different from the actor */\n targetUserId?: string;\n /** Team (group) the action belongs to */\n teamId?: string;\n /** Kind of actor that performed the action, when the caller can vouch for it */\n actorType?: ActivityActorType;\n /** User on whose behalf the action was taken (for an agent action: the human who started it) */\n onBehalfOf?: string;\n /**\n * Idempotency key. Replaying a write with the same key returns the existing row. A random\n * key is generated when omitted so the client's own transport retries never duplicate rows.\n */\n dedupeKey?: string;\n /** IP address of the end user's request */\n ipAddress?: string;\n /** User agent of the end user's request */\n userAgent?: string;\n /** Additional metadata */\n metadata?: Record<string, unknown>;\n /** Severity level */\n severity?: ActivitySeverity;\n /** Error message if failed */\n errorMessage?: string;\n /** Duration in milliseconds */\n duration?: number;\n}\n\nexport interface Activity {\n id: string;\n userId: string;\n activityType: ActivityType;\n resourceType: string;\n resourceId?: string;\n action: string;\n status: ActivityStatus;\n workspaceId?: string;\n organizationId?: string;\n projectId?: string;\n productId?: string;\n description?: string;\n targetUserId?: string;\n actorType?: string;\n onBehalfOf?: string;\n ipAddress?: string;\n userAgent?: string;\n metadata?: Record<string, unknown>;\n severity: ActivitySeverity;\n errorMessage?: string;\n duration?: number;\n createdAt: string;\n}\n\nexport interface GetActivitiesOptions {\n /** Workspace to read (required: the owner scopes every service read to one workspace) */\n workspaceId?: string;\n /** Filter by user */\n userId?: string;\n /** Filter by exact action */\n action?: string;\n /** Filter by resource type */\n resourceType?: string;\n /** Filter by resource ID */\n resourceId?: string;\n /** Filter by the user affected by the action */\n targetUserId?: string;\n /** Filter by date range */\n startDate?: string;\n endDate?: string;\n /** Limit number of results (the owner caps a page at 200) */\n limit?: number;\n /** Offset for pagination */\n offset?: number;\n /**\n * Not supported by the activity owner. Passing any of the fields below throws a\n * `ValidationError` instead of silently returning an unfiltered page.\n */\n organizationId?: string;\n projectId?: string;\n activityType?: ActivityType;\n status?: ActivityStatus;\n severity?: ActivitySeverity;\n search?: string;\n /** Only `createdAt` (newest first) is supported */\n sortBy?: 'createdAt' | 'duration' | 'severity';\n /** Only `desc` is supported */\n sortOrder?: 'asc' | 'desc';\n}\n\nexport interface ActivityStats {\n totalActivities: number;\n successCount: number;\n failureCount: number;\n pendingCount: number;\n warningCount: number;\n averageDuration?: number;\n activitiesByType: Record<string, number>;\n activitiesBySeverity: Record<string, number>;\n topUsers: Array<{ userId: string; count: number }>;\n topResources: Array<{ resourceType: string; count: number }>;\n}\n\n/** Thrown by SDK operations the current activity owner does not expose. */\nexport class ActivityOperationUnsupportedError extends SDKError {\n constructor(operation: string, guidance: string) {\n super(\n `ActivityModule.${operation} is not supported by the workspace activity owner: ${guidance}`,\n 'ACTIVITY_OPERATION_UNSUPPORTED',\n { operation }\n );\n this.name = 'ActivityOperationUnsupportedError';\n Object.setPrototypeOf(this, ActivityOperationUnsupportedError.prototype);\n }\n}\n\n/**\n * `ActivityLog` fields selected from wspace-activity-svc. Every name here must exist on the\n * owner's published `ActivityLog` type (see tests/activity-module.test.ts).\n */\nexport const ACTIVITY_LOG_SELECTION = `\n id\n userId\n action\n description\n details\n timestamp\n productId\n workspaceId\n resourceType\n resourceId\n targetUserId\n ipAddress\n userAgent\n actorType\n onBehalfOf\n context {\n projectId\n custom\n }\n`;\n\nexport const RECORD_ACTIVITY_MUTATION = `\n mutation RecordActivity($input: RecordActivityInput!) {\n recordActivity(input: $input) {\n ${ACTIVITY_LOG_SELECTION}\n }\n }\n`;\n\nexport const WORKSPACE_ACTIVITY_SLICE_QUERY = `\n query GetWorkspaceActivitySlice($filter: ActivityLogFilter!) {\n getWorkspaceActivitySlice(filter: $filter) {\n ${ACTIVITY_LOG_SELECTION}\n }\n activityCount(filter: $filter)\n }\n`;\n\n/** Raw `ActivityLog` row as selected by {@link ACTIVITY_LOG_SELECTION}. */\nexport interface ActivityLogRecord {\n id: string;\n userId: string;\n action: string;\n description?: string | null;\n details?: unknown;\n timestamp: string;\n productId?: string | null;\n workspaceId?: string | null;\n resourceType?: string | null;\n resourceId?: string | null;\n targetUserId?: string | null;\n ipAddress?: string | null;\n userAgent?: string | null;\n actorType?: string | null;\n onBehalfOf?: string | null;\n context?: { projectId?: string | null; custom?: unknown } | null;\n}\n\n/**\n * Keys the SDK stores inside `metadata`/`details` for its own fields. The owner overwrites\n * `metadata.ipAddress`/`metadata.userAgent` with the relaying request's values, so the end\n * user's request details travel under their own keys.\n */\nconst SDK_DETAIL_KEYS = [\n 'activityType',\n 'status',\n 'severity',\n 'duration',\n 'organizationId',\n 'projectId',\n 'requestIpAddress',\n 'requestUserAgent',\n 'errorMessage',\n 'ipAddress',\n 'userAgent',\n] as const;\n\nfunction readRecord(value: unknown): Record<string, unknown> | undefined {\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n ? (value as Record<string, unknown>)\n : undefined;\n}\n\nfunction readString(value: unknown): string | undefined {\n return typeof value === 'string' && value.length > 0 ? value : undefined;\n}\n\nfunction readEnum<T extends string>(values: Record<string, T>, value: unknown, fallback: T): T {\n const allowed: readonly string[] = Object.values(values);\n return typeof value === 'string' && allowed.includes(value) ? (value as T) : fallback;\n}\n\n/** Remove undefined entries so the payload only names fields the caller actually set. */\nfunction compact(input: Record<string, unknown>): Record<string, unknown> {\n return Object.fromEntries(Object.entries(input).filter(([, value]) => value !== undefined));\n}\n\n/**\n * Build the wspace-activity-svc `RecordActivityInput` for an SDK activity.\n * Exported for unit tests.\n */\nexport function buildRecordActivityInput(\n options: LogActivityOptions,\n context: SDKContext = {}\n): Record<string, unknown> {\n const severity = options.severity ?? ActivitySeverity.LOW;\n const metadata = compact({\n ...options.metadata,\n activityType: options.activityType,\n status: options.status,\n severity,\n duration: options.duration,\n // The owner stores errorMessage in a column it does not expose on ActivityLog; keeping a\n // copy in details is what lets a read return it.\n errorMessage: options.errorMessage,\n organizationId: options.organizationId,\n projectId: options.projectId,\n requestIpAddress: options.ipAddress,\n requestUserAgent: options.userAgent,\n });\n\n const activityContext = compact({\n workspaceId: options.workspaceId,\n userId: options.userId,\n projectId: options.projectId,\n custom: options.organizationId ? { organizationId: options.organizationId } : undefined,\n });\n\n return compact({\n action: options.action,\n description: options.description,\n resourceType: options.resourceType,\n resourceId: options.resourceId,\n workspaceId: options.workspaceId,\n productId: options.productId ?? context.productId,\n targetUserId: options.targetUserId,\n teamId: options.teamId,\n success: options.status !== ActivityStatus.FAILURE,\n errorMessage: options.errorMessage,\n actorType: options.actorType,\n onBehalfOf: options.onBehalfOf,\n context: activityContext,\n metadata,\n dedupeKey: options.dedupeKey ?? `sdk-activity:${randomUUID()}`,\n });\n}\n\n/**\n * Rebuild the SDK `Activity` shape from an owner row. Fields the owner has no column for are\n * read back from the persisted `details`. Exported for unit tests.\n */\nexport function toActivity(record: ActivityLogRecord): Activity {\n const details = readRecord(record.details) ?? {};\n const custom = readRecord(record.context?.custom);\n\n const metadata: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(details)) {\n if (!(SDK_DETAIL_KEYS as readonly string[]).includes(key)) metadata[key] = value;\n }\n\n const duration = details['duration'];\n\n return {\n id: record.id,\n userId: record.userId,\n activityType: readEnum(ActivityType, details['activityType'], ActivityType.CUSTOM),\n resourceType: record.resourceType ?? '',\n resourceId: record.resourceId ?? undefined,\n action: record.action,\n status: readEnum(ActivityStatus, details['status'], ActivityStatus.SUCCESS),\n workspaceId: record.workspaceId ?? undefined,\n organizationId: readString(details['organizationId']) ?? readString(custom?.['organizationId']),\n projectId: record.context?.projectId ?? readString(details['projectId']),\n productId: record.productId ?? undefined,\n description: record.description ?? undefined,\n targetUserId: record.targetUserId ?? undefined,\n actorType: record.actorType ?? undefined,\n onBehalfOf: record.onBehalfOf ?? undefined,\n ipAddress: readString(details['requestIpAddress']) ?? record.ipAddress ?? undefined,\n userAgent: readString(details['requestUserAgent']) ?? record.userAgent ?? undefined,\n metadata,\n severity: readEnum(ActivitySeverity, details['severity'], ActivitySeverity.LOW),\n errorMessage: readString(details['errorMessage']),\n duration: typeof duration === 'number' && Number.isFinite(duration) ? duration : undefined,\n createdAt: record.timestamp,\n };\n}\n\n/**\n * Build the owner's `ActivityLogFilter` for an SDK read. Filters the owner cannot apply are\n * rejected rather than dropped, because dropping them would return rows the caller excluded.\n * Exported for unit tests.\n */\nexport function buildActivityLogFilter(options: GetActivitiesOptions): Record<string, unknown> {\n if (!options.workspaceId) {\n throw new ValidationError('workspaceId is required to read activities');\n }\n\n const unsupported: string[] = (\n ['organizationId', 'projectId', 'activityType', 'status', 'severity', 'search'] as const\n ).filter((key) => options[key] !== undefined);\n if (options.sortBy !== undefined && options.sortBy !== 'createdAt') unsupported.push('sortBy');\n if (options.sortOrder !== undefined && options.sortOrder !== 'desc') unsupported.push('sortOrder');\n if (unsupported.length > 0) {\n throw new ValidationError(\n `Activity filters not supported by the workspace activity owner: ${unsupported.join(', ')}`,\n { unsupported }\n );\n }\n\n return compact({\n workspaceId: options.workspaceId,\n userId: options.userId,\n action: options.action,\n resourceType: options.resourceType,\n resourceId: options.resourceId,\n targetUserId: options.targetUserId,\n startDate: options.startDate,\n endDate: options.endDate,\n limit: options.limit ?? 50,\n offset: options.offset ?? 0,\n });\n}\n\n/**\n * Activity Tracking Module\n */\nexport class ActivityModule {\n constructor(\n private client: BurdenoffGraphQLClient,\n private context: SDKContext\n ) {}\n\n /**\n * Log activity\n *\n * The write is relayed as a platform service acting for `userId`, the same identity\n * transport `trackOperation` uses, so the owner records the end user as the actor and\n * honours `actorType`/`onBehalfOf` from the input.\n */\n public async log(options: LogActivityOptions): Promise<Activity> {\n // Validate required fields\n if (!options.userId) {\n throw new ValidationError('User ID is required');\n }\n\n if (!options.activityType) {\n throw new ValidationError('Activity type is required');\n }\n\n if (!options.resourceType) {\n throw new ValidationError('Resource type is required');\n }\n\n if (!options.action) {\n throw new ValidationError('Action is required');\n }\n\n if (!options.status) {\n throw new ValidationError('Status is required');\n }\n\n // A validated explicit write: the mutation-audit backstop skips its generic row for this operation.\n markExplicitActivity();\n\n logger.debug('[Activity] Logging activity', {\n userId: options.userId,\n action: options.action,\n resourceType: options.resourceType,\n });\n\n const input = buildRecordActivityInput(options, this.context);\n const requestContext: SDKContext = {\n ...this.context,\n actorId: options.userId,\n actorType: 'service',\n workspaceId: options.workspaceId ?? this.context.workspaceId,\n };\n\n const response = await this.client.query<{ recordActivity: ActivityLogRecord }>(\n RECORD_ACTIVITY_MUTATION,\n { input },\n requestContext\n );\n\n const activity = toActivity(response.recordActivity);\n logger.info('[Activity] Activity logged', { activityId: activity.id });\n return activity;\n }\n\n /**\n * Log activity with automatic status detection\n */\n public async logSuccess(\n userId: string,\n action: string,\n resourceType: string,\n resourceId?: string,\n metadata?: Record<string, unknown>\n ): Promise<Activity> {\n return this.log({\n userId,\n action,\n resourceType,\n resourceId,\n activityType: this.inferActivityType(action),\n status: ActivityStatus.SUCCESS,\n severity: ActivitySeverity.LOW,\n metadata,\n workspaceId: this.context.workspaceId,\n });\n }\n\n /**\n * Log failed activity\n */\n public async logFailure(\n userId: string,\n action: string,\n resourceType: string,\n errorMessage: string,\n resourceId?: string,\n metadata?: Record<string, unknown>\n ): Promise<Activity> {\n return this.log({\n userId,\n action,\n resourceType,\n resourceId,\n activityType: this.inferActivityType(action),\n status: ActivityStatus.FAILURE,\n severity: ActivitySeverity.HIGH,\n errorMessage,\n metadata,\n workspaceId: this.context.workspaceId,\n });\n }\n\n /**\n * Get one workspace's activities, newest first.\n *\n * Reads the owner's workspace-scoped slice (`getWorkspaceActivitySlice`) together with the\n * matching `activityCount`, so `total` counts every row the filter matches, not just the page.\n */\n public async getActivities(options: GetActivitiesOptions): Promise<{\n activities: Activity[];\n total: number;\n }> {\n logger.debug('[Activity] Getting activities', options);\n\n const filter = buildActivityLogFilter(options);\n const requestContext: SDKContext = {\n ...this.context,\n workspaceId: options.workspaceId,\n };\n\n const response = await this.client.query<{\n getWorkspaceActivitySlice: ActivityLogRecord[];\n activityCount: number;\n }>(WORKSPACE_ACTIVITY_SLICE_QUERY, { filter }, requestContext);\n\n return {\n activities: response.getWorkspaceActivitySlice.map(toActivity),\n total: response.activityCount,\n };\n }\n\n /**\n * @deprecated The workspace activity owner has no read-by-id operation. Use\n * {@link getActivities} with `resourceId`/`action` filters instead.\n */\n public async getActivity(_activityId: string): Promise<Activity> {\n throw new ActivityOperationUnsupportedError('getActivity', 'use getActivities with a workspace filter');\n }\n\n /**\n * @deprecated The workspace activity owner has no statistics operation. Use\n * {@link getActivities} (its `total` is the owner's `activityCount`) per filter instead.\n */\n public async getStats(_options: Omit<GetActivitiesOptions, 'limit' | 'offset'>): Promise<ActivityStats> {\n throw new ActivityOperationUnsupportedError('getStats', 'use getActivities and its total per filter');\n }\n\n /**\n * @deprecated Retention is enforced by the activity owner's retention policy and legal holds;\n * there is no client-driven cleanup operation.\n */\n public async cleanup(_olderThanDays: number, _workspaceId?: string): Promise<number> {\n throw new ActivityOperationUnsupportedError('cleanup', 'retention is enforced by the activity owner');\n }\n\n /**\n * @deprecated The workspace activity owner exports through `exportActivityLogsSiem`\n * (CEF/LEEF/JSON lines); there is no CSV export operation.\n */\n public async exportToCSV(_options: GetActivitiesOptions): Promise<string> {\n throw new ActivityOperationUnsupportedError('exportToCSV', 'use the owner exportActivityLogsSiem query');\n }\n\n /**\n * Infer activity type from action string\n */\n private inferActivityType(action: string): ActivityType {\n const actionLower = action.toLowerCase();\n\n if (actionLower.includes('create') || actionLower.includes('add')) {\n return ActivityType.CREATE;\n }\n if (actionLower.includes('update') || actionLower.includes('edit') || actionLower.includes('modify')) {\n return ActivityType.UPDATE;\n }\n if (actionLower.includes('delete') || actionLower.includes('remove')) {\n return ActivityType.DELETE;\n }\n if (actionLower.includes('read') || actionLower.includes('view') || actionLower.includes('get')) {\n return ActivityType.READ;\n }\n if (actionLower.includes('login') || actionLower.includes('signin')) {\n return ActivityType.LOGIN;\n }\n if (actionLower.includes('logout') || actionLower.includes('signout')) {\n return ActivityType.LOGOUT;\n }\n if (actionLower.includes('export')) {\n return ActivityType.EXPORT;\n }\n if (actionLower.includes('import')) {\n return ActivityType.IMPORT;\n }\n if (actionLower.includes('share')) {\n return ActivityType.SHARE;\n }\n if (actionLower.includes('download')) {\n return ActivityType.DOWNLOAD;\n }\n if (actionLower.includes('upload')) {\n return ActivityType.UPLOAD;\n }\n if (actionLower.includes('execute') || actionLower.includes('run')) {\n return ActivityType.EXECUTE;\n }\n if (actionLower.includes('approve')) {\n return ActivityType.APPROVE;\n }\n if (actionLower.includes('reject')) {\n return ActivityType.REJECT;\n }\n\n return ActivityType.CUSTOM;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA0BA,IAAY,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,KAAK,YAAY,SAAS,KAAK,GAC/D;EAEF,IAAI,YAAY,SAAS,SAAS,GAChC;EAEF,IAAI,YAAY,SAAS,QAAQ,GAC/B;EAGF;CACF;AACF"}
|
package/dist/ai-credits/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as AI_CREDIT_MAX_TOKENS_PER_REPORT, c as defaultAiCreditHashPrefix, i as isAiCreditInputError, l as encodeAiCreditHashComponent, n as AiCreditMeter, o as aiCreditIdempotencyHash, r as AiCreditInputError, s as aiCreditQuotaName, u as validateAiTokenUsage } from "../ai-credits-
|
|
1
|
+
import { a as AI_CREDIT_MAX_TOKENS_PER_REPORT, c as defaultAiCreditHashPrefix, i as isAiCreditInputError, l as encodeAiCreditHashComponent, n as AiCreditMeter, o as aiCreditIdempotencyHash, r as AiCreditInputError, s as aiCreditQuotaName, u as validateAiTokenUsage } from "../ai-credits-xxfwGpHS.js";
|
|
2
2
|
|
|
3
3
|
export { AI_CREDIT_MAX_TOKENS_PER_REPORT, AiCreditInputError, AiCreditMeter, aiCreditIdempotencyHash, aiCreditQuotaName, defaultAiCreditHashPrefix, encodeAiCreditHashComponent, isAiCreditInputError, validateAiTokenUsage };
|
|
4
4
|
//# sourceMappingURL=index.js.map
|
|
@@ -507,7 +507,7 @@ var AiCreditMeter = class {
|
|
|
507
507
|
const client = (async () => {
|
|
508
508
|
if (option && typeof option === "function") return option(url);
|
|
509
509
|
if (option) return option;
|
|
510
|
-
const gateway = await import("./client-
|
|
510
|
+
const gateway = await import("./client-sAJTrb4i.js").then((n) => n.n);
|
|
511
511
|
const identity = this.resolveServiceName();
|
|
512
512
|
return new gateway.GatewayClient({
|
|
513
513
|
layer: "wspace",
|
|
@@ -543,4 +543,4 @@ var ai_credits_exports = /* @__PURE__ */ __exportAll({
|
|
|
543
543
|
});
|
|
544
544
|
|
|
545
545
|
export { AI_CREDIT_MAX_TOKENS_PER_REPORT as a, defaultAiCreditHashPrefix as c, isAiCreditInputError as i, encodeAiCreditHashComponent as l, AiCreditMeter as n, aiCreditIdempotencyHash as o, AiCreditInputError as r, aiCreditQuotaName as s, ai_credits_exports as t, validateAiTokenUsage as u };
|
|
546
|
-
//# sourceMappingURL=ai-credits-
|
|
546
|
+
//# sourceMappingURL=ai-credits-xxfwGpHS.js.map
|