@certik/skynet 0.18.6 → 0.18.8
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/.eslintrc.json +5 -6
- package/CHANGELOG.md +10 -2
- package/README.md +7 -7
- package/app.d.ts +4 -4
- package/bun.lockb +0 -0
- package/databricks.js +81 -0
- package/examples/api.js +0 -0
- package/examples/consumer.js +0 -0
- package/examples/indexer.js +0 -0
- package/examples/mode-indexer.js +0 -0
- package/examples/producer.js +0 -0
- package/package.json +5 -3
- package/selector.d.ts +1 -1
- package/.vscode/settings.json +0 -5
package/.eslintrc.json
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
{
|
|
2
|
+
"extends": ["eslint:recommended", "plugin:import/recommended", "plugin:md/prettier"],
|
|
3
|
+
"parserOptions": {
|
|
4
|
+
"ecmaVersion": 2023
|
|
5
|
+
},
|
|
2
6
|
"env": {
|
|
3
7
|
"node": true,
|
|
4
8
|
"browser": false,
|
|
5
|
-
"
|
|
6
|
-
},
|
|
7
|
-
"extends": ["eslint:recommended", "plugin:import/recommended"],
|
|
8
|
-
"parserOptions": {
|
|
9
|
-
"ecmaVersion": "latest",
|
|
10
|
-
"sourceType": "module"
|
|
9
|
+
"es2023": true
|
|
11
10
|
},
|
|
12
11
|
"settings": {
|
|
13
12
|
"import/core-modules": ["ava", "meow"],
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.18.8
|
|
4
|
+
|
|
5
|
+
- Added `databricks` library with `executeSql` function
|
|
6
|
+
|
|
7
|
+
## 0.18.7
|
|
8
|
+
|
|
9
|
+
- Update type definition for app.js and selector.js
|
|
10
|
+
|
|
3
11
|
## 0.18.6
|
|
4
12
|
|
|
5
13
|
- Update type definition for app.js and selector.js
|
|
@@ -293,9 +301,9 @@
|
|
|
293
301
|
|
|
294
302
|
## 0.10.21
|
|
295
303
|
|
|
296
|
-
- Enabled more customizations for indexer selector support, check https://github.com/sindresorhus/meow for available config options, an example
|
|
304
|
+
- Enabled more customizations for indexer selector support, check <https://github.com/sindresorhus/meow> for available config options, an example
|
|
297
305
|
|
|
298
|
-
```
|
|
306
|
+
```bash
|
|
299
307
|
selectors: {
|
|
300
308
|
"onlyProject": {
|
|
301
309
|
type: "string",
|
package/README.md
CHANGED
|
@@ -2,22 +2,22 @@
|
|
|
2
2
|
|
|
3
3
|
## Usage
|
|
4
4
|
|
|
5
|
-
```
|
|
6
|
-
|
|
5
|
+
```bash
|
|
6
|
+
bun add @certik/skynet
|
|
7
7
|
```
|
|
8
8
|
|
|
9
|
-
```
|
|
9
|
+
```bash
|
|
10
10
|
const { scanWholeTable } = require("@certik/skynet/dynamodb");
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
## Test
|
|
14
14
|
|
|
15
|
-
```
|
|
16
|
-
|
|
15
|
+
```bash
|
|
16
|
+
bun run test
|
|
17
17
|
```
|
|
18
18
|
|
|
19
19
|
## Publish
|
|
20
20
|
|
|
21
|
-
```
|
|
22
|
-
|
|
21
|
+
```bash
|
|
22
|
+
bun run pub
|
|
23
23
|
```
|
package/app.d.ts
CHANGED
|
@@ -69,15 +69,15 @@ export type Validate = {
|
|
|
69
69
|
mem: number;
|
|
70
70
|
};
|
|
71
71
|
|
|
72
|
-
type BuildWithRestart = Build & { restart
|
|
72
|
+
type BuildWithRestart = Build & { restart?: Restart };
|
|
73
73
|
|
|
74
|
-
type BuildWithConcurrency = Build & { concurrency
|
|
74
|
+
type BuildWithConcurrency = Build & { concurrency?: number };
|
|
75
75
|
|
|
76
|
-
type ValidateWithConcurrency = Validate & { concurrency
|
|
76
|
+
type ValidateWithConcurrency = Validate & { concurrency?: number };
|
|
77
77
|
|
|
78
78
|
export const SENSITIVE_VALUE: null;
|
|
79
79
|
|
|
80
|
-
export function every(n
|
|
80
|
+
export function every(n?: number): {
|
|
81
81
|
second: string;
|
|
82
82
|
seconds: string;
|
|
83
83
|
minute: string;
|
package/bun.lockb
CHANGED
|
Binary file
|
package/databricks.js
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
// eslint-disable-next-line no-unused-vars
|
|
2
|
+
import { DBSQLClient, DBSQLParameter, DBSQLSession } from "@databricks/sql";
|
|
3
|
+
import { ensureAndGet } from "./env.js";
|
|
4
|
+
import { exponentialRetry } from "./availability.js";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @type {DBSQLClient}
|
|
8
|
+
*/
|
|
9
|
+
let client;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @type {DBSQLSession}
|
|
13
|
+
*/
|
|
14
|
+
let session;
|
|
15
|
+
|
|
16
|
+
async function initSession() {
|
|
17
|
+
if (!client) {
|
|
18
|
+
client = new DBSQLClient();
|
|
19
|
+
await client.connect({
|
|
20
|
+
token: ensureAndGet("SKYNET_DATABRICKS_TOKEN"),
|
|
21
|
+
host: ensureAndGet("SKYNET_DATABRICKS_SERVER_HOSTNAME"),
|
|
22
|
+
path: ensureAndGet("SKYNET_DATABRICKS_HTTP_PATH"),
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
if (!session) {
|
|
26
|
+
session = await client.openSession();
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
async function executeSql(sql, bindings) {
|
|
31
|
+
// retry sql query to avoid socket hang up error
|
|
32
|
+
const results = exponentialRetry(
|
|
33
|
+
async () => {
|
|
34
|
+
let queryOperation;
|
|
35
|
+
try {
|
|
36
|
+
await initSession();
|
|
37
|
+
queryOperation = await session.executeStatement(sql, {
|
|
38
|
+
runAsync: true,
|
|
39
|
+
namedParameters: objToParameter(bindings),
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
const result = await queryOperation.fetchAll();
|
|
43
|
+
return result;
|
|
44
|
+
} catch (err) {
|
|
45
|
+
// If the error is not a Databricks error, throw it
|
|
46
|
+
if (!checkIsDatabricksError(err)) {
|
|
47
|
+
throw err;
|
|
48
|
+
}
|
|
49
|
+
return err;
|
|
50
|
+
} finally {
|
|
51
|
+
await queryOperation?.close();
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
maxRetry: 3,
|
|
56
|
+
initialDuration: 500,
|
|
57
|
+
test: (result) => {
|
|
58
|
+
return !checkIsDatabricksError(result);
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
if (checkIsDatabricksError(results)) {
|
|
64
|
+
// still error after retry, throw it
|
|
65
|
+
throw results;
|
|
66
|
+
}
|
|
67
|
+
return results;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function checkIsDatabricksError(err) {
|
|
71
|
+
return err?.errno === "ECONNRESET" || err?.message?.includes("java.lang.NullPointerException");
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function objToParameter(obj) {
|
|
75
|
+
return Object.entries(obj).reduce((acc, [key, value]) => {
|
|
76
|
+
acc[key] = new DBSQLParameter({ value });
|
|
77
|
+
return acc;
|
|
78
|
+
}, {});
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export { executeSql };
|
package/examples/api.js
CHANGED
|
File without changes
|
package/examples/consumer.js
CHANGED
|
File without changes
|
package/examples/indexer.js
CHANGED
|
File without changes
|
package/examples/mode-indexer.js
CHANGED
|
File without changes
|
package/examples/producer.js
CHANGED
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@certik/skynet",
|
|
3
|
-
"version": "0.18.
|
|
3
|
+
"version": "0.18.8",
|
|
4
4
|
"description": "Skynet Shared JS library",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
"@aws-sdk/client-s3": "^3.478.0",
|
|
20
20
|
"@aws-sdk/client-sqs": "^3.478.0",
|
|
21
21
|
"@aws-sdk/lib-dynamodb": "^3.478.0",
|
|
22
|
+
"@databricks/sql": "^1.9.0",
|
|
22
23
|
"@elastic/elasticsearch": "^8.14.0",
|
|
23
24
|
"@slack/web-api": "^6.11.0",
|
|
24
25
|
"bottleneck": "^2.19.5",
|
|
@@ -33,8 +34,9 @@
|
|
|
33
34
|
},
|
|
34
35
|
"devDependencies": {
|
|
35
36
|
"ava": "^6.1.3",
|
|
36
|
-
"eslint": "8",
|
|
37
|
+
"eslint": "^8.45.0",
|
|
37
38
|
"eslint-plugin-import": "^2.29.1",
|
|
39
|
+
"eslint-plugin-md": "^1.0.19",
|
|
38
40
|
"prettier": "^3.3.3",
|
|
39
41
|
"sinon": "^18.0.0"
|
|
40
42
|
},
|
|
@@ -42,4 +44,4 @@
|
|
|
42
44
|
"publishConfig": {
|
|
43
45
|
"access": "public"
|
|
44
46
|
}
|
|
45
|
-
}
|
|
47
|
+
}
|
package/selector.d.ts
CHANGED