@forgehive/hive-sdk 0.1.0 → 0.1.2
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/index.d.ts +2 -9
- package/dist/test/getLog.test.js +20 -5
- package/dist/test/sendLog.test.js +20 -4
- package/package.json +9 -2
- package/src/index.ts +3 -10
- package/src/test/getLog.test.ts +20 -5
- package/src/test/sendLog.test.ts +20 -4
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,8 @@
|
|
|
1
|
+
import type { ExecutionRecord } from '@forgehive/task';
|
|
1
2
|
export interface Metadata {
|
|
2
3
|
[key: string]: string;
|
|
3
4
|
}
|
|
4
|
-
export
|
|
5
|
-
input: InputType;
|
|
6
|
-
output?: OutputType;
|
|
7
|
-
error?: string;
|
|
8
|
-
boundaries?: B;
|
|
9
|
-
taskName?: string;
|
|
10
|
-
metadata?: Metadata;
|
|
11
|
-
type?: 'success' | 'error' | 'pending';
|
|
12
|
-
}
|
|
5
|
+
export type { ExecutionRecord } from '@forgehive/task';
|
|
13
6
|
export interface HiveLogClientConfig {
|
|
14
7
|
projectName: string;
|
|
15
8
|
apiKey?: string;
|
package/dist/test/getLog.test.js
CHANGED
|
@@ -33,8 +33,13 @@ describe('HiveLogClient getLog', () => {
|
|
|
33
33
|
output: { success: true, sessionId: 'abc123' },
|
|
34
34
|
error: undefined,
|
|
35
35
|
boundaries: {
|
|
36
|
-
database: [{
|
|
37
|
-
|
|
36
|
+
database: [{
|
|
37
|
+
input: ['SELECT * FROM users'],
|
|
38
|
+
output: [{ id: 123 }],
|
|
39
|
+
timing: { startTime: 1000, endTime: 1100, duration: 100 }
|
|
40
|
+
}]
|
|
41
|
+
},
|
|
42
|
+
type: 'success'
|
|
38
43
|
},
|
|
39
44
|
replayFrom: 'some-replay-id',
|
|
40
45
|
createdAt: '2023-12-01T10:00:00Z'
|
|
@@ -66,7 +71,9 @@ describe('HiveLogClient getLog', () => {
|
|
|
66
71
|
taskName: 'minimal-task',
|
|
67
72
|
projectName: 'test-project',
|
|
68
73
|
logItem: {
|
|
69
|
-
input: 'simple input'
|
|
74
|
+
input: 'simple input',
|
|
75
|
+
boundaries: {},
|
|
76
|
+
type: 'pending'
|
|
70
77
|
},
|
|
71
78
|
createdAt: '2023-12-01T10:00:00Z'
|
|
72
79
|
};
|
|
@@ -104,7 +111,11 @@ describe('HiveLogClient getLog', () => {
|
|
|
104
111
|
uuid: 'uuid-with-special-chars-!@#',
|
|
105
112
|
taskName: 'task-with-special-chars-!@#',
|
|
106
113
|
projectName: 'test-project',
|
|
107
|
-
logItem: {
|
|
114
|
+
logItem: {
|
|
115
|
+
input: 'test',
|
|
116
|
+
boundaries: {},
|
|
117
|
+
type: 'pending'
|
|
118
|
+
},
|
|
108
119
|
createdAt: '2023-12-01T10:00:00Z'
|
|
109
120
|
};
|
|
110
121
|
mockedAxios.get.mockResolvedValueOnce({ data: mockResponse });
|
|
@@ -124,7 +135,11 @@ describe('isApiError type guard', () => {
|
|
|
124
135
|
uuid: 'test-uuid',
|
|
125
136
|
taskName: 'test-task',
|
|
126
137
|
projectName: 'test-project',
|
|
127
|
-
logItem: {
|
|
138
|
+
logItem: {
|
|
139
|
+
input: 'test',
|
|
140
|
+
boundaries: {},
|
|
141
|
+
type: 'pending'
|
|
142
|
+
},
|
|
128
143
|
createdAt: '2023-12-01T10:00:00Z'
|
|
129
144
|
};
|
|
130
145
|
expect((0, index_1.isApiError)(logResponse)).toBe(false);
|
|
@@ -63,8 +63,16 @@ describe('HiveLogClient sendLog with ExecutionRecord', () => {
|
|
|
63
63
|
taskName: 'complex-task',
|
|
64
64
|
type: 'success',
|
|
65
65
|
boundaries: {
|
|
66
|
-
database: [{
|
|
67
|
-
|
|
66
|
+
database: [{
|
|
67
|
+
input: ['SELECT * FROM users'],
|
|
68
|
+
output: [{ id: 123 }],
|
|
69
|
+
timing: { startTime: 1000, endTime: 1100, duration: 100 }
|
|
70
|
+
}],
|
|
71
|
+
api: [{
|
|
72
|
+
input: [{ endpoint: '/auth' }],
|
|
73
|
+
output: { token: 'jwt123' },
|
|
74
|
+
timing: { startTime: 1200, endTime: 1250, duration: 50 }
|
|
75
|
+
}]
|
|
68
76
|
},
|
|
69
77
|
metadata: { environment: 'test' }
|
|
70
78
|
};
|
|
@@ -79,8 +87,16 @@ describe('HiveLogClient sendLog with ExecutionRecord', () => {
|
|
|
79
87
|
taskName: 'complex-task',
|
|
80
88
|
type: 'success',
|
|
81
89
|
boundaries: {
|
|
82
|
-
database: [{
|
|
83
|
-
|
|
90
|
+
database: [{
|
|
91
|
+
input: ['SELECT * FROM users'],
|
|
92
|
+
output: [{ id: 123 }],
|
|
93
|
+
timing: { startTime: 1000, endTime: 1100, duration: 100 }
|
|
94
|
+
}],
|
|
95
|
+
api: [{
|
|
96
|
+
input: [{ endpoint: '/auth' }],
|
|
97
|
+
output: { token: 'jwt123' },
|
|
98
|
+
timing: { startTime: 1200, endTime: 1250, duration: 50 }
|
|
99
|
+
}]
|
|
84
100
|
},
|
|
85
101
|
metadata: { environment: 'test' }
|
|
86
102
|
})
|
package/package.json
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forgehive/hive-sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
|
+
"publishConfig": {
|
|
8
|
+
"access": "public",
|
|
9
|
+
"dependencies": {
|
|
10
|
+
"@forgehive/task": "^0.2.5"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
7
13
|
"devDependencies": {
|
|
8
14
|
"@types/jest": "^29.5.14",
|
|
9
15
|
"@types/node": "^24.0.3",
|
|
@@ -15,7 +21,8 @@
|
|
|
15
21
|
"license": "ISC",
|
|
16
22
|
"dependencies": {
|
|
17
23
|
"axios": "^1.8.4",
|
|
18
|
-
"debug": "^4.4.1"
|
|
24
|
+
"debug": "^4.4.1",
|
|
25
|
+
"@forgehive/task": "0.2.5"
|
|
19
26
|
},
|
|
20
27
|
"scripts": {
|
|
21
28
|
"build": "tsc",
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import axios from 'axios'
|
|
2
2
|
import debug from 'debug'
|
|
3
|
+
import type { ExecutionRecord } from '@forgehive/task'
|
|
3
4
|
|
|
4
5
|
const log = debug('hive-sdk')
|
|
5
6
|
|
|
@@ -8,16 +9,8 @@ export interface Metadata {
|
|
|
8
9
|
[key: string]: string
|
|
9
10
|
}
|
|
10
11
|
|
|
11
|
-
//
|
|
12
|
-
export
|
|
13
|
-
input: InputType
|
|
14
|
-
output?: OutputType
|
|
15
|
-
error?: string
|
|
16
|
-
boundaries?: B
|
|
17
|
-
taskName?: string
|
|
18
|
-
metadata?: Metadata
|
|
19
|
-
type?: 'success' | 'error' | 'pending'
|
|
20
|
-
}
|
|
12
|
+
// Re-export ExecutionRecord type from task package for convenience
|
|
13
|
+
export type { ExecutionRecord } from '@forgehive/task'
|
|
21
14
|
|
|
22
15
|
// Configuration interface for HiveLogClient
|
|
23
16
|
export interface HiveLogClientConfig {
|
package/src/test/getLog.test.ts
CHANGED
|
@@ -34,8 +34,13 @@ describe('HiveLogClient getLog', () => {
|
|
|
34
34
|
output: { success: true, sessionId: 'abc123' },
|
|
35
35
|
error: undefined,
|
|
36
36
|
boundaries: {
|
|
37
|
-
database: [{
|
|
38
|
-
|
|
37
|
+
database: [{
|
|
38
|
+
input: ['SELECT * FROM users'],
|
|
39
|
+
output: [{ id: 123 }],
|
|
40
|
+
timing: { startTime: 1000, endTime: 1100, duration: 100 }
|
|
41
|
+
}]
|
|
42
|
+
},
|
|
43
|
+
type: 'success' as const
|
|
39
44
|
},
|
|
40
45
|
replayFrom: 'some-replay-id',
|
|
41
46
|
createdAt: '2023-12-01T10:00:00Z'
|
|
@@ -78,7 +83,9 @@ describe('HiveLogClient getLog', () => {
|
|
|
78
83
|
taskName: 'minimal-task',
|
|
79
84
|
projectName: 'test-project',
|
|
80
85
|
logItem: {
|
|
81
|
-
input: 'simple input'
|
|
86
|
+
input: 'simple input',
|
|
87
|
+
boundaries: {},
|
|
88
|
+
type: 'pending' as const
|
|
82
89
|
},
|
|
83
90
|
createdAt: '2023-12-01T10:00:00Z'
|
|
84
91
|
}
|
|
@@ -129,7 +136,11 @@ describe('HiveLogClient getLog', () => {
|
|
|
129
136
|
uuid: 'uuid-with-special-chars-!@#',
|
|
130
137
|
taskName: 'task-with-special-chars-!@#',
|
|
131
138
|
projectName: 'test-project',
|
|
132
|
-
logItem: {
|
|
139
|
+
logItem: {
|
|
140
|
+
input: 'test',
|
|
141
|
+
boundaries: {},
|
|
142
|
+
type: 'pending' as const
|
|
143
|
+
},
|
|
133
144
|
createdAt: '2023-12-01T10:00:00Z'
|
|
134
145
|
}
|
|
135
146
|
|
|
@@ -157,7 +168,11 @@ describe('isApiError type guard', () => {
|
|
|
157
168
|
uuid: 'test-uuid',
|
|
158
169
|
taskName: 'test-task',
|
|
159
170
|
projectName: 'test-project',
|
|
160
|
-
logItem: {
|
|
171
|
+
logItem: {
|
|
172
|
+
input: 'test',
|
|
173
|
+
boundaries: {},
|
|
174
|
+
type: 'pending' as const
|
|
175
|
+
},
|
|
161
176
|
createdAt: '2023-12-01T10:00:00Z'
|
|
162
177
|
}
|
|
163
178
|
expect(isApiError(logResponse)).toBe(false)
|
package/src/test/sendLog.test.ts
CHANGED
|
@@ -73,8 +73,16 @@ describe('HiveLogClient sendLog with ExecutionRecord', () => {
|
|
|
73
73
|
taskName: 'complex-task',
|
|
74
74
|
type: 'success' as const,
|
|
75
75
|
boundaries: {
|
|
76
|
-
database: [{
|
|
77
|
-
|
|
76
|
+
database: [{
|
|
77
|
+
input: ['SELECT * FROM users'],
|
|
78
|
+
output: [{ id: 123 }],
|
|
79
|
+
timing: { startTime: 1000, endTime: 1100, duration: 100 }
|
|
80
|
+
}],
|
|
81
|
+
api: [{
|
|
82
|
+
input: [{ endpoint: '/auth' }],
|
|
83
|
+
output: { token: 'jwt123' },
|
|
84
|
+
timing: { startTime: 1200, endTime: 1250, duration: 50 }
|
|
85
|
+
}]
|
|
78
86
|
},
|
|
79
87
|
metadata: { environment: 'test' }
|
|
80
88
|
}
|
|
@@ -93,8 +101,16 @@ describe('HiveLogClient sendLog with ExecutionRecord', () => {
|
|
|
93
101
|
taskName: 'complex-task',
|
|
94
102
|
type: 'success',
|
|
95
103
|
boundaries: {
|
|
96
|
-
database: [{
|
|
97
|
-
|
|
104
|
+
database: [{
|
|
105
|
+
input: ['SELECT * FROM users'],
|
|
106
|
+
output: [{ id: 123 }],
|
|
107
|
+
timing: { startTime: 1000, endTime: 1100, duration: 100 }
|
|
108
|
+
}],
|
|
109
|
+
api: [{
|
|
110
|
+
input: [{ endpoint: '/auth' }],
|
|
111
|
+
output: { token: 'jwt123' },
|
|
112
|
+
timing: { startTime: 1200, endTime: 1250, duration: 50 }
|
|
113
|
+
}]
|
|
98
114
|
},
|
|
99
115
|
metadata: { environment: 'test' }
|
|
100
116
|
})
|