@certik/skynet 0.22.1 → 0.22.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/.vscode/settings.json +5 -0
- package/CHANGELOG.md +4 -0
- package/build.ts +23 -0
- package/bun.lockb +0 -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 +1 -1
- package/dist/opsgenie.js +31 -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 +5 -4
- package/{graphql.ts → src/graphql.ts} +1 -1
- package/{opsgenie.ts → src/opsgenie.ts} +2 -1
- 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/{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/s3.js
CHANGED
|
@@ -1,110 +1,122 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
// src/s3.ts
|
|
2
|
+
import {
|
|
3
|
+
S3Client,
|
|
4
|
+
GetObjectCommand,
|
|
5
|
+
HeadObjectCommand,
|
|
6
|
+
PutObjectCommand,
|
|
7
|
+
DeleteObjectCommand,
|
|
8
|
+
ListObjectsV2Command,
|
|
9
|
+
NotFound,
|
|
10
|
+
NoSuchKey
|
|
11
|
+
} from "@aws-sdk/client-s3";
|
|
12
|
+
var _s3Client;
|
|
3
13
|
function getS3(forceNew = false) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
14
|
+
if (!_s3Client || forceNew) {
|
|
15
|
+
_s3Client = new S3Client;
|
|
16
|
+
}
|
|
17
|
+
return _s3Client;
|
|
8
18
|
}
|
|
9
19
|
async function readFile(bucketName, key, verbose = false) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
// do nothing
|
|
22
|
-
return null;
|
|
23
|
-
}
|
|
24
|
-
throw error;
|
|
20
|
+
const s3 = getS3();
|
|
21
|
+
const params = { Bucket: bucketName, Key: key };
|
|
22
|
+
try {
|
|
23
|
+
const result = await s3.send(new GetObjectCommand(params));
|
|
24
|
+
return result.Body?.transformToString();
|
|
25
|
+
} catch (error) {
|
|
26
|
+
if (error instanceof NoSuchKey) {
|
|
27
|
+
if (verbose) {
|
|
28
|
+
console.log("no such bucket or key", bucketName, key);
|
|
29
|
+
}
|
|
30
|
+
return null;
|
|
25
31
|
}
|
|
32
|
+
throw error;
|
|
33
|
+
}
|
|
26
34
|
}
|
|
27
35
|
async function hasFile(bucketName, key) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
return false;
|
|
36
|
-
}
|
|
37
|
-
throw headErr;
|
|
36
|
+
const s3 = getS3();
|
|
37
|
+
try {
|
|
38
|
+
await s3.send(new HeadObjectCommand({ Bucket: bucketName, Key: key }));
|
|
39
|
+
return true;
|
|
40
|
+
} catch (headErr) {
|
|
41
|
+
if (headErr instanceof NotFound) {
|
|
42
|
+
return false;
|
|
38
43
|
}
|
|
44
|
+
throw headErr;
|
|
45
|
+
}
|
|
39
46
|
}
|
|
40
47
|
async function getFileSize(bucketName, key) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
48
|
+
const s3 = getS3();
|
|
49
|
+
const result = await s3.send(new HeadObjectCommand({
|
|
50
|
+
Bucket: bucketName,
|
|
51
|
+
Key: key
|
|
52
|
+
}));
|
|
53
|
+
return result.ContentLength;
|
|
47
54
|
}
|
|
48
55
|
async function writeFile(bucketName, key, body, options = {}) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
const verbose = options.verbose || false;
|
|
56
|
-
const params = { Bucket: bucketName, Key: key, Body: body };
|
|
57
|
-
if (options.acl) {
|
|
58
|
-
params.ACL = options.acl;
|
|
59
|
-
}
|
|
60
|
-
if (options.contentType) {
|
|
61
|
-
params.ContentType = options.contentType;
|
|
56
|
+
const s3 = getS3();
|
|
57
|
+
if (options.skipIfExists) {
|
|
58
|
+
if (await hasFile(bucketName, key)) {
|
|
59
|
+
return;
|
|
62
60
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
61
|
+
}
|
|
62
|
+
const verbose = options.verbose || false;
|
|
63
|
+
const params = { Bucket: bucketName, Key: key, Body: body };
|
|
64
|
+
if (options.acl) {
|
|
65
|
+
params.ACL = options.acl;
|
|
66
|
+
}
|
|
67
|
+
if (options.contentType) {
|
|
68
|
+
params.ContentType = options.contentType;
|
|
69
|
+
}
|
|
70
|
+
if (verbose) {
|
|
71
|
+
console.log("uploading", key);
|
|
72
|
+
}
|
|
73
|
+
await s3.send(new PutObjectCommand(params));
|
|
67
74
|
}
|
|
68
75
|
async function deleteFile(bucketName, key, verbose = false) {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
// do nothing
|
|
80
|
-
return null;
|
|
81
|
-
}
|
|
82
|
-
throw error;
|
|
76
|
+
const s3 = getS3();
|
|
77
|
+
const params = { Bucket: bucketName, Key: key };
|
|
78
|
+
try {
|
|
79
|
+
await s3.send(new DeleteObjectCommand(params));
|
|
80
|
+
} catch (error) {
|
|
81
|
+
if (error instanceof NoSuchKey) {
|
|
82
|
+
if (verbose) {
|
|
83
|
+
console.log("no such bucket or key", bucketName, key);
|
|
84
|
+
}
|
|
85
|
+
return null;
|
|
83
86
|
}
|
|
87
|
+
throw error;
|
|
88
|
+
}
|
|
84
89
|
}
|
|
85
90
|
async function listKeys(bucketName, prefix, continuationToken) {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
return null;
|
|
99
|
-
}
|
|
100
|
-
throw `unable to list keys with prefix ${prefix}: ${err}`;
|
|
101
|
-
}
|
|
102
|
-
if (!data.Contents) {
|
|
103
|
-
return { keys: [] };
|
|
91
|
+
const s3 = getS3();
|
|
92
|
+
const params = {
|
|
93
|
+
Bucket: bucketName,
|
|
94
|
+
Prefix: prefix,
|
|
95
|
+
ContinuationToken: continuationToken
|
|
96
|
+
};
|
|
97
|
+
let data;
|
|
98
|
+
try {
|
|
99
|
+
data = await s3.send(new ListObjectsV2Command(params));
|
|
100
|
+
} catch (err) {
|
|
101
|
+
if (err instanceof Error && "statusCode" in err && err.statusCode === 400) {
|
|
102
|
+
return null;
|
|
104
103
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
};
|
|
104
|
+
throw `unable to list keys with prefix ${prefix}: ${err}`;
|
|
105
|
+
}
|
|
106
|
+
if (!data.Contents) {
|
|
107
|
+
return { keys: [] };
|
|
108
|
+
}
|
|
109
|
+
return {
|
|
110
|
+
keys: data.Contents.map(({ Key }) => Key),
|
|
111
|
+
continuationToken: data.IsTruncated ? data.NextContinuationToken : undefined
|
|
112
|
+
};
|
|
109
113
|
}
|
|
110
|
-
export {
|
|
114
|
+
export {
|
|
115
|
+
writeFile,
|
|
116
|
+
readFile,
|
|
117
|
+
listKeys,
|
|
118
|
+
hasFile,
|
|
119
|
+
getS3,
|
|
120
|
+
getFileSize,
|
|
121
|
+
deleteFile
|
|
122
|
+
};
|
package/dist/search.d.ts
CHANGED
package/dist/search.js
CHANGED
|
@@ -1,30 +1,105 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
// src/env.ts
|
|
2
|
+
function ensureAndGet(envName, defaultValue) {
|
|
3
|
+
return process.env[envName] || defaultValue;
|
|
4
|
+
}
|
|
5
|
+
function getEnvironment() {
|
|
6
|
+
return ensureAndGet("SKYNET_ENVIRONMENT", "dev");
|
|
7
|
+
}
|
|
8
|
+
function getEnvOrThrow(envName) {
|
|
9
|
+
if (!process.env[envName]) {
|
|
10
|
+
throw new Error(`Must set environment variable ${envName}`);
|
|
11
|
+
}
|
|
12
|
+
return process.env[envName];
|
|
13
|
+
}
|
|
14
|
+
function isProduction() {
|
|
15
|
+
return getEnvironment() === "prd";
|
|
16
|
+
}
|
|
17
|
+
function isDev() {
|
|
18
|
+
return getEnvironment() === "dev";
|
|
19
|
+
}
|
|
20
|
+
// src/log.ts
|
|
21
|
+
function isObject(a) {
|
|
22
|
+
return !!a && a.constructor === Object;
|
|
23
|
+
}
|
|
24
|
+
function print(o) {
|
|
25
|
+
if (Array.isArray(o)) {
|
|
26
|
+
return `[${o.map(print).join(", ")}]`;
|
|
27
|
+
}
|
|
28
|
+
if (isObject(o)) {
|
|
29
|
+
return `{${Object.keys(o).map((k) => `${k}: ${o[k]}`).join(", ")}}`;
|
|
30
|
+
}
|
|
31
|
+
return `${o}`;
|
|
32
|
+
}
|
|
33
|
+
function getLine(params) {
|
|
34
|
+
let line = "";
|
|
35
|
+
for (let i = 0, l = params.length;i < l; i++) {
|
|
36
|
+
line += `${print(params[i])} `.replace(/\n/gm, "\t");
|
|
37
|
+
}
|
|
38
|
+
return line.trim();
|
|
39
|
+
}
|
|
40
|
+
function timestamp() {
|
|
41
|
+
return new Date().toISOString();
|
|
42
|
+
}
|
|
43
|
+
var inline = {
|
|
44
|
+
debug: function(...args) {
|
|
45
|
+
if (true) {
|
|
46
|
+
console.log(`${timestamp()} ${getLine(args)}`);
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
log: function(...args) {
|
|
50
|
+
if (true) {
|
|
51
|
+
console.log(`${timestamp()} ${getLine(args)}`);
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
error: function(...args) {
|
|
55
|
+
if (true) {
|
|
56
|
+
console.error(`${timestamp()} ${getLine(args)}`);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
var logger = {
|
|
61
|
+
debug: function(...args) {
|
|
62
|
+
if (true) {
|
|
63
|
+
console.log(`[${timestamp()}]`, ...args);
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
log: function(...args) {
|
|
67
|
+
if (true) {
|
|
68
|
+
console.log(`[${timestamp()}]`, ...args);
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
error: function(...args) {
|
|
72
|
+
if (true) {
|
|
73
|
+
console.error(`[${timestamp()}]`, ...args);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
// src/search.ts
|
|
3
78
|
import { Client, HttpConnection } from "@elastic/elasticsearch";
|
|
4
79
|
import osModule from "os";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
80
|
+
async function sendToSearch(indexPrefix, record, throws = false) {
|
|
81
|
+
if (!process.env["SKYNET_ELASTICSEARCH_CLOUD_ID"] || !process.env["SKYNET_ELASTICSEARCH_API_KEY"]) {
|
|
82
|
+
throw new Error("SKYNET_ELASTICSEARCH_CLOUD_ID or SKYNET_ELASTICSEARCH_API_KEY is not set");
|
|
83
|
+
}
|
|
84
|
+
const client = new Client({
|
|
85
|
+
cloud: { id: process.env["SKYNET_ELASTICSEARCH_CLOUD_ID"] },
|
|
86
|
+
auth: { apiKey: process.env["SKYNET_ELASTICSEARCH_API_KEY"] },
|
|
87
|
+
Connection: HttpConnection
|
|
88
|
+
});
|
|
89
|
+
const now = new Date;
|
|
90
|
+
const indexName = [indexPrefix, isProduction() ? "prod" : "dev", now.toISOString().slice(0, 7)].join("-");
|
|
91
|
+
try {
|
|
92
|
+
await client.index({
|
|
93
|
+
index: indexName,
|
|
94
|
+
document: { instance: osModule.hostname(), timestamp: now, record }
|
|
13
95
|
});
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
try {
|
|
19
|
-
await client.index({
|
|
20
|
-
index: indexName,
|
|
21
|
-
document: { instance: osModule.hostname(), timestamp: now, record },
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
catch (err) {
|
|
25
|
-
inline.error(err);
|
|
26
|
-
if (throws) {
|
|
27
|
-
throw err;
|
|
28
|
-
}
|
|
96
|
+
} catch (err) {
|
|
97
|
+
inline.error(err);
|
|
98
|
+
if (throws) {
|
|
99
|
+
throw err;
|
|
29
100
|
}
|
|
101
|
+
}
|
|
30
102
|
}
|
|
103
|
+
export {
|
|
104
|
+
sendToSearch
|
|
105
|
+
};
|
package/dist/selector.d.ts
CHANGED
|
@@ -15,4 +15,3 @@ declare function getSelectorFlags<TSelector extends Selector>(selector: Selector
|
|
|
15
15
|
declare function toSelectorString<TSelector extends Selector>(selectorFlags: SelectorFlags<TSelector>, delim?: string): string;
|
|
16
16
|
declare function getJobName<TSelector extends Selector>(name: string, selectorFlags: SelectorFlags<TSelector>, mode?: string): string;
|
|
17
17
|
export { getJobName, getSelectorDesc, getSelectorFlags, toSelectorString };
|
|
18
|
-
//# sourceMappingURL=selector.d.ts.map
|
package/dist/selector.js
CHANGED
|
@@ -1,48 +1,44 @@
|
|
|
1
|
+
// src/selector.ts
|
|
1
2
|
function getSelectorDesc(selector) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
.join("\n");
|
|
3
|
+
return Object.keys(selector).map((name) => {
|
|
4
|
+
return ` --${name.padEnd(14)}${selector[name].desc || selector[name].description || ""}`;
|
|
5
|
+
}).join(`
|
|
6
|
+
`);
|
|
7
7
|
}
|
|
8
|
-
// check https://github.com/sindresorhus/meow for selector config options
|
|
9
8
|
function getSelectorFlags(selector) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}, {});
|
|
9
|
+
return Object.keys(selector).reduce((acc, name) => {
|
|
10
|
+
const flag = {
|
|
11
|
+
type: selector[name].type || "string",
|
|
12
|
+
...selector[name]
|
|
13
|
+
};
|
|
14
|
+
if (!selector[name].optional && selector[name].isRequired !== false) {
|
|
15
|
+
flag.isRequired = true;
|
|
16
|
+
}
|
|
17
|
+
return { ...acc, [name]: flag };
|
|
18
|
+
}, {});
|
|
21
19
|
}
|
|
22
20
|
function toSelectorString(selectorFlags, delim = ",") {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
return `${flag}=${selectorFlags[flag]}`;
|
|
27
|
-
})
|
|
28
|
-
.join(delim);
|
|
21
|
+
return Object.keys(selectorFlags).sort().map((flag) => {
|
|
22
|
+
return `${flag}=${selectorFlags[flag]}`;
|
|
23
|
+
}).join(delim);
|
|
29
24
|
}
|
|
30
25
|
function normalizeSelectorValue(v) {
|
|
31
|
-
|
|
26
|
+
return v.replace(/[^A-Za-z0-9]+/g, "-");
|
|
32
27
|
}
|
|
33
28
|
function getJobName(name, selectorFlags, mode) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
// handle special case
|
|
44
|
-
jobName += `-${normalizeSelectorValue(selectorNamePart)}`;
|
|
45
|
-
}
|
|
46
|
-
return jobName;
|
|
29
|
+
const selectorNamePart = Object.keys(selectorFlags).sort().map((name2) => selectorFlags[name2]).join("-");
|
|
30
|
+
let jobName = name;
|
|
31
|
+
if (mode) {
|
|
32
|
+
jobName += `-${mode}`;
|
|
33
|
+
}
|
|
34
|
+
if (selectorNamePart.length > 0) {
|
|
35
|
+
jobName += `-${normalizeSelectorValue(selectorNamePart)}`;
|
|
36
|
+
}
|
|
37
|
+
return jobName;
|
|
47
38
|
}
|
|
48
|
-
export {
|
|
39
|
+
export {
|
|
40
|
+
toSelectorString,
|
|
41
|
+
getSelectorFlags,
|
|
42
|
+
getSelectorDesc,
|
|
43
|
+
getJobName
|
|
44
|
+
};
|
package/dist/slack.d.ts
CHANGED
package/dist/slack.js
CHANGED
|
@@ -1,26 +1,32 @@
|
|
|
1
|
+
// src/slack.ts
|
|
1
2
|
import { WebClient } from "@slack/web-api";
|
|
2
3
|
function getClient(token) {
|
|
3
|
-
|
|
4
|
+
return new WebClient(token);
|
|
4
5
|
}
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
catch (error) {
|
|
22
|
-
console.error("failed to post slack message", error);
|
|
23
|
-
throw error;
|
|
6
|
+
async function postMessageToConversation({
|
|
7
|
+
conversationId,
|
|
8
|
+
message,
|
|
9
|
+
token,
|
|
10
|
+
verbose
|
|
11
|
+
}) {
|
|
12
|
+
if (!token) {
|
|
13
|
+
throw new Error("missing slack token");
|
|
14
|
+
}
|
|
15
|
+
try {
|
|
16
|
+
const client = getClient(token);
|
|
17
|
+
const post = typeof message === "string" ? { text: message } : message;
|
|
18
|
+
if (verbose) {
|
|
19
|
+
console.log(`posting to slack conversation ${conversationId}:`, JSON.stringify(post, null, 2));
|
|
24
20
|
}
|
|
21
|
+
await client.chat.postMessage({
|
|
22
|
+
channel: conversationId,
|
|
23
|
+
...post
|
|
24
|
+
});
|
|
25
|
+
} catch (error) {
|
|
26
|
+
console.error("failed to post slack message", error);
|
|
27
|
+
throw error;
|
|
28
|
+
}
|
|
25
29
|
}
|
|
26
|
-
export {
|
|
30
|
+
export {
|
|
31
|
+
postMessageToConversation
|
|
32
|
+
};
|
package/dist/util.d.ts
CHANGED
|
@@ -2,4 +2,3 @@ declare function range(startAt: number, endAt: number, step: number): [number, n
|
|
|
2
2
|
declare function arrayGroup<T>(array: T[], groupSize: number): T[][];
|
|
3
3
|
declare function fillRange(start: number, end: number): number[];
|
|
4
4
|
export { arrayGroup, range, fillRange };
|
|
5
|
-
//# sourceMappingURL=util.d.ts.map
|
package/dist/util.js
CHANGED
|
@@ -1,26 +1,27 @@
|
|
|
1
|
-
//
|
|
1
|
+
// src/util.ts
|
|
2
2
|
function range(startAt, endAt, step) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
const arr = [];
|
|
4
|
+
for (let i = startAt;i <= endAt; i += step) {
|
|
5
|
+
arr.push([i, Math.min(endAt, i + step - 1)]);
|
|
6
|
+
}
|
|
7
|
+
return arr;
|
|
8
8
|
}
|
|
9
9
|
function arrayGroup(array, groupSize) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
const groups = [];
|
|
11
|
+
for (let i = 0;i < array.length; i += groupSize) {
|
|
12
|
+
groups.push(array.slice(i, i + groupSize));
|
|
13
|
+
}
|
|
14
|
+
return groups;
|
|
15
15
|
}
|
|
16
|
-
// return an array with numbers of given inclusive range
|
|
17
|
-
// given 1, 5
|
|
18
|
-
// return [1, 2, 3, 4, 5]
|
|
19
16
|
function fillRange(start, end) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
17
|
+
const result = [];
|
|
18
|
+
for (let i = start;i <= end; i++) {
|
|
19
|
+
result.push(i);
|
|
20
|
+
}
|
|
21
|
+
return result;
|
|
25
22
|
}
|
|
26
|
-
export {
|
|
23
|
+
export {
|
|
24
|
+
range,
|
|
25
|
+
fillRange,
|
|
26
|
+
arrayGroup
|
|
27
|
+
};
|
package/examples/api.ts
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
// $ examples/api --help
|
|
9
9
|
|
|
10
10
|
import type { Request, Response, NextFunction } from "express";
|
|
11
|
-
import { api, SENSITIVE_VALUE } from "../app";
|
|
11
|
+
import { api, SENSITIVE_VALUE } from "../src/app";
|
|
12
12
|
|
|
13
13
|
// an example middleware
|
|
14
14
|
async function exampleMiddleware(req: Request, res: Response, next: NextFunction) {
|
package/examples/indexer.ts
CHANGED
package/examples/mode-indexer.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@certik/skynet",
|
|
3
|
-
"version": "0.22.
|
|
3
|
+
"version": "0.22.2",
|
|
4
4
|
"description": "Skynet Shared JS library",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -99,7 +99,7 @@
|
|
|
99
99
|
},
|
|
100
100
|
"author": "CertiK Engineering",
|
|
101
101
|
"scripts": {
|
|
102
|
-
"build": "tsc --project tsconfig.build.json",
|
|
102
|
+
"build": "rimraf dist && bun build.ts && tsc --project tsconfig.build.json",
|
|
103
103
|
"clean": "rimraf dist",
|
|
104
104
|
"lint": "eslint '*.ts' test/*.ts",
|
|
105
105
|
"test": "doppler run -- bun test",
|
|
@@ -140,8 +140,9 @@
|
|
|
140
140
|
"eslint-plugin-md": "^1.0.19",
|
|
141
141
|
"eslint-plugin-prettier": "^5.2.3",
|
|
142
142
|
"prettier": "^3.5.2",
|
|
143
|
+
"rimraf": "^6.0.1",
|
|
143
144
|
"typescript": "^5.8.2",
|
|
144
|
-
"
|
|
145
|
+
"typescript-eslint": "^8.38.0"
|
|
145
146
|
},
|
|
146
147
|
"license": "MIT",
|
|
147
148
|
"publishConfig": {
|
|
@@ -150,4 +151,4 @@
|
|
|
150
151
|
"patchedDependencies": {
|
|
151
152
|
"@databricks/sql@1.9.0": "patches/@databricks%2Fsql@1.9.0.patch"
|
|
152
153
|
}
|
|
153
|
-
}
|
|
154
|
+
}
|
|
@@ -30,7 +30,7 @@ export async function gql<T>(query: string, variables: GraphqlVariables = {}) {
|
|
|
30
30
|
});
|
|
31
31
|
|
|
32
32
|
if (res.ok) {
|
|
33
|
-
const { data, errors }
|
|
33
|
+
const { data, errors } = (await res.json()) as GraphQLResponse<T>;
|
|
34
34
|
|
|
35
35
|
if (errors && errors.length > 0) {
|
|
36
36
|
throw new Error(JSON.stringify(errors, null, 2));
|
|
@@ -13,6 +13,7 @@ type OpsgenieResponse = {
|
|
|
13
13
|
};
|
|
14
14
|
took: number;
|
|
15
15
|
requestId: string;
|
|
16
|
+
result: string;
|
|
16
17
|
};
|
|
17
18
|
|
|
18
19
|
function getGenieKey(key?: string) {
|
|
@@ -55,7 +56,7 @@ export async function postGenieMessage(
|
|
|
55
56
|
body: JSON.stringify(body),
|
|
56
57
|
});
|
|
57
58
|
|
|
58
|
-
const result
|
|
59
|
+
const result = (await response.json()) as OpsgenieResponse;
|
|
59
60
|
if (verbose) {
|
|
60
61
|
console.log(`Result of API call to Opsgenie... ${result}`);
|
|
61
62
|
}
|
package/tsconfig.build.json
CHANGED
|
@@ -4,15 +4,12 @@
|
|
|
4
4
|
"noEmit": false,
|
|
5
5
|
"outDir": "dist",
|
|
6
6
|
"declaration": true,
|
|
7
|
-
"
|
|
8
|
-
"target": "ES2020",
|
|
9
|
-
"module": "ES2020",
|
|
10
|
-
"moduleResolution": "bundler",
|
|
7
|
+
"emitDeclarationOnly": true,
|
|
11
8
|
"allowImportingTsExtensions": false,
|
|
12
9
|
"verbatimModuleSyntax": false
|
|
13
10
|
},
|
|
14
11
|
"include": [
|
|
15
|
-
"
|
|
12
|
+
"src/**/*.ts"
|
|
16
13
|
],
|
|
17
14
|
"exclude": [
|
|
18
15
|
"test/**/*",
|