@binalyze/air-sdk 4.46.0 → 5.4.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/air/AIR.js.map +1 -1
- package/dist/domains/acquisitions.js +18 -14
- package/dist/domains/acquisitions.js.map +1 -1
- package/dist/domains/api-tokens.js +48 -31
- package/dist/domains/api-tokens.js.map +1 -1
- package/dist/domains/assets.js +133 -69
- package/dist/domains/assets.js.map +1 -1
- package/dist/domains/baseline.js +46 -26
- package/dist/domains/baseline.js.map +1 -1
- package/dist/domains/cases.js +94 -70
- package/dist/domains/cases.js.map +1 -1
- package/dist/domains/interact.js +46 -31
- package/dist/domains/interact.js.map +1 -1
- package/dist/domains/organization.js +151 -60
- package/dist/domains/organization.js.map +1 -1
- package/dist/domains/repositories.js +14 -9
- package/dist/domains/repositories.js.map +1 -1
- package/dist/domains/tasks.js +28 -28
- package/dist/domains/tasks.js.map +1 -1
- package/dist/domains/triage.js +87 -24
- package/dist/domains/triage.js.map +1 -1
- package/dist/domains/users.js +16 -11
- package/dist/domains/users.js.map +1 -1
- package/dist/generated/bindings.d.ts +1 -0
- package/dist/generated/bindings.js +1 -0
- package/dist/generated/bindings.js.map +1 -1
- package/dist/sdk/typescript-axios/client/client.gen.js +56 -23
- package/dist/sdk/typescript-axios/client/client.gen.js.map +1 -1
- package/dist/sdk/typescript-axios/client/index.js +1 -0
- package/dist/sdk/typescript-axios/client/index.js.map +1 -1
- package/dist/sdk/typescript-axios/client/types.gen.d.ts +14 -12
- package/dist/sdk/typescript-axios/client/types.gen.js +1 -0
- package/dist/sdk/typescript-axios/client/types.gen.js.map +1 -1
- package/dist/sdk/typescript-axios/client/utils.gen.d.ts +1 -7
- package/dist/sdk/typescript-axios/client/utils.gen.js +32 -86
- package/dist/sdk/typescript-axios/client/utils.gen.js.map +1 -1
- package/dist/sdk/typescript-axios/client.gen.d.ts +1 -1
- package/dist/sdk/typescript-axios/client.gen.js +1 -0
- package/dist/sdk/typescript-axios/client.gen.js.map +1 -1
- package/dist/sdk/typescript-axios/core/auth.gen.js +1 -0
- package/dist/sdk/typescript-axios/core/auth.gen.js.map +1 -1
- package/dist/sdk/typescript-axios/core/bodySerializer.gen.js +4 -0
- package/dist/sdk/typescript-axios/core/bodySerializer.gen.js.map +1 -1
- package/dist/sdk/typescript-axios/core/params.gen.js +3 -3
- package/dist/sdk/typescript-axios/core/params.gen.js.map +1 -1
- package/dist/sdk/typescript-axios/core/pathSerializer.gen.d.ts +2 -2
- package/dist/sdk/typescript-axios/core/pathSerializer.gen.js +1 -0
- package/dist/sdk/typescript-axios/core/pathSerializer.gen.js.map +1 -1
- package/dist/sdk/typescript-axios/core/serverSentEvents.gen.d.ts +71 -0
- package/dist/sdk/typescript-axios/core/serverSentEvents.gen.js +141 -0
- package/dist/sdk/typescript-axios/core/serverSentEvents.gen.js.map +1 -0
- package/dist/sdk/typescript-axios/core/types.gen.d.ts +12 -12
- package/dist/sdk/typescript-axios/core/types.gen.js +1 -0
- package/dist/sdk/typescript-axios/core/types.gen.js.map +1 -1
- package/dist/sdk/typescript-axios/core/utils.gen.d.ts +19 -0
- package/dist/sdk/typescript-axios/core/utils.gen.js +95 -0
- package/dist/sdk/typescript-axios/core/utils.gen.js.map +1 -0
- package/dist/sdk/typescript-axios/index.js +2 -1
- package/dist/sdk/typescript-axios/index.js.map +1 -1
- package/dist/sdk/typescript-axios/sdk.gen.d.ts +175 -26
- package/dist/sdk/typescript-axios/sdk.gen.js +1090 -1003
- package/dist/sdk/typescript-axios/sdk.gen.js.map +1 -1
- package/dist/sdk/typescript-axios/types.gen.d.ts +4260 -975
- package/dist/sdk/typescript-axios/types.gen.js +1 -0
- package/dist/sdk/typescript-axios/types.gen.js.map +1 -1
- package/dist/types/acquisitions.d.ts +10 -5
- package/dist/types/api-tokens.d.ts +41 -14
- package/dist/types/assets.d.ts +158 -7
- package/dist/types/baseline.d.ts +34 -3
- package/dist/types/cases.d.ts +140 -13
- package/dist/types/interact.d.ts +60 -7
- package/dist/types/organization.d.ts +72 -11
- package/dist/types/repositories.d.ts +22 -2
- package/dist/types/tasks.d.ts +132 -5
- package/dist/types/triage.d.ts +45 -9
- package/dist/types/users.d.ts +22 -2
- package/dist/utils/utils.d.ts +28 -0
- package/dist/utils/utils.js +88 -10
- package/dist/utils/utils.js.map +1 -1
- package/package.json +2 -2
package/dist/types/tasks.d.ts
CHANGED
|
@@ -1,7 +1,134 @@
|
|
|
1
|
+
import type { TaskAssignmentGetResponses, TasksGetByIdResponses } from '../generated/bindings';
|
|
2
|
+
export interface TaskEntity {
|
|
3
|
+
_id: string;
|
|
4
|
+
source?: string;
|
|
5
|
+
endpointFilter?: {
|
|
6
|
+
organizationIds?: number[];
|
|
7
|
+
includedEndpointIds?: string[];
|
|
8
|
+
excludedEndpointIds?: string[];
|
|
9
|
+
[key: string]: unknown;
|
|
10
|
+
};
|
|
11
|
+
totalAssignedEndpoints?: number;
|
|
12
|
+
totalCompletedEndpoints?: number;
|
|
13
|
+
totalFailedEndpoints?: number;
|
|
14
|
+
totalCancelledEndpoints?: number;
|
|
15
|
+
name?: string;
|
|
16
|
+
type?: string;
|
|
17
|
+
organizationId?: number;
|
|
18
|
+
status?: string;
|
|
19
|
+
createdBy?: string;
|
|
20
|
+
baseTaskId?: string | null;
|
|
21
|
+
schedulerConfig?: {
|
|
22
|
+
when?: string;
|
|
23
|
+
[key: string]: unknown;
|
|
24
|
+
};
|
|
25
|
+
metadata?: Record<string, unknown>;
|
|
26
|
+
totalMatched?: number | null;
|
|
27
|
+
createdAt?: string;
|
|
28
|
+
updatedAt?: string;
|
|
29
|
+
}
|
|
30
|
+
export type Task = TasksGetByIdResponses[200] & TaskEntity;
|
|
31
|
+
export interface SdkTask {
|
|
32
|
+
_id: string;
|
|
33
|
+
status?: string;
|
|
34
|
+
type?: string;
|
|
35
|
+
name?: string;
|
|
36
|
+
source?: string;
|
|
37
|
+
createdAt?: string;
|
|
38
|
+
updatedAt?: string;
|
|
39
|
+
}
|
|
40
|
+
export interface TasksPage extends Array<TaskEntity> {
|
|
41
|
+
_pagination?: {
|
|
42
|
+
totalEntityCount?: number;
|
|
43
|
+
pageSize?: number;
|
|
44
|
+
currentPage?: number;
|
|
45
|
+
totalPageCount?: number;
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
export interface TaskAssignmentEntity {
|
|
49
|
+
_id: string;
|
|
50
|
+
taskId?: string;
|
|
51
|
+
name?: string;
|
|
52
|
+
type?: string;
|
|
53
|
+
endpointId?: string;
|
|
54
|
+
endpointName?: string;
|
|
55
|
+
organizationId?: number;
|
|
56
|
+
status?: string;
|
|
57
|
+
subStatus?: string | null;
|
|
58
|
+
recurrence?: unknown | null;
|
|
59
|
+
progress?: number;
|
|
60
|
+
durations?: Record<string, number>;
|
|
61
|
+
duration?: number;
|
|
62
|
+
caseIds?: string[];
|
|
63
|
+
metadata?: TaskAssignmentMetadata;
|
|
64
|
+
createdAt?: string;
|
|
65
|
+
createdBy?: string;
|
|
66
|
+
updatedAt?: string;
|
|
67
|
+
displayType?: string;
|
|
68
|
+
response?: TaskAssignmentResponse;
|
|
69
|
+
reportUrl?: string;
|
|
70
|
+
isReportReady?: boolean;
|
|
71
|
+
}
|
|
72
|
+
export type TaskAssignment = TaskAssignmentGetResponses[200] & TaskAssignmentEntity;
|
|
73
|
+
export interface TaskAssignmentsPage extends Array<TaskAssignmentEntity> {
|
|
74
|
+
_pagination?: {
|
|
75
|
+
totalEntityCount?: number;
|
|
76
|
+
pageSize?: number;
|
|
77
|
+
currentPage?: number;
|
|
78
|
+
totalPageCount?: number;
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
export interface TaskAssignmentMetadata {
|
|
82
|
+
purged?: boolean;
|
|
83
|
+
hasCaseDb?: boolean;
|
|
84
|
+
hasCasePpc?: boolean;
|
|
85
|
+
hasDroneData?: boolean;
|
|
86
|
+
taskCreatedByFullName?: string;
|
|
87
|
+
[key: string]: unknown;
|
|
88
|
+
}
|
|
89
|
+
export interface TaskAssignmentResponse {
|
|
90
|
+
errorMessage?: string | null;
|
|
91
|
+
caseDirectory?: string | null;
|
|
92
|
+
matchCount?: number | null;
|
|
93
|
+
result?: unknown;
|
|
94
|
+
[key: string]: unknown;
|
|
95
|
+
}
|
|
96
|
+
export interface GetTaskOptions {
|
|
97
|
+
id: string;
|
|
98
|
+
}
|
|
99
|
+
export interface TaskFilters {
|
|
100
|
+
organizationIds?: number[];
|
|
101
|
+
searchTerm?: string;
|
|
102
|
+
name?: string;
|
|
103
|
+
type?: string[];
|
|
104
|
+
source?: string[];
|
|
105
|
+
status?: string[];
|
|
106
|
+
executionType?: string[];
|
|
107
|
+
}
|
|
108
|
+
export interface GetTasksOptions {
|
|
109
|
+
pageNumber?: number;
|
|
110
|
+
pageSize?: number;
|
|
111
|
+
sortBy?: string;
|
|
112
|
+
sortType?: 'ASC' | 'DESC';
|
|
113
|
+
filter?: TaskFilters;
|
|
114
|
+
}
|
|
115
|
+
export interface GetTaskAssignmentsOptions {
|
|
116
|
+
id: string;
|
|
117
|
+
pageNumber?: number;
|
|
118
|
+
pageSize?: number;
|
|
119
|
+
sortBy?: string;
|
|
120
|
+
sortType?: 'ASC' | 'DESC';
|
|
121
|
+
filter?: TaskAssignmentFilters;
|
|
122
|
+
includeFilter?: boolean;
|
|
123
|
+
}
|
|
124
|
+
export interface TaskAssignmentFilters {
|
|
125
|
+
status?: string[];
|
|
126
|
+
searchTerm?: string;
|
|
127
|
+
hasDroneData?: boolean;
|
|
128
|
+
endpointIds?: string[];
|
|
129
|
+
}
|
|
1
130
|
export interface TasksAPI {
|
|
2
|
-
get: (
|
|
3
|
-
getMany: (
|
|
4
|
-
|
|
5
|
-
getAssignment: (assignmentId: string) => Promise<any>;
|
|
6
|
-
getAssignments: (id: string, pageNumber?: number, pageSize?: number) => Promise<any>;
|
|
131
|
+
get: (options: GetTaskOptions) => Promise<Task>;
|
|
132
|
+
getMany: (options?: GetTasksOptions) => Promise<TasksPage>;
|
|
133
|
+
getAssignments: (options: GetTaskAssignmentsOptions) => Promise<TaskAssignmentsPage>;
|
|
7
134
|
}
|
package/dist/types/triage.d.ts
CHANGED
|
@@ -1,11 +1,47 @@
|
|
|
1
|
+
import type { AssignTriageTaskResponses, CreateTriageRuleData, GetManyTriageRulesData, GetManyTriageRulesResponses, GetTriageRuleResponses, ValidateTriageRuleRequestDto, AssignTriageTaskRequestDto, UpdateTriageRuleData } from '../generated/bindings';
|
|
2
|
+
export type CreateCompatBody = CreateTriageRuleData['body'] & {
|
|
3
|
+
name?: string;
|
|
4
|
+
};
|
|
5
|
+
export type UpdateCompatBody = UpdateTriageRuleData['body'] & {
|
|
6
|
+
name?: string;
|
|
7
|
+
engine?: 'osquery' | 'yara' | 'sigma';
|
|
8
|
+
};
|
|
9
|
+
export type OperationResponse = {
|
|
10
|
+
success: boolean;
|
|
11
|
+
};
|
|
12
|
+
export type RemoveResult = {
|
|
13
|
+
id: string;
|
|
14
|
+
deleted: boolean;
|
|
15
|
+
status: number;
|
|
16
|
+
existed: boolean | null;
|
|
17
|
+
};
|
|
18
|
+
export type ValidationResponse = {
|
|
19
|
+
success: true;
|
|
20
|
+
} | {
|
|
21
|
+
success: false;
|
|
22
|
+
status: number;
|
|
23
|
+
message: string;
|
|
24
|
+
};
|
|
1
25
|
export interface TriageAPI {
|
|
2
|
-
getMany: (
|
|
3
|
-
get: (
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
26
|
+
getMany: (options?: GetManyTriageRulesData['query']) => Promise<GetManyTriageRulesResponses[200]>;
|
|
27
|
+
get: (options: {
|
|
28
|
+
id: string;
|
|
29
|
+
}) => Promise<GetTriageRuleResponses[200]>;
|
|
30
|
+
create: (options: {
|
|
31
|
+
body: CreateTriageRuleData['body'] | CreateCompatBody;
|
|
32
|
+
}) => Promise<OperationResponse>;
|
|
33
|
+
update: (options: {
|
|
34
|
+
id: string;
|
|
35
|
+
body: UpdateTriageRuleData['body'] | UpdateCompatBody;
|
|
36
|
+
}) => Promise<OperationResponse>;
|
|
37
|
+
remove: (options: {
|
|
38
|
+
id: string;
|
|
39
|
+
ensureExists?: boolean;
|
|
40
|
+
}) => Promise<RemoveResult>;
|
|
41
|
+
validate: (options: {
|
|
42
|
+
body: ValidateTriageRuleRequestDto;
|
|
43
|
+
}) => Promise<ValidationResponse>;
|
|
44
|
+
assignTask: (options: {
|
|
45
|
+
body: AssignTriageTaskRequestDto;
|
|
46
|
+
}) => Promise<AssignTriageTaskResponses[200]>;
|
|
11
47
|
}
|
package/dist/types/users.d.ts
CHANGED
|
@@ -1,4 +1,24 @@
|
|
|
1
|
+
import type { FilterUsersRequestDto, UserDto, UserManagementUsersGetResponses } from '../generated/bindings';
|
|
2
|
+
export type User = UserManagementUsersGetResponses[200];
|
|
3
|
+
export type UsersPage = (UserDto[]) & {
|
|
4
|
+
_pagination?: {
|
|
5
|
+
totalEntityCount?: number;
|
|
6
|
+
pageSize?: number;
|
|
7
|
+
currentPage?: number;
|
|
8
|
+
totalPageCount?: number;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
export interface GetUserOptions {
|
|
12
|
+
id: string;
|
|
13
|
+
}
|
|
14
|
+
export interface GetUsersOptions {
|
|
15
|
+
pageNumber?: number;
|
|
16
|
+
pageSize?: number;
|
|
17
|
+
sortBy?: string;
|
|
18
|
+
sortType?: 'ASC' | 'DESC';
|
|
19
|
+
filter?: Partial<FilterUsersRequestDto>;
|
|
20
|
+
}
|
|
1
21
|
export interface UsersAPI {
|
|
2
|
-
get: (
|
|
3
|
-
getMany: (
|
|
22
|
+
get: (options: GetUserOptions) => Promise<User>;
|
|
23
|
+
getMany: (options?: GetUsersOptions) => Promise<UsersPage>;
|
|
4
24
|
}
|
package/dist/utils/utils.d.ts
CHANGED
|
@@ -2,3 +2,31 @@ export declare function serializeQueryDeep(query: Record<string, unknown>): stri
|
|
|
2
2
|
export declare function tryParseJson(input: unknown): unknown;
|
|
3
3
|
export declare function buildNormalizedErrorResponse(parsed: unknown, status?: number): unknown;
|
|
4
4
|
export declare function normalizeApiResponse(parsed: unknown): unknown;
|
|
5
|
+
export interface PaginationMetadata {
|
|
6
|
+
totalEntityCount?: number;
|
|
7
|
+
pageSize?: number;
|
|
8
|
+
currentPage?: number;
|
|
9
|
+
totalPageCount?: number;
|
|
10
|
+
}
|
|
11
|
+
export type PageWithPagination<T> = Array<T> & {
|
|
12
|
+
_pagination?: PaginationMetadata;
|
|
13
|
+
};
|
|
14
|
+
type ResponseEnvelope<T> = {
|
|
15
|
+
data?: T;
|
|
16
|
+
error?: unknown;
|
|
17
|
+
};
|
|
18
|
+
export declare function unwrapResponse<T>(response: ResponseEnvelope<T> | T): T;
|
|
19
|
+
export declare function extractPagination(source: unknown): PaginationMetadata | undefined;
|
|
20
|
+
export declare function normalizePage<TEntity, TPage extends PageWithPagination<TEntity>>(response: unknown, mapEntity?: (entity: unknown) => TEntity): TPage;
|
|
21
|
+
type HasOrganizationIds = {
|
|
22
|
+
organizationIds?: number[];
|
|
23
|
+
};
|
|
24
|
+
type EnsureOrganizationIds<T> = T extends undefined ? {
|
|
25
|
+
organizationIds: number[];
|
|
26
|
+
} : T extends HasOrganizationIds ? Omit<T, 'organizationIds'> & {
|
|
27
|
+
organizationIds: number[];
|
|
28
|
+
} : {
|
|
29
|
+
organizationIds: number[];
|
|
30
|
+
};
|
|
31
|
+
export declare function ensureOrganizationIds<T extends HasOrganizationIds | undefined>(filter: T, defaultId?: number): EnsureOrganizationIds<T>;
|
|
32
|
+
export {};
|
package/dist/utils/utils.js
CHANGED
|
@@ -4,6 +4,10 @@ exports.serializeQueryDeep = serializeQueryDeep;
|
|
|
4
4
|
exports.tryParseJson = tryParseJson;
|
|
5
5
|
exports.buildNormalizedErrorResponse = buildNormalizedErrorResponse;
|
|
6
6
|
exports.normalizeApiResponse = normalizeApiResponse;
|
|
7
|
+
exports.unwrapResponse = unwrapResponse;
|
|
8
|
+
exports.extractPagination = extractPagination;
|
|
9
|
+
exports.normalizePage = normalizePage;
|
|
10
|
+
exports.ensureOrganizationIds = ensureOrganizationIds;
|
|
7
11
|
function serializeQueryDeep(query) {
|
|
8
12
|
const parts = [];
|
|
9
13
|
const enc = encodeURIComponent;
|
|
@@ -28,7 +32,7 @@ function serializeQueryDeep(query) {
|
|
|
28
32
|
}
|
|
29
33
|
append(prefix, value);
|
|
30
34
|
};
|
|
31
|
-
for (const [k, v] of Object.entries(query
|
|
35
|
+
for (const [k, v] of Object.entries(query ?? {})) {
|
|
32
36
|
if (v === undefined || v === null)
|
|
33
37
|
continue;
|
|
34
38
|
if (Array.isArray(v)) {
|
|
@@ -59,15 +63,14 @@ function tryParseJson(input) {
|
|
|
59
63
|
}
|
|
60
64
|
}
|
|
61
65
|
function buildNormalizedErrorResponse(parsed, status) {
|
|
62
|
-
var _a, _b;
|
|
63
66
|
if (parsed && typeof parsed === 'object') {
|
|
64
|
-
const serverStatus = Number(
|
|
67
|
+
const serverStatus = Number(parsed.statusCode ?? status ?? 0);
|
|
65
68
|
const serverErrors = Array.isArray(parsed.errors)
|
|
66
69
|
? parsed.errors
|
|
67
70
|
: (parsed && parsed.message)
|
|
68
71
|
? [parsed.message]
|
|
69
72
|
: [];
|
|
70
|
-
const messageList = serverErrors.map((e) =>
|
|
73
|
+
const messageList = serverErrors.map((e) => typeof e === 'string' ? e : e?.message ?? String(e ?? ''));
|
|
71
74
|
const message = messageList.filter(Boolean).join('; ') || `HTTP ${serverStatus}`;
|
|
72
75
|
return {
|
|
73
76
|
success: false,
|
|
@@ -78,15 +81,14 @@ function buildNormalizedErrorResponse(parsed, status) {
|
|
|
78
81
|
}
|
|
79
82
|
}
|
|
80
83
|
function normalizeApiResponse(parsed) {
|
|
81
|
-
var _a, _b, _c, _d, _e;
|
|
82
84
|
if (parsed && typeof parsed === 'object' && 'result' in parsed) {
|
|
83
85
|
const raw = parsed;
|
|
84
|
-
const result =
|
|
86
|
+
const result = raw.result ?? {};
|
|
85
87
|
const pagination = {
|
|
86
|
-
totalEntityCount: Number(
|
|
87
|
-
pageSize: Number(
|
|
88
|
-
currentPage: Number(
|
|
89
|
-
totalPageCount: Number(
|
|
88
|
+
totalEntityCount: Number(result.totalEntityCount ?? 0),
|
|
89
|
+
pageSize: Number(result.pageSize ?? 0),
|
|
90
|
+
currentPage: Number(result.currentPage ?? 0),
|
|
91
|
+
totalPageCount: Number(result.totalPageCount ?? 0),
|
|
90
92
|
};
|
|
91
93
|
if (result && typeof result === 'object' && Array.isArray(result.entities)) {
|
|
92
94
|
const entitiesWithPagination = result.entities.map((entity) => ({
|
|
@@ -95,6 +97,13 @@ function normalizeApiResponse(parsed) {
|
|
|
95
97
|
}));
|
|
96
98
|
return entitiesWithPagination;
|
|
97
99
|
}
|
|
100
|
+
// When the API returns an array directly in result, normalize to an array
|
|
101
|
+
// and attach pagination to each element instead of spreading the array into an object
|
|
102
|
+
if (Array.isArray(result)) {
|
|
103
|
+
return result.map((entity) => entity && typeof entity === 'object'
|
|
104
|
+
? { ...entity, _pagination: pagination }
|
|
105
|
+
: { value: entity, _pagination: pagination });
|
|
106
|
+
}
|
|
98
107
|
return {
|
|
99
108
|
...(typeof result === 'object' ? result : { value: result }),
|
|
100
109
|
_pagination: pagination,
|
|
@@ -102,4 +111,73 @@ function normalizeApiResponse(parsed) {
|
|
|
102
111
|
}
|
|
103
112
|
return parsed;
|
|
104
113
|
}
|
|
114
|
+
function unwrapResponse(response) {
|
|
115
|
+
if (response && typeof response === 'object') {
|
|
116
|
+
const record = response;
|
|
117
|
+
if (record.error !== undefined && record.error !== null) {
|
|
118
|
+
throw record.error;
|
|
119
|
+
}
|
|
120
|
+
if ('data' in record && record.data !== undefined) {
|
|
121
|
+
return record.data;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return response;
|
|
125
|
+
}
|
|
126
|
+
function extractPaginationCandidate(source) {
|
|
127
|
+
if (!source)
|
|
128
|
+
return undefined;
|
|
129
|
+
if (Array.isArray(source)) {
|
|
130
|
+
return source._pagination;
|
|
131
|
+
}
|
|
132
|
+
if (typeof source === 'object') {
|
|
133
|
+
const obj = source;
|
|
134
|
+
if (obj._pagination && typeof obj._pagination === 'object') {
|
|
135
|
+
return obj._pagination;
|
|
136
|
+
}
|
|
137
|
+
return obj;
|
|
138
|
+
}
|
|
139
|
+
return undefined;
|
|
140
|
+
}
|
|
141
|
+
function extractPagination(source) {
|
|
142
|
+
const candidate = extractPaginationCandidate(source);
|
|
143
|
+
if (!candidate || typeof candidate !== 'object')
|
|
144
|
+
return undefined;
|
|
145
|
+
const meta = candidate;
|
|
146
|
+
const { totalEntityCount, pageSize, currentPage, totalPageCount } = meta;
|
|
147
|
+
if (totalEntityCount === undefined &&
|
|
148
|
+
pageSize === undefined &&
|
|
149
|
+
currentPage === undefined &&
|
|
150
|
+
totalPageCount === undefined) {
|
|
151
|
+
return undefined;
|
|
152
|
+
}
|
|
153
|
+
return {
|
|
154
|
+
totalEntityCount: typeof totalEntityCount === 'number' ? totalEntityCount : undefined,
|
|
155
|
+
pageSize: typeof pageSize === 'number' ? pageSize : undefined,
|
|
156
|
+
currentPage: typeof currentPage === 'number' ? currentPage : undefined,
|
|
157
|
+
totalPageCount: typeof totalPageCount === 'number' ? totalPageCount : undefined,
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
function normalizePage(response, mapEntity) {
|
|
161
|
+
const dto = unwrapResponse(response);
|
|
162
|
+
const entitiesSource = Array.isArray(dto) ? dto : dto?.entities ?? [];
|
|
163
|
+
const entities = mapEntity
|
|
164
|
+
? entitiesSource.map((entity) => mapEntity(entity))
|
|
165
|
+
: entitiesSource;
|
|
166
|
+
const pagination = extractPagination(dto);
|
|
167
|
+
const page = [...entities];
|
|
168
|
+
if (pagination) {
|
|
169
|
+
page._pagination = pagination;
|
|
170
|
+
}
|
|
171
|
+
return page;
|
|
172
|
+
}
|
|
173
|
+
function ensureOrganizationIds(filter, defaultId = 0) {
|
|
174
|
+
const base = (filter ?? {});
|
|
175
|
+
const organizationIds = Array.isArray(base.organizationIds) && base.organizationIds.length > 0
|
|
176
|
+
? base.organizationIds
|
|
177
|
+
: [defaultId];
|
|
178
|
+
return {
|
|
179
|
+
...base,
|
|
180
|
+
organizationIds,
|
|
181
|
+
};
|
|
182
|
+
}
|
|
105
183
|
//# sourceMappingURL=utils.js.map
|
package/dist/utils/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils/utils.ts"],"names":[],"mappings":";;AAAA,gDAoCC;AAED,oCAUC;AAED,oEAqBC;AAED,
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils/utils.ts"],"names":[],"mappings":";;AAAA,gDAoCC;AAED,oCAUC;AAED,oEAqBC;AAED,oDAqCC;AAgBD,wCAWC;AAiBD,8CAmBC;AAED,sCAeC;AAUD,sDAaC;AArND,SAAgB,kBAAkB,CAAC,KAA8B;IAC/D,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,MAAM,GAAG,GAAG,kBAAkB,CAAC;IAE/B,MAAM,MAAM,GAAG,CAAC,GAAW,EAAE,KAAc,EAAE,EAAE;QAC7C,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI;YAAE,OAAO;QAClD,KAAK,CAAC,IAAI,CAAC,GAAG,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;IAC7C,CAAC,CAAC;IAEF,MAAM,KAAK,GAAG,CAAC,MAAc,EAAE,KAAc,EAAE,EAAE;QAC/C,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI;YAAE,OAAO;QAClD,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YACzB,KAAK,MAAM,IAAI,IAAI,KAAK;gBAAE,MAAM,CAAC,GAAG,MAAM,IAAI,EAAE,IAAI,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AC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAUD,SAAgB,qBAAqB,CACnC,MAAS,EACT,SAAS,GAAG,CAAC;IAEb,MAAM,IAAI,GAAG,CAAC,MAAM,IAAI,EAAE,CAAiD,CAAC;IAC5E,MAAM,eAAe,GACnB,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,eAAe,CAAC,IAAI,IAAI,CAAC,eAAe,CAAC,MAAM,GAAG,CAAC;QACpE,CAAC,CAAC,IAAI,CAAC,eAAe;QACtB,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;IAClB,OAAO;QACL,GAAG,IAAI;QACP,eAAe;KACY,CAAC;AAChC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@binalyze/air-sdk",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "5.4.0",
|
|
4
4
|
"private": false,
|
|
5
|
-
"description": "Binalyze AIR Typescript Axios SDK",
|
|
5
|
+
"description": "Binalyze AIR - Typescript Axios SDK",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"type": "commonjs",
|
|
8
8
|
"main": "dist/index.js",
|