@intelmesh/sdk 0.1.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/scripts/compute-disttag.sh +47 -0
- package/.github/workflows/release.yml +206 -0
- package/.husky/commit-msg +1 -0
- package/.husky/pre-commit +2 -0
- package/.prettierrc +8 -0
- package/CLAUDE.md +37 -0
- package/LICENSE +21 -0
- package/commitlint.config.cjs +3 -0
- package/dist/index.d.ts +1293 -0
- package/dist/index.js +1651 -0
- package/docs/superpowers/plans/2026-04-10-release-pipeline.md +798 -0
- package/docs/superpowers/specs/2026-04-10-release-pipeline-design.md +309 -0
- package/eslint.config.mjs +38 -0
- package/package.json +72 -0
- package/src/builders/event.ts +72 -0
- package/src/builders/rule.ts +143 -0
- package/src/client/errors.ts +171 -0
- package/src/client/http.ts +209 -0
- package/src/client/intelmesh.ts +57 -0
- package/src/client/pagination.ts +50 -0
- package/src/generated/types.ts +11 -0
- package/src/index.ts +106 -0
- package/src/provision/index.ts +6 -0
- package/src/provision/provisioner.ts +326 -0
- package/src/provision/rule-builder.ts +193 -0
- package/src/resources/apikeys.ts +63 -0
- package/src/resources/audit.ts +29 -0
- package/src/resources/evaluations.ts +38 -0
- package/src/resources/events.ts +61 -0
- package/src/resources/lists.ts +91 -0
- package/src/resources/phases.ts +71 -0
- package/src/resources/rules.ts +98 -0
- package/src/resources/scopes.ts +71 -0
- package/src/resources/scores.ts +63 -0
- package/src/testkit/assertion.ts +76 -0
- package/src/testkit/harness.ts +252 -0
- package/src/testkit/index.ts +7 -0
- package/src/types.ts +330 -0
- package/tests/client/errors.test.ts +159 -0
- package/tests/provision/provisioner.test.ts +311 -0
- package/tests/scripts/compute-disttag.test.ts +178 -0
- package/tests/testkit/harness.test.ts +291 -0
- package/tsconfig.eslint.json +8 -0
- package/tsconfig.json +29 -0
- package/vitest.config.ts +14 -0
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
// ---------------------------------------------------------------------------
|
|
2
|
+
// Lists resource — CRUD + items
|
|
3
|
+
// ---------------------------------------------------------------------------
|
|
4
|
+
|
|
5
|
+
import type { HttpClient } from '../client/http.js';
|
|
6
|
+
import type {
|
|
7
|
+
AddItemsRequest,
|
|
8
|
+
BulkImportRequest,
|
|
9
|
+
CreateListRequest,
|
|
10
|
+
List,
|
|
11
|
+
PaginatedResponse,
|
|
12
|
+
PaginationParams,
|
|
13
|
+
UpdateListRequest,
|
|
14
|
+
} from '../types.js';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Resource for named list management (blocklists, allowlists, etc.).
|
|
18
|
+
*/
|
|
19
|
+
export class Lists {
|
|
20
|
+
private readonly http: HttpClient;
|
|
21
|
+
|
|
22
|
+
constructor(http: HttpClient) {
|
|
23
|
+
this.http = http;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Lists all named lists with cursor-based pagination.
|
|
28
|
+
* @param params - Optional pagination parameters.
|
|
29
|
+
* @returns A paginated list of named lists.
|
|
30
|
+
*/
|
|
31
|
+
async list(params: PaginationParams = {}): Promise<PaginatedResponse<List>> {
|
|
32
|
+
return this.http.get<PaginatedResponse<List>>('/api/v1/lists', {
|
|
33
|
+
cursor: params.cursor,
|
|
34
|
+
limit: params.limit,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Retrieves a single list by ID.
|
|
40
|
+
* @param id - The list ID.
|
|
41
|
+
* @returns The list.
|
|
42
|
+
*/
|
|
43
|
+
async get(id: string): Promise<List> {
|
|
44
|
+
return this.http.get<List>(`/api/v1/lists/${id}`);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Creates a new named list.
|
|
49
|
+
* @param request - The list creation payload.
|
|
50
|
+
* @returns The created list.
|
|
51
|
+
*/
|
|
52
|
+
async create(request: CreateListRequest): Promise<List> {
|
|
53
|
+
return this.http.post<List>('/api/v1/lists', request);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Updates an existing list by ID.
|
|
58
|
+
* @param id - The list ID.
|
|
59
|
+
* @param request - The update payload.
|
|
60
|
+
* @returns The updated list.
|
|
61
|
+
*/
|
|
62
|
+
async update(id: string, request: UpdateListRequest): Promise<List> {
|
|
63
|
+
return this.http.put<List>(`/api/v1/lists/${id}`, request);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Deletes a list by ID.
|
|
68
|
+
* @param id - The list ID.
|
|
69
|
+
*/
|
|
70
|
+
async delete(id: string): Promise<void> {
|
|
71
|
+
await this.http.delete<unknown>(`/api/v1/lists/${id}`);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Adds items to a list.
|
|
76
|
+
* @param listId - The list ID.
|
|
77
|
+
* @param request - The items to add.
|
|
78
|
+
*/
|
|
79
|
+
async addItems(listId: string, request: AddItemsRequest): Promise<void> {
|
|
80
|
+
await this.http.post<unknown>(`/api/v1/lists/${listId}/items`, request);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Bulk-imports items into a list, replacing existing items.
|
|
85
|
+
* @param listId - The list ID.
|
|
86
|
+
* @param request - The items to import.
|
|
87
|
+
*/
|
|
88
|
+
async bulkImport(listId: string, request: BulkImportRequest): Promise<void> {
|
|
89
|
+
await this.http.post<unknown>(`/api/v1/lists/${listId}/import`, request);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// ---------------------------------------------------------------------------
|
|
2
|
+
// Phases resource — CRUD
|
|
3
|
+
// ---------------------------------------------------------------------------
|
|
4
|
+
|
|
5
|
+
import type { HttpClient } from '../client/http.js';
|
|
6
|
+
import type {
|
|
7
|
+
CreatePhaseRequest,
|
|
8
|
+
PaginatedResponse,
|
|
9
|
+
PaginationParams,
|
|
10
|
+
Phase,
|
|
11
|
+
UpdatePhaseRequest,
|
|
12
|
+
} from '../types.js';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Resource for pipeline phase management.
|
|
16
|
+
*/
|
|
17
|
+
export class Phases {
|
|
18
|
+
private readonly http: HttpClient;
|
|
19
|
+
|
|
20
|
+
constructor(http: HttpClient) {
|
|
21
|
+
this.http = http;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Lists all phases with cursor-based pagination.
|
|
26
|
+
* @param params - Optional pagination parameters.
|
|
27
|
+
* @returns A paginated list of phases.
|
|
28
|
+
*/
|
|
29
|
+
async list(params: PaginationParams = {}): Promise<PaginatedResponse<Phase>> {
|
|
30
|
+
return this.http.get<PaginatedResponse<Phase>>('/api/v1/phases', {
|
|
31
|
+
cursor: params.cursor,
|
|
32
|
+
limit: params.limit,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Retrieves a single phase by ID.
|
|
38
|
+
* @param id - The phase ID.
|
|
39
|
+
* @returns The phase.
|
|
40
|
+
*/
|
|
41
|
+
async get(id: string): Promise<Phase> {
|
|
42
|
+
return this.http.get<Phase>(`/api/v1/phases/${id}`);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Creates a new phase.
|
|
47
|
+
* @param request - The phase creation payload.
|
|
48
|
+
* @returns The created phase.
|
|
49
|
+
*/
|
|
50
|
+
async create(request: CreatePhaseRequest): Promise<Phase> {
|
|
51
|
+
return this.http.post<Phase>('/api/v1/phases', request);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Updates an existing phase by ID.
|
|
56
|
+
* @param id - The phase ID.
|
|
57
|
+
* @param request - The update payload.
|
|
58
|
+
* @returns The updated phase.
|
|
59
|
+
*/
|
|
60
|
+
async update(id: string, request: UpdatePhaseRequest): Promise<Phase> {
|
|
61
|
+
return this.http.put<Phase>(`/api/v1/phases/${id}`, request);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Deletes a phase by ID.
|
|
66
|
+
* @param id - The phase ID.
|
|
67
|
+
*/
|
|
68
|
+
async delete(id: string): Promise<void> {
|
|
69
|
+
await this.http.delete<unknown>(`/api/v1/phases/${id}`);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
// ---------------------------------------------------------------------------
|
|
2
|
+
// Rules resource — CRUD + versions
|
|
3
|
+
// ---------------------------------------------------------------------------
|
|
4
|
+
|
|
5
|
+
import type { HttpClient } from '../client/http.js';
|
|
6
|
+
import type {
|
|
7
|
+
CreateRuleRequest,
|
|
8
|
+
PaginatedResponse,
|
|
9
|
+
PaginationParams,
|
|
10
|
+
Rule,
|
|
11
|
+
RuleVersion,
|
|
12
|
+
UpdateRuleRequest,
|
|
13
|
+
} from '../types.js';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Resource for rule management operations.
|
|
17
|
+
*/
|
|
18
|
+
export class Rules {
|
|
19
|
+
private readonly http: HttpClient;
|
|
20
|
+
|
|
21
|
+
constructor(http: HttpClient) {
|
|
22
|
+
this.http = http;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Lists all rules with cursor-based pagination.
|
|
27
|
+
* @param params - Optional pagination parameters.
|
|
28
|
+
* @returns A paginated list of rules.
|
|
29
|
+
*/
|
|
30
|
+
async list(params: PaginationParams = {}): Promise<PaginatedResponse<Rule>> {
|
|
31
|
+
return this.http.get<PaginatedResponse<Rule>>('/api/v1/rules', {
|
|
32
|
+
cursor: params.cursor,
|
|
33
|
+
limit: params.limit,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Retrieves a single rule by ID.
|
|
39
|
+
* @param id - The rule ID.
|
|
40
|
+
* @returns The rule.
|
|
41
|
+
*/
|
|
42
|
+
async get(id: string): Promise<Rule> {
|
|
43
|
+
return this.http.get<Rule>(`/api/v1/rules/${id}`);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Creates a new rule.
|
|
48
|
+
* @param request - The rule creation payload.
|
|
49
|
+
* @returns The created rule.
|
|
50
|
+
*/
|
|
51
|
+
async create(request: CreateRuleRequest): Promise<Rule> {
|
|
52
|
+
return this.http.post<Rule>('/api/v1/rules', request);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Updates an existing rule by ID.
|
|
57
|
+
* @param id - The rule ID.
|
|
58
|
+
* @param request - The update payload.
|
|
59
|
+
* @returns The updated rule.
|
|
60
|
+
*/
|
|
61
|
+
async update(id: string, request: UpdateRuleRequest): Promise<Rule> {
|
|
62
|
+
return this.http.put<Rule>(`/api/v1/rules/${id}`, request);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Deletes a rule by ID.
|
|
67
|
+
* @param id - The rule ID.
|
|
68
|
+
*/
|
|
69
|
+
async delete(id: string): Promise<void> {
|
|
70
|
+
await this.http.delete<unknown>(`/api/v1/rules/${id}`);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Lists all versions of a rule.
|
|
75
|
+
* @param ruleId - The rule ID.
|
|
76
|
+
* @param params - Optional pagination parameters.
|
|
77
|
+
* @returns A paginated list of rule versions.
|
|
78
|
+
*/
|
|
79
|
+
async listVersions(
|
|
80
|
+
ruleId: string,
|
|
81
|
+
params: PaginationParams = {},
|
|
82
|
+
): Promise<PaginatedResponse<RuleVersion>> {
|
|
83
|
+
return this.http.get<PaginatedResponse<RuleVersion>>(
|
|
84
|
+
`/api/v1/rules/${ruleId}/versions`,
|
|
85
|
+
{ cursor: params.cursor, limit: params.limit },
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Retrieves a specific version of a rule.
|
|
91
|
+
* @param ruleId - The rule ID.
|
|
92
|
+
* @param versionId - The version ID.
|
|
93
|
+
* @returns The rule version.
|
|
94
|
+
*/
|
|
95
|
+
async getVersion(ruleId: string, versionId: string): Promise<RuleVersion> {
|
|
96
|
+
return this.http.get<RuleVersion>(`/api/v1/rules/${ruleId}/versions/${versionId}`);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// ---------------------------------------------------------------------------
|
|
2
|
+
// Scopes resource — CRUD
|
|
3
|
+
// ---------------------------------------------------------------------------
|
|
4
|
+
|
|
5
|
+
import type { HttpClient } from '../client/http.js';
|
|
6
|
+
import type {
|
|
7
|
+
CreateScopeRequest,
|
|
8
|
+
PaginatedResponse,
|
|
9
|
+
PaginationParams,
|
|
10
|
+
Scope,
|
|
11
|
+
UpdateScopeRequest,
|
|
12
|
+
} from '../types.js';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Resource for scope management.
|
|
16
|
+
*/
|
|
17
|
+
export class Scopes {
|
|
18
|
+
private readonly http: HttpClient;
|
|
19
|
+
|
|
20
|
+
constructor(http: HttpClient) {
|
|
21
|
+
this.http = http;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Lists all scopes with cursor-based pagination.
|
|
26
|
+
* @param params - Optional pagination parameters.
|
|
27
|
+
* @returns A paginated list of scopes.
|
|
28
|
+
*/
|
|
29
|
+
async list(params: PaginationParams = {}): Promise<PaginatedResponse<Scope>> {
|
|
30
|
+
return this.http.get<PaginatedResponse<Scope>>('/api/v1/scopes', {
|
|
31
|
+
cursor: params.cursor,
|
|
32
|
+
limit: params.limit,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Retrieves a single scope by ID.
|
|
38
|
+
* @param id - The scope ID.
|
|
39
|
+
* @returns The scope.
|
|
40
|
+
*/
|
|
41
|
+
async get(id: string): Promise<Scope> {
|
|
42
|
+
return this.http.get<Scope>(`/api/v1/scopes/${id}`);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Creates a new scope.
|
|
47
|
+
* @param request - The scope creation payload.
|
|
48
|
+
* @returns The created scope.
|
|
49
|
+
*/
|
|
50
|
+
async create(request: CreateScopeRequest): Promise<Scope> {
|
|
51
|
+
return this.http.post<Scope>('/api/v1/scopes', request);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Updates an existing scope by ID.
|
|
56
|
+
* @param id - The scope ID.
|
|
57
|
+
* @param request - The update payload.
|
|
58
|
+
* @returns The updated scope.
|
|
59
|
+
*/
|
|
60
|
+
async update(id: string, request: UpdateScopeRequest): Promise<Scope> {
|
|
61
|
+
return this.http.put<Scope>(`/api/v1/scopes/${id}`, request);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Deletes a scope by ID.
|
|
66
|
+
* @param id - The scope ID.
|
|
67
|
+
*/
|
|
68
|
+
async delete(id: string): Promise<void> {
|
|
69
|
+
await this.http.delete<unknown>(`/api/v1/scopes/${id}`);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// ---------------------------------------------------------------------------
|
|
2
|
+
// Scores resource — get, list, set, reset
|
|
3
|
+
// ---------------------------------------------------------------------------
|
|
4
|
+
|
|
5
|
+
import type { HttpClient } from '../client/http.js';
|
|
6
|
+
import type { PaginatedResponse, PaginationParams, Score, SetScoreRequest } from '../types.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Resource for score management.
|
|
10
|
+
*/
|
|
11
|
+
export class Scores {
|
|
12
|
+
private readonly http: HttpClient;
|
|
13
|
+
|
|
14
|
+
constructor(http: HttpClient) {
|
|
15
|
+
this.http = http;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Retrieves a score for a specific scope name and value.
|
|
20
|
+
* @param scopeName - The scope name (e.g. "customer_id").
|
|
21
|
+
* @param scopeValue - The scope value (e.g. "12345678900").
|
|
22
|
+
* @returns The score entry.
|
|
23
|
+
*/
|
|
24
|
+
async get(scopeName: string, scopeValue: string): Promise<Score> {
|
|
25
|
+
return this.http.get<Score>(`/api/v1/scores/${scopeName}/${scopeValue}`);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Lists scores for a scope name with cursor-based pagination.
|
|
30
|
+
* @param scopeName - The scope name.
|
|
31
|
+
* @param params - Optional pagination parameters.
|
|
32
|
+
* @returns A paginated list of scores.
|
|
33
|
+
*/
|
|
34
|
+
async list(
|
|
35
|
+
scopeName: string,
|
|
36
|
+
params: PaginationParams = {},
|
|
37
|
+
): Promise<PaginatedResponse<Score>> {
|
|
38
|
+
return this.http.get<PaginatedResponse<Score>>(`/api/v1/scores/${scopeName}`, {
|
|
39
|
+
cursor: params.cursor,
|
|
40
|
+
limit: params.limit,
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Sets a score for a specific scope name and value.
|
|
46
|
+
* @param scopeName - The scope name.
|
|
47
|
+
* @param scopeValue - The scope value.
|
|
48
|
+
* @param request - The score value to set.
|
|
49
|
+
* @returns The updated score.
|
|
50
|
+
*/
|
|
51
|
+
async set(scopeName: string, scopeValue: string, request: SetScoreRequest): Promise<Score> {
|
|
52
|
+
return this.http.put<Score>(`/api/v1/scores/${scopeName}/${scopeValue}`, request);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Resets a score to zero for a specific scope name and value.
|
|
57
|
+
* @param scopeName - The scope name.
|
|
58
|
+
* @param scopeValue - The scope value.
|
|
59
|
+
*/
|
|
60
|
+
async reset(scopeName: string, scopeValue: string): Promise<void> {
|
|
61
|
+
await this.http.delete<unknown>(`/api/v1/scores/${scopeName}/${scopeValue}`);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
// ---------------------------------------------------------------------------
|
|
2
|
+
// EventAssertion — chainable assertions on IngestResult
|
|
3
|
+
// Mirrors the Go SDK's testkit.EventAssertion.
|
|
4
|
+
// ---------------------------------------------------------------------------
|
|
5
|
+
|
|
6
|
+
import type { IngestResult } from '../types.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Chains assertions on the result of an event send.
|
|
10
|
+
* Throws on assertion failure (suitable for test frameworks).
|
|
11
|
+
*/
|
|
12
|
+
export class EventAssertion {
|
|
13
|
+
private readonly result: IngestResult;
|
|
14
|
+
|
|
15
|
+
constructor(result: IngestResult) {
|
|
16
|
+
this.result = result;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Asserts the result has a specific decision action and severity.
|
|
21
|
+
* @param action - The expected action string (e.g. "block").
|
|
22
|
+
* @param severity - The expected severity level.
|
|
23
|
+
* @returns This assertion for chaining.
|
|
24
|
+
* @throws {Error} If the decision does not match.
|
|
25
|
+
*/
|
|
26
|
+
expectDecision(action: string, severity: string): this {
|
|
27
|
+
const decision = this.result.decision;
|
|
28
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- defensive runtime guard: API may return unexpected shapes despite type definition
|
|
29
|
+
if (!decision) {
|
|
30
|
+
throw new Error(`testkit: expected decision ${action}/${severity}, got no decision`);
|
|
31
|
+
}
|
|
32
|
+
if (decision.action !== action) {
|
|
33
|
+
throw new Error(`testkit: decision action: got "${decision.action}", want "${action}"`);
|
|
34
|
+
}
|
|
35
|
+
if (decision.severity !== severity) {
|
|
36
|
+
throw new Error(`testkit: decision severity: got "${decision.severity}", want "${severity}"`);
|
|
37
|
+
}
|
|
38
|
+
return this;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Asserts the result has no decision (action is empty or undefined).
|
|
43
|
+
* @returns This assertion for chaining.
|
|
44
|
+
* @throws {Error} If a decision is present.
|
|
45
|
+
*/
|
|
46
|
+
expectNoDecision(): this {
|
|
47
|
+
const decision = this.result.decision;
|
|
48
|
+
if (decision.action !== '') {
|
|
49
|
+
throw new Error(`testkit: expected no decision, got ${decision.action}/${decision.severity}`);
|
|
50
|
+
}
|
|
51
|
+
return this;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Asserts the transient score equals the expected value.
|
|
56
|
+
* @param score - The expected score value.
|
|
57
|
+
* @returns This assertion for chaining.
|
|
58
|
+
* @throws {Error} If the score does not match.
|
|
59
|
+
*/
|
|
60
|
+
expectScore(score: number): this {
|
|
61
|
+
if (this.result.transient_score !== score) {
|
|
62
|
+
throw new Error(
|
|
63
|
+
`testkit: score: got ${String(this.result.transient_score)}, want ${String(score)}`,
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
return this;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Returns the underlying IngestResult for custom assertions.
|
|
71
|
+
* @returns The raw IngestResult.
|
|
72
|
+
*/
|
|
73
|
+
raw(): IngestResult {
|
|
74
|
+
return this.result;
|
|
75
|
+
}
|
|
76
|
+
}
|