@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.
Files changed (102) hide show
  1. package/.vscode/settings.json +5 -0
  2. package/CHANGELOG.md +4 -0
  3. package/build.ts +23 -0
  4. package/bun.lockb +0 -0
  5. package/dist/abi.d.ts +1 -2
  6. package/dist/abi.js +569 -563
  7. package/dist/address.d.ts +0 -1
  8. package/dist/address.js +22 -21
  9. package/dist/api.d.ts +0 -1
  10. package/dist/api.js +235 -120
  11. package/dist/app.d.ts +1 -2
  12. package/dist/app.js +2030 -276
  13. package/dist/availability.d.ts +0 -1
  14. package/dist/availability.js +126 -56
  15. package/dist/cli.d.ts +0 -1
  16. package/dist/cli.js +28 -24
  17. package/dist/const.d.ts +0 -1
  18. package/dist/const.js +153 -132
  19. package/dist/databricks.d.ts +0 -1
  20. package/dist/databricks.js +198 -58
  21. package/dist/date.d.ts +0 -1
  22. package/dist/date.js +48 -21
  23. package/dist/deploy.d.ts +0 -1
  24. package/dist/deploy.js +427 -292
  25. package/dist/dynamodb.d.ts +3 -4
  26. package/dist/dynamodb.js +432 -281
  27. package/dist/env.d.ts +2 -3
  28. package/dist/env.js +16 -9
  29. package/dist/graphql.d.ts +0 -1
  30. package/dist/graphql.js +26 -23
  31. package/dist/indexer.d.ts +0 -1
  32. package/dist/indexer.js +1050 -441
  33. package/dist/log.d.ts +0 -1
  34. package/dist/log.js +53 -52
  35. package/dist/object-hash.d.ts +0 -1
  36. package/dist/object-hash.js +49 -59
  37. package/dist/opsgenie.d.ts +1 -1
  38. package/dist/opsgenie.js +31 -30
  39. package/dist/por.d.ts +0 -1
  40. package/dist/por.js +113 -123
  41. package/dist/s3.d.ts +7 -8
  42. package/dist/s3.js +103 -91
  43. package/dist/search.d.ts +0 -1
  44. package/dist/search.js +100 -25
  45. package/dist/selector.d.ts +0 -1
  46. package/dist/selector.js +34 -38
  47. package/dist/slack.d.ts +0 -1
  48. package/dist/slack.js +27 -21
  49. package/dist/util.d.ts +0 -1
  50. package/dist/util.js +21 -20
  51. package/examples/api.ts +1 -1
  52. package/examples/indexer.ts +1 -1
  53. package/examples/mode-indexer.ts +1 -1
  54. package/package.json +5 -4
  55. package/{graphql.ts → src/graphql.ts} +1 -1
  56. package/{opsgenie.ts → src/opsgenie.ts} +2 -1
  57. package/tsconfig.build.json +2 -5
  58. package/tsconfig.json +11 -20
  59. package/dist/abi.d.ts.map +0 -1
  60. package/dist/address.d.ts.map +0 -1
  61. package/dist/api.d.ts.map +0 -1
  62. package/dist/app.d.ts.map +0 -1
  63. package/dist/availability.d.ts.map +0 -1
  64. package/dist/cli.d.ts.map +0 -1
  65. package/dist/const.d.ts.map +0 -1
  66. package/dist/databricks.d.ts.map +0 -1
  67. package/dist/date.d.ts.map +0 -1
  68. package/dist/deploy.d.ts.map +0 -1
  69. package/dist/dynamodb.d.ts.map +0 -1
  70. package/dist/env.d.ts.map +0 -1
  71. package/dist/graphql.d.ts.map +0 -1
  72. package/dist/indexer.d.ts.map +0 -1
  73. package/dist/log.d.ts.map +0 -1
  74. package/dist/object-hash.d.ts.map +0 -1
  75. package/dist/opsgenie.d.ts.map +0 -1
  76. package/dist/por.d.ts.map +0 -1
  77. package/dist/s3.d.ts.map +0 -1
  78. package/dist/search.d.ts.map +0 -1
  79. package/dist/selector.d.ts.map +0 -1
  80. package/dist/slack.d.ts.map +0 -1
  81. package/dist/util.d.ts.map +0 -1
  82. /package/{abi.ts → src/abi.ts} +0 -0
  83. /package/{address.ts → src/address.ts} +0 -0
  84. /package/{api.ts → src/api.ts} +0 -0
  85. /package/{app.ts → src/app.ts} +0 -0
  86. /package/{availability.ts → src/availability.ts} +0 -0
  87. /package/{cli.ts → src/cli.ts} +0 -0
  88. /package/{const.ts → src/const.ts} +0 -0
  89. /package/{databricks.ts → src/databricks.ts} +0 -0
  90. /package/{date.ts → src/date.ts} +0 -0
  91. /package/{deploy.ts → src/deploy.ts} +0 -0
  92. /package/{dynamodb.ts → src/dynamodb.ts} +0 -0
  93. /package/{env.ts → src/env.ts} +0 -0
  94. /package/{indexer.ts → src/indexer.ts} +0 -0
  95. /package/{log.ts → src/log.ts} +0 -0
  96. /package/{object-hash.ts → src/object-hash.ts} +0 -0
  97. /package/{por.ts → src/por.ts} +0 -0
  98. /package/{s3.ts → src/s3.ts} +0 -0
  99. /package/{search.ts → src/search.ts} +0 -0
  100. /package/{selector.ts → src/selector.ts} +0 -0
  101. /package/{slack.ts → src/slack.ts} +0 -0
  102. /package/{util.ts → src/util.ts} +0 -0
package/dist/s3.js CHANGED
@@ -1,110 +1,122 @@
1
- import { S3Client, GetObjectCommand, HeadObjectCommand, PutObjectCommand, DeleteObjectCommand, ListObjectsV2Command, NotFound, NoSuchKey, } from "@aws-sdk/client-s3";
2
- let _s3Client;
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
- if (!_s3Client || forceNew) {
5
- _s3Client = new S3Client();
6
- }
7
- return _s3Client;
14
+ if (!_s3Client || forceNew) {
15
+ _s3Client = new S3Client;
16
+ }
17
+ return _s3Client;
8
18
  }
9
19
  async function readFile(bucketName, key, verbose = false) {
10
- const s3 = getS3();
11
- const params = { Bucket: bucketName, Key: key };
12
- try {
13
- const result = await s3.send(new GetObjectCommand(params));
14
- return result.Body?.transformToString();
15
- }
16
- catch (error) {
17
- if (error instanceof NoSuchKey) {
18
- if (verbose) {
19
- console.log("no such bucket or key", bucketName, key);
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
- const s3 = getS3();
29
- try {
30
- await s3.send(new HeadObjectCommand({ Bucket: bucketName, Key: key }));
31
- return true;
32
- }
33
- catch (headErr) {
34
- if (headErr instanceof NotFound) {
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
- const s3 = getS3();
42
- const result = await s3.send(new HeadObjectCommand({
43
- Bucket: bucketName,
44
- Key: key,
45
- }));
46
- return result.ContentLength;
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
- const s3 = getS3();
50
- if (options.skipIfExists) {
51
- if (await hasFile(bucketName, key)) {
52
- return;
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
- if (verbose) {
64
- console.log("uploading", key);
65
- }
66
- await s3.send(new PutObjectCommand(params));
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
- const s3 = getS3();
70
- const params = { Bucket: bucketName, Key: key };
71
- try {
72
- await s3.send(new DeleteObjectCommand(params));
73
- }
74
- catch (error) {
75
- if (error instanceof NoSuchKey) {
76
- if (verbose) {
77
- console.log("no such bucket or key", bucketName, key);
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
- const s3 = getS3();
87
- const params = {
88
- Bucket: bucketName,
89
- Prefix: prefix,
90
- ContinuationToken: continuationToken,
91
- };
92
- let data;
93
- try {
94
- data = await s3.send(new ListObjectsV2Command(params));
95
- }
96
- catch (err) {
97
- if (err instanceof Error && "statusCode" in err && err.statusCode === 400) {
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
- return {
106
- keys: data.Contents.map(({ Key }) => Key),
107
- continuationToken: data.IsTruncated ? data.NextContinuationToken : undefined,
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 { getS3, hasFile, readFile, writeFile, deleteFile, getFileSize, listKeys };
114
+ export {
115
+ writeFile,
116
+ readFile,
117
+ listKeys,
118
+ hasFile,
119
+ getS3,
120
+ getFileSize,
121
+ deleteFile
122
+ };
package/dist/search.d.ts CHANGED
@@ -3,4 +3,3 @@ type ElasticSearchRecord = {
3
3
  };
4
4
  export declare function sendToSearch(indexPrefix: string, record: ElasticSearchRecord, throws?: boolean): Promise<void>;
5
5
  export {};
6
- //# sourceMappingURL=search.d.ts.map
package/dist/search.js CHANGED
@@ -1,30 +1,105 @@
1
- import { isProduction } from "./env";
2
- import { inline } from "./log";
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
- export async function sendToSearch(indexPrefix, record, throws = false) {
6
- if (!process.env["SKYNET_ELASTICSEARCH_CLOUD_ID"] || !process.env["SKYNET_ELASTICSEARCH_API_KEY"]) {
7
- throw new Error("SKYNET_ELASTICSEARCH_CLOUD_ID or SKYNET_ELASTICSEARCH_API_KEY is not set");
8
- }
9
- const client = new Client({
10
- cloud: { id: process.env["SKYNET_ELASTICSEARCH_CLOUD_ID"] },
11
- auth: { apiKey: process.env["SKYNET_ELASTICSEARCH_API_KEY"] },
12
- Connection: HttpConnection, // bun compatibility, see https://github.com/oven-sh/bun/issues/7920
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
- const now = new Date();
15
- const indexName = [indexPrefix, isProduction() ? "prod" : "dev", now.toISOString().slice(0, 7)].join("-");
16
- // best as possible delivery
17
- // by default not throw
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
+ };
@@ -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
- return Object.keys(selector)
3
- .map((name) => {
4
- return ` --${name.padEnd(14)}${selector[name].desc || selector[name].description || ""}`;
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
- return Object.keys(selector).reduce((acc, name) => {
11
- const flag = {
12
- type: selector[name].type || "string",
13
- ...selector[name],
14
- };
15
- // by default to be required
16
- if (!selector[name].optional && selector[name].isRequired !== false) {
17
- flag.isRequired = true;
18
- }
19
- return { ...acc, [name]: flag };
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
- return Object.keys(selectorFlags)
24
- .sort() // deterministic
25
- .map((flag) => {
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
- return v.replace(/[^A-Za-z0-9]+/g, "-");
26
+ return v.replace(/[^A-Za-z0-9]+/g, "-");
32
27
  }
33
28
  function getJobName(name, selectorFlags, mode) {
34
- const selectorNamePart = Object.keys(selectorFlags)
35
- .sort()
36
- .map((name) => selectorFlags[name])
37
- .join("-");
38
- let jobName = name;
39
- if (mode) {
40
- jobName += `-${mode}`;
41
- }
42
- if (selectorNamePart.length > 0) {
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 { getJobName, getSelectorDesc, getSelectorFlags, toSelectorString };
39
+ export {
40
+ toSelectorString,
41
+ getSelectorFlags,
42
+ getSelectorDesc,
43
+ getJobName
44
+ };
package/dist/slack.d.ts CHANGED
@@ -6,4 +6,3 @@ declare function postMessageToConversation({ conversationId, message, token, ver
6
6
  verbose?: boolean;
7
7
  }): Promise<void>;
8
8
  export { postMessageToConversation };
9
- //# sourceMappingURL=slack.d.ts.map
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
- return new WebClient(token);
4
+ return new WebClient(token);
4
5
  }
5
- // you can identify conversation ID at the bottom of the channel settings page
6
- async function postMessageToConversation({ conversationId, message, token, verbose, }) {
7
- if (!token) {
8
- throw new Error("missing slack token");
9
- }
10
- try {
11
- const client = getClient(token);
12
- const post = typeof message === "string" ? { text: message } : message;
13
- if (verbose) {
14
- console.log(`posting to slack conversation ${conversationId}:`, JSON.stringify(post, null, 2));
15
- }
16
- await client.chat.postMessage({
17
- channel: conversationId,
18
- ...post,
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 { postMessageToConversation };
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
- // Inclusive range
1
+ // src/util.ts
2
2
  function range(startAt, endAt, step) {
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;
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
- const groups = [];
11
- for (let i = 0; i < array.length; i += groupSize) {
12
- groups.push(array.slice(i, i + groupSize));
13
- }
14
- return groups;
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
- const result = [];
21
- for (let i = start; i <= end; i++) {
22
- result.push(i);
23
- }
24
- return result;
17
+ const result = [];
18
+ for (let i = start;i <= end; i++) {
19
+ result.push(i);
20
+ }
21
+ return result;
25
22
  }
26
- export { arrayGroup, range, fillRange };
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) {
@@ -7,7 +7,7 @@
7
7
  // $ examples/indexer deploy --protocol eth
8
8
  // $ examples/indexer --help
9
9
 
10
- import { indexer, every } from "../app";
10
+ import { indexer, every } from "../src/app";
11
11
 
12
12
  const app = indexer({
13
13
  name: "example-indexer",
@@ -8,7 +8,7 @@
8
8
  // $ examples/mode-indexer deploy --protocol eth
9
9
  // $ examples/mode-indexer --help
10
10
 
11
- import { modeIndexer, every } from "../app";
11
+ import { modeIndexer, every } from "../src/app";
12
12
 
13
13
  async function validate({
14
14
  protocol,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@certik/skynet",
3
- "version": "0.22.1",
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
- "rimraf": "^6.0.1"
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 }: GraphQLResponse<T> = await res.json();
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: OpsgenieResponse = await response.json();
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
  }
@@ -4,15 +4,12 @@
4
4
  "noEmit": false,
5
5
  "outDir": "dist",
6
6
  "declaration": true,
7
- "declarationMap": true,
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
- "*.ts"
12
+ "src/**/*.ts"
16
13
  ],
17
14
  "exclude": [
18
15
  "test/**/*",