@certik/skynet 0.22.1 → 0.22.3
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/CHANGELOG.md +8 -0
- package/build.ts +23 -0
- package/dist/abi.d.ts +1 -2
- package/dist/abi.js +569 -563
- package/dist/address.d.ts +0 -1
- package/dist/address.js +22 -21
- package/dist/api.d.ts +0 -1
- package/dist/api.js +235 -120
- package/dist/app.d.ts +1 -2
- package/dist/app.js +2030 -276
- package/dist/availability.d.ts +0 -1
- package/dist/availability.js +126 -56
- package/dist/cli.d.ts +0 -1
- package/dist/cli.js +28 -24
- package/dist/const.d.ts +0 -1
- package/dist/const.js +153 -132
- package/dist/databricks.d.ts +0 -1
- package/dist/databricks.js +198 -58
- package/dist/date.d.ts +0 -1
- package/dist/date.js +48 -21
- package/dist/deploy.d.ts +0 -1
- package/dist/deploy.js +427 -292
- package/dist/dynamodb.d.ts +3 -4
- package/dist/dynamodb.js +432 -281
- package/dist/env.d.ts +2 -3
- package/dist/env.js +16 -9
- package/dist/graphql.d.ts +0 -1
- package/dist/graphql.js +26 -23
- package/dist/indexer.d.ts +0 -1
- package/dist/indexer.js +1050 -441
- package/dist/log.d.ts +0 -1
- package/dist/log.js +53 -52
- package/dist/object-hash.d.ts +0 -1
- package/dist/object-hash.js +49 -59
- package/dist/opsgenie.d.ts +97 -19
- package/dist/opsgenie.js +35 -30
- package/dist/por.d.ts +0 -1
- package/dist/por.js +113 -123
- package/dist/s3.d.ts +7 -8
- package/dist/s3.js +103 -91
- package/dist/search.d.ts +0 -1
- package/dist/search.js +100 -25
- package/dist/selector.d.ts +0 -1
- package/dist/selector.js +34 -38
- package/dist/slack.d.ts +0 -1
- package/dist/slack.js +27 -21
- package/dist/util.d.ts +0 -1
- package/dist/util.js +21 -20
- package/examples/api.ts +1 -1
- package/examples/indexer.ts +1 -1
- package/examples/mode-indexer.ts +1 -1
- package/package.json +4 -3
- package/{graphql.ts → src/graphql.ts} +1 -1
- package/src/opsgenie.ts +176 -0
- package/tsconfig.build.json +2 -5
- package/tsconfig.json +11 -20
- package/dist/abi.d.ts.map +0 -1
- package/dist/address.d.ts.map +0 -1
- package/dist/api.d.ts.map +0 -1
- package/dist/app.d.ts.map +0 -1
- package/dist/availability.d.ts.map +0 -1
- package/dist/cli.d.ts.map +0 -1
- package/dist/const.d.ts.map +0 -1
- package/dist/databricks.d.ts.map +0 -1
- package/dist/date.d.ts.map +0 -1
- package/dist/deploy.d.ts.map +0 -1
- package/dist/dynamodb.d.ts.map +0 -1
- package/dist/env.d.ts.map +0 -1
- package/dist/graphql.d.ts.map +0 -1
- package/dist/indexer.d.ts.map +0 -1
- package/dist/log.d.ts.map +0 -1
- package/dist/object-hash.d.ts.map +0 -1
- package/dist/opsgenie.d.ts.map +0 -1
- package/dist/por.d.ts.map +0 -1
- package/dist/s3.d.ts.map +0 -1
- package/dist/search.d.ts.map +0 -1
- package/dist/selector.d.ts.map +0 -1
- package/dist/slack.d.ts.map +0 -1
- package/dist/util.d.ts.map +0 -1
- package/opsgenie.ts +0 -69
- /package/{abi.ts → src/abi.ts} +0 -0
- /package/{address.ts → src/address.ts} +0 -0
- /package/{api.ts → src/api.ts} +0 -0
- /package/{app.ts → src/app.ts} +0 -0
- /package/{availability.ts → src/availability.ts} +0 -0
- /package/{cli.ts → src/cli.ts} +0 -0
- /package/{const.ts → src/const.ts} +0 -0
- /package/{databricks.ts → src/databricks.ts} +0 -0
- /package/{date.ts → src/date.ts} +0 -0
- /package/{deploy.ts → src/deploy.ts} +0 -0
- /package/{dynamodb.ts → src/dynamodb.ts} +0 -0
- /package/{env.ts → src/env.ts} +0 -0
- /package/{indexer.ts → src/indexer.ts} +0 -0
- /package/{log.ts → src/log.ts} +0 -0
- /package/{object-hash.ts → src/object-hash.ts} +0 -0
- /package/{por.ts → src/por.ts} +0 -0
- /package/{s3.ts → src/s3.ts} +0 -0
- /package/{search.ts → src/search.ts} +0 -0
- /package/{selector.ts → src/selector.ts} +0 -0
- /package/{slack.ts → src/slack.ts} +0 -0
- /package/{util.ts → src/util.ts} +0 -0
package/dist/log.d.ts
CHANGED
package/dist/log.js
CHANGED
|
@@ -1,62 +1,63 @@
|
|
|
1
|
+
// src/log.ts
|
|
1
2
|
function isObject(a) {
|
|
2
|
-
|
|
3
|
+
return !!a && a.constructor === Object;
|
|
3
4
|
}
|
|
4
5
|
function print(o) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
return `${o}`;
|
|
6
|
+
if (Array.isArray(o)) {
|
|
7
|
+
return `[${o.map(print).join(", ")}]`;
|
|
8
|
+
}
|
|
9
|
+
if (isObject(o)) {
|
|
10
|
+
return `{${Object.keys(o).map((k) => `${k}: ${o[k]}`).join(", ")}}`;
|
|
11
|
+
}
|
|
12
|
+
return `${o}`;
|
|
14
13
|
}
|
|
15
14
|
function getLine(params) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
line += `${print(params[i])} `.replace(/\n/gm, "\t");
|
|
22
|
-
}
|
|
23
|
-
return line.trim();
|
|
15
|
+
let line = "";
|
|
16
|
+
for (let i = 0, l = params.length;i < l; i++) {
|
|
17
|
+
line += `${print(params[i])} `.replace(/\n/gm, "\t");
|
|
18
|
+
}
|
|
19
|
+
return line.trim();
|
|
24
20
|
}
|
|
25
21
|
function timestamp() {
|
|
26
|
-
|
|
22
|
+
return new Date().toISOString();
|
|
27
23
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
24
|
+
var inline = {
|
|
25
|
+
debug: function(...args) {
|
|
26
|
+
if (true) {
|
|
27
|
+
console.log(`${timestamp()} ${getLine(args)}`);
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
log: function(...args) {
|
|
31
|
+
if (true) {
|
|
32
|
+
console.log(`${timestamp()} ${getLine(args)}`);
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
error: function(...args) {
|
|
36
|
+
if (true) {
|
|
37
|
+
console.error(`${timestamp()} ${getLine(args)}`);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
var logger = {
|
|
42
|
+
debug: function(...args) {
|
|
43
|
+
if (true) {
|
|
44
|
+
console.log(`[${timestamp()}]`, ...args);
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
log: function(...args) {
|
|
48
|
+
if (true) {
|
|
49
|
+
console.log(`[${timestamp()}]`, ...args);
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
error: function(...args) {
|
|
53
|
+
if (true) {
|
|
54
|
+
console.error(`[${timestamp()}]`, ...args);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
44
57
|
};
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
},
|
|
51
|
-
log: function (...args) {
|
|
52
|
-
if (process.env.NODE_ENV !== "test") {
|
|
53
|
-
console.log(`[${timestamp()}]`, ...args);
|
|
54
|
-
}
|
|
55
|
-
},
|
|
56
|
-
error: function (...args) {
|
|
57
|
-
if (process.env.NODE_ENV !== "test") {
|
|
58
|
-
console.error(`[${timestamp()}]`, ...args);
|
|
59
|
-
}
|
|
60
|
-
},
|
|
58
|
+
export {
|
|
59
|
+
print,
|
|
60
|
+
logger,
|
|
61
|
+
inline,
|
|
62
|
+
getLine
|
|
61
63
|
};
|
|
62
|
-
export { print, getLine, inline, logger };
|
package/dist/object-hash.d.ts
CHANGED
package/dist/object-hash.js
CHANGED
|
@@ -1,71 +1,61 @@
|
|
|
1
|
+
// src/object-hash.ts
|
|
1
2
|
import xh from "@node-rs/xxhash";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
function getHash(obj) {
|
|
4
|
+
const xxh3 = xh.xxh3.Xxh3.withSeed();
|
|
5
|
+
hash(obj, xxh3);
|
|
6
|
+
return xxh3.digest().toString(16);
|
|
6
7
|
}
|
|
7
8
|
function hash(obj, xxh3) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
setHash(obj, xxh3);
|
|
34
|
-
}
|
|
35
|
-
else if (obj instanceof Map) {
|
|
36
|
-
mapHash(obj, xxh3);
|
|
37
|
-
}
|
|
38
|
-
else if (typeof obj === "object") {
|
|
39
|
-
objectHash(obj, xxh3);
|
|
40
|
-
}
|
|
41
|
-
else {
|
|
42
|
-
throw new Error(`Unsupported type: ${obj}`);
|
|
43
|
-
}
|
|
9
|
+
if (obj === null) {
|
|
10
|
+
xxh3.update("null");
|
|
11
|
+
} else if (obj === undefined) {
|
|
12
|
+
xxh3.update("undefined");
|
|
13
|
+
} else if (typeof obj === "string") {
|
|
14
|
+
xxh3.update(obj);
|
|
15
|
+
} else if (typeof obj === "number") {
|
|
16
|
+
xxh3.update(obj.toString());
|
|
17
|
+
} else if (typeof obj === "boolean") {
|
|
18
|
+
xxh3.update(obj.toString());
|
|
19
|
+
} else if (typeof obj === "bigint") {
|
|
20
|
+
xxh3.update(obj.toString());
|
|
21
|
+
} else if (obj instanceof Date) {
|
|
22
|
+
xxh3.update(obj.toISOString());
|
|
23
|
+
} else if (Array.isArray(obj)) {
|
|
24
|
+
arrayHash(obj, xxh3);
|
|
25
|
+
} else if (obj instanceof Set) {
|
|
26
|
+
setHash(obj, xxh3);
|
|
27
|
+
} else if (obj instanceof Map) {
|
|
28
|
+
mapHash(obj, xxh3);
|
|
29
|
+
} else if (typeof obj === "object") {
|
|
30
|
+
objectHash(obj, xxh3);
|
|
31
|
+
} else {
|
|
32
|
+
throw new Error(`Unsupported type: ${obj}`);
|
|
33
|
+
}
|
|
44
34
|
}
|
|
45
35
|
function arrayHash(array, xxh3) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
36
|
+
xxh3.update("[");
|
|
37
|
+
for (const obj of array) {
|
|
38
|
+
hash(obj, xxh3);
|
|
39
|
+
}
|
|
40
|
+
xxh3.update("]");
|
|
51
41
|
}
|
|
52
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
53
42
|
function setHash(_set, _xxh3) {
|
|
54
|
-
|
|
43
|
+
throw new Error("Set hashing not implemented");
|
|
55
44
|
}
|
|
56
45
|
function mapHash(map, xxh3) {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
46
|
+
const array = Array.from(map.entries()).sort(([aKey], [bKey]) => aKey.localeCompare(bKey));
|
|
47
|
+
for (const [key, value] of array) {
|
|
48
|
+
hash(key, xxh3);
|
|
49
|
+
hash(value, xxh3);
|
|
50
|
+
}
|
|
63
51
|
}
|
|
64
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
65
52
|
function objectHash(obj, xxh3) {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
53
|
+
const array = Object.entries(obj).sort(([aKey], [bKey]) => aKey.localeCompare(bKey));
|
|
54
|
+
for (const [key, value] of array) {
|
|
55
|
+
hash(key, xxh3);
|
|
56
|
+
hash(value, xxh3);
|
|
57
|
+
}
|
|
71
58
|
}
|
|
59
|
+
export {
|
|
60
|
+
getHash
|
|
61
|
+
};
|
package/dist/opsgenie.d.ts
CHANGED
|
@@ -1,21 +1,99 @@
|
|
|
1
|
-
type
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
export
|
|
16
|
-
|
|
1
|
+
export type OpsgeniePriority = "P1" | "P2" | "P3" | "P4" | "P5";
|
|
2
|
+
export interface TeamRefById {
|
|
3
|
+
id: string;
|
|
4
|
+
type: "team";
|
|
5
|
+
}
|
|
6
|
+
export interface TeamRefByName {
|
|
7
|
+
name: string;
|
|
8
|
+
type: "team";
|
|
9
|
+
}
|
|
10
|
+
export type TeamRef = TeamRefById | TeamRefByName;
|
|
11
|
+
export interface UserRefById {
|
|
12
|
+
id: string;
|
|
13
|
+
type: "user";
|
|
14
|
+
}
|
|
15
|
+
export interface UserRefByUsername {
|
|
16
|
+
username: string;
|
|
17
|
+
type: "user";
|
|
18
|
+
}
|
|
19
|
+
export type UserRef = UserRefById | UserRefByUsername;
|
|
20
|
+
export interface EscalationRefById {
|
|
21
|
+
id: string;
|
|
22
|
+
type: "escalation";
|
|
23
|
+
}
|
|
24
|
+
export interface EscalationRefByName {
|
|
25
|
+
name: string;
|
|
26
|
+
type: "escalation";
|
|
27
|
+
}
|
|
28
|
+
export type EscalationRef = EscalationRefById | EscalationRefByName;
|
|
29
|
+
export interface ScheduleRefById {
|
|
30
|
+
id: string;
|
|
31
|
+
type: "schedule";
|
|
32
|
+
}
|
|
33
|
+
export interface ScheduleRefByName {
|
|
34
|
+
name: string;
|
|
35
|
+
type: "schedule";
|
|
36
|
+
}
|
|
37
|
+
export type ScheduleRef = ScheduleRefById | ScheduleRefByName;
|
|
38
|
+
export type ResponderRef = TeamRef | UserRef | EscalationRef | ScheduleRef;
|
|
39
|
+
export interface VisibleToTeamById {
|
|
40
|
+
id: string;
|
|
41
|
+
type: "team";
|
|
42
|
+
}
|
|
43
|
+
export interface VisibleToTeamByName {
|
|
44
|
+
name: string;
|
|
45
|
+
type: "team";
|
|
46
|
+
}
|
|
47
|
+
export type VisibleToTeam = VisibleToTeamById | VisibleToTeamByName;
|
|
48
|
+
export interface VisibleToUserById {
|
|
49
|
+
id: string;
|
|
50
|
+
type: "user";
|
|
51
|
+
}
|
|
52
|
+
export interface VisibleToUserByUsername {
|
|
53
|
+
username: string;
|
|
54
|
+
type: "user";
|
|
55
|
+
}
|
|
56
|
+
export type VisibleToUser = VisibleToUserById | VisibleToUserByUsername;
|
|
57
|
+
export type VisibleToRef = VisibleToTeam | VisibleToUser;
|
|
58
|
+
export interface CreateAlertRequest {
|
|
17
59
|
message: string;
|
|
60
|
+
alias?: string;
|
|
18
61
|
description?: string;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
62
|
+
responders?: ResponderRef[];
|
|
63
|
+
visibleTo?: VisibleToRef[];
|
|
64
|
+
actions?: string[];
|
|
65
|
+
tags?: string[];
|
|
66
|
+
details?: Record<string, string>;
|
|
67
|
+
entity?: string;
|
|
68
|
+
source?: string;
|
|
69
|
+
priority?: OpsgeniePriority;
|
|
70
|
+
user?: string;
|
|
71
|
+
note?: string;
|
|
72
|
+
}
|
|
73
|
+
export interface OpsgenieAcceptedResponse {
|
|
74
|
+
result: string;
|
|
75
|
+
took: number;
|
|
76
|
+
requestId: string;
|
|
77
|
+
}
|
|
78
|
+
export interface OpsgenieRequestStatusData {
|
|
79
|
+
success: boolean;
|
|
80
|
+
action: string;
|
|
81
|
+
processedAt: string;
|
|
82
|
+
integrationId: string;
|
|
83
|
+
isSuccess: boolean;
|
|
84
|
+
status: string;
|
|
85
|
+
alertId: string;
|
|
86
|
+
alias: string;
|
|
87
|
+
}
|
|
88
|
+
export interface OpsgenieRequestStatusResponse extends OpsgenieAcceptedResponse {
|
|
89
|
+
data: OpsgenieRequestStatusData;
|
|
90
|
+
}
|
|
91
|
+
export type OpsgenieResponse = OpsgenieAcceptedResponse | OpsgenieRequestStatusResponse;
|
|
92
|
+
export interface OpsgenieErrorResponse {
|
|
93
|
+
message?: string;
|
|
94
|
+
took?: number;
|
|
95
|
+
requestId?: string;
|
|
96
|
+
errors?: unknown;
|
|
97
|
+
status?: number | string;
|
|
98
|
+
}
|
|
99
|
+
export declare function postGenieMessage(body: CreateAlertRequest, apiKey?: string, verbose?: boolean): Promise<OpsgenieResponse>;
|
package/dist/opsgenie.js
CHANGED
|
@@ -1,38 +1,43 @@
|
|
|
1
|
+
// src/opsgenie.ts
|
|
1
2
|
import md5 from "md5";
|
|
2
3
|
function getGenieKey(key) {
|
|
3
|
-
|
|
4
|
+
return key || process.env["SKYNET_OPSGENIE_API_KEY"];
|
|
4
5
|
}
|
|
5
6
|
function getGenieEndPoint() {
|
|
6
|
-
|
|
7
|
+
return process.env["SKYNET_OPSGENIE_END_POINT"] || "https://api.opsgenie.com/v2/alerts";
|
|
7
8
|
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
body.alias = md5(body.message);
|
|
15
|
-
}
|
|
16
|
-
if (verbose) {
|
|
17
|
-
console.log(`Making API call to Opsgenie`, JSON.stringify(body, null, 2));
|
|
18
|
-
}
|
|
19
|
-
// Makes the call using fetch and ENV variables
|
|
20
|
-
const response = await fetch(genieEndPoint, {
|
|
21
|
-
method: "POST",
|
|
22
|
-
headers: {
|
|
23
|
-
"Content-Type": "application/json",
|
|
24
|
-
Authorization: `GenieKey ${genieKey}`,
|
|
25
|
-
},
|
|
26
|
-
body: JSON.stringify(body),
|
|
27
|
-
});
|
|
28
|
-
const result = await response.json();
|
|
29
|
-
if (verbose) {
|
|
30
|
-
console.log(`Result of API call to Opsgenie... ${result}`);
|
|
31
|
-
}
|
|
32
|
-
return result;
|
|
9
|
+
async function postGenieMessage(body, apiKey, verbose) {
|
|
10
|
+
try {
|
|
11
|
+
const genieKey = apiKey || getGenieKey();
|
|
12
|
+
const genieEndPoint = getGenieEndPoint();
|
|
13
|
+
if (!body.alias) {
|
|
14
|
+
body.alias = md5(body.message);
|
|
33
15
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
throw error;
|
|
16
|
+
if (verbose) {
|
|
17
|
+
console.log(`Making API call to Opsgenie`, JSON.stringify(body, null, 2));
|
|
37
18
|
}
|
|
19
|
+
const response = await fetch(genieEndPoint, {
|
|
20
|
+
method: "POST",
|
|
21
|
+
headers: {
|
|
22
|
+
"Content-Type": "application/json",
|
|
23
|
+
Authorization: `GenieKey ${genieKey}`
|
|
24
|
+
},
|
|
25
|
+
body: JSON.stringify(body)
|
|
26
|
+
});
|
|
27
|
+
const json = await response.json();
|
|
28
|
+
if (verbose) {
|
|
29
|
+
console.log("Result of API call to Opsgenie...", json);
|
|
30
|
+
}
|
|
31
|
+
if ("result" in json) {
|
|
32
|
+
return json;
|
|
33
|
+
}
|
|
34
|
+
console.error("Error response from Opsgenie API", json);
|
|
35
|
+
throw new Error(json.message || "Unknown error from Opsgenie API");
|
|
36
|
+
} catch (error) {
|
|
37
|
+
console.error("Failed to make opsgenie API call", error);
|
|
38
|
+
throw error;
|
|
39
|
+
}
|
|
38
40
|
}
|
|
41
|
+
export {
|
|
42
|
+
postGenieMessage
|
|
43
|
+
};
|
package/dist/por.d.ts
CHANGED