@kravc/dos-dynamodb 1.0.0-alpha.7 → 1.0.1
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/.github/workflows/ci.yaml +26 -0
- package/.github/workflows/publish.yaml +32 -0
- package/AGENTS.md +14 -0
- package/README.md +52 -1
- package/bin/db-down.js +20 -0
- package/bin/db-up.js +73 -0
- package/dist/src/Table/helpers/getRawClientConfig.d.ts.map +1 -1
- package/dist/src/Table/helpers/getRawClientConfig.js +2 -2
- package/dist/src/Table/helpers/getRawClientConfig.js.map +1 -1
- package/package.json +4 -3
- package/src/Document/__tests__/Document.test.ts +4 -4
- package/src/Table/helpers/getRawClientConfig.ts +2 -4
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
test:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
steps:
|
|
13
|
+
- uses: actions/checkout@v4
|
|
14
|
+
|
|
15
|
+
- uses: actions/setup-node@v4
|
|
16
|
+
with:
|
|
17
|
+
node-version: 22
|
|
18
|
+
cache: npm
|
|
19
|
+
|
|
20
|
+
- run: npm ci
|
|
21
|
+
|
|
22
|
+
- run: npm test
|
|
23
|
+
env:
|
|
24
|
+
AWS_ACCESS_KEY_ID: local
|
|
25
|
+
AWS_SECRET_ACCESS_KEY: local
|
|
26
|
+
AWS_REGION: us-east-1
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
name: Publish
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- 'v*'
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
publish:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
permissions:
|
|
12
|
+
contents: read
|
|
13
|
+
steps:
|
|
14
|
+
- uses: actions/checkout@v4
|
|
15
|
+
|
|
16
|
+
- uses: actions/setup-node@v4
|
|
17
|
+
with:
|
|
18
|
+
node-version: 22
|
|
19
|
+
cache: npm
|
|
20
|
+
registry-url: https://registry.npmjs.org
|
|
21
|
+
|
|
22
|
+
- run: npm ci
|
|
23
|
+
|
|
24
|
+
- run: npm test
|
|
25
|
+
env:
|
|
26
|
+
AWS_ACCESS_KEY_ID: local
|
|
27
|
+
AWS_SECRET_ACCESS_KEY: local
|
|
28
|
+
AWS_REGION: us-east-1
|
|
29
|
+
|
|
30
|
+
- run: npm publish --access public
|
|
31
|
+
env:
|
|
32
|
+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
package/AGENTS.md
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Agents
|
|
2
|
+
|
|
3
|
+
## Commands
|
|
4
|
+
|
|
5
|
+
- `npm run test` to run tests
|
|
6
|
+
|
|
7
|
+
## Requirements
|
|
8
|
+
|
|
9
|
+
- 100% code coverage is required
|
|
10
|
+
|
|
11
|
+
## DynamoDB Local
|
|
12
|
+
|
|
13
|
+
- **macOS**: requires [`apple/container`](https://github.com/apple/container) installed and `container system start` running
|
|
14
|
+
- **Linux**: requires Docker
|
package/README.md
CHANGED
|
@@ -20,11 +20,62 @@ List supported DynamoDB table commands:
|
|
|
20
20
|
npx table
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
+
## Development
|
|
24
|
+
|
|
25
|
+
Tests require DynamoDB Local to be running on port 8000.
|
|
26
|
+
|
|
27
|
+
**macOS** — uses [apple/container](https://github.com/apple/container) (requires macOS 26+):
|
|
28
|
+
|
|
29
|
+
Install `container` via Homebrew:
|
|
30
|
+
|
|
31
|
+
```sh
|
|
32
|
+
brew install apple/apple/container
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Then start the service and run tests:
|
|
36
|
+
|
|
37
|
+
```sh
|
|
38
|
+
container system start
|
|
39
|
+
npm test
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
To start the container service automatically at login:
|
|
43
|
+
|
|
44
|
+
```sh
|
|
45
|
+
cat > ~/Library/LaunchAgents/com.apple.container.start.plist << 'EOF'
|
|
46
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
47
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
48
|
+
<plist version="1.0">
|
|
49
|
+
<dict>
|
|
50
|
+
<key>Label</key>
|
|
51
|
+
<string>com.apple.container.start</string>
|
|
52
|
+
<key>ProgramArguments</key>
|
|
53
|
+
<array>
|
|
54
|
+
<string>/usr/local/bin/container</string>
|
|
55
|
+
<string>system</string>
|
|
56
|
+
<string>start</string>
|
|
57
|
+
</array>
|
|
58
|
+
<key>RunAtLoad</key>
|
|
59
|
+
<true/>
|
|
60
|
+
</dict>
|
|
61
|
+
</plist>
|
|
62
|
+
EOF
|
|
63
|
+
launchctl load ~/Library/LaunchAgents/com.apple.container.start.plist
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
**Linux** — uses Docker:
|
|
67
|
+
|
|
68
|
+
```sh
|
|
69
|
+
npm test
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
`npm run db:up` starts the container (skips if already running). `npm run db:down` stops and removes it.
|
|
73
|
+
|
|
23
74
|
## License
|
|
24
75
|
|
|
25
76
|
ISC
|
|
26
77
|
|
|
27
78
|
---
|
|
28
79
|
|
|
29
|
-
Revision:
|
|
80
|
+
Revision: March 23, 2026<br/>
|
|
30
81
|
By: Oleksandr Kravets (@alexkravets)
|
package/bin/db-down.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
'use strict';
|
|
4
|
+
|
|
5
|
+
const { execSync } = require('child_process');
|
|
6
|
+
|
|
7
|
+
const CONTAINER_NAME = 'dynamo';
|
|
8
|
+
|
|
9
|
+
const isMac = process.platform === 'darwin';
|
|
10
|
+
|
|
11
|
+
if (isMac) {
|
|
12
|
+
execSync(`container stop ${CONTAINER_NAME}`, { stdio: 'inherit' });
|
|
13
|
+
execSync(`container rm ${CONTAINER_NAME}`, { stdio: 'inherit' });
|
|
14
|
+
|
|
15
|
+
} else {
|
|
16
|
+
execSync(
|
|
17
|
+
'docker compose --project-name dos -f ./docker-compose.yaml down',
|
|
18
|
+
{ stdio: 'inherit' }
|
|
19
|
+
);
|
|
20
|
+
}
|
package/bin/db-up.js
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
'use strict';
|
|
4
|
+
|
|
5
|
+
const http = require('http');
|
|
6
|
+
const { execSync, spawnSync } = require('child_process');
|
|
7
|
+
|
|
8
|
+
const CONTAINER_NAME = 'dynamo';
|
|
9
|
+
const IMAGE = 'amazon/dynamodb-local:latest';
|
|
10
|
+
const DYNAMO_PORT = 8000;
|
|
11
|
+
|
|
12
|
+
const isMac = process.platform === 'darwin';
|
|
13
|
+
|
|
14
|
+
/** Resolves true when DynamoDB Local is accepting connections, false on timeout. */
|
|
15
|
+
const waitForDynamo = (timeout = 10000) => new Promise(resolve => {
|
|
16
|
+
const deadline = Date.now() + timeout;
|
|
17
|
+
|
|
18
|
+
const poll = () => {
|
|
19
|
+
const req = http.request({ hostname: 'localhost', port: DYNAMO_PORT, method: 'GET', path: '/' }, () => resolve(true));
|
|
20
|
+
req.on('error', () => {
|
|
21
|
+
if (Date.now() < deadline) setTimeout(poll, 100);
|
|
22
|
+
else resolve(false);
|
|
23
|
+
});
|
|
24
|
+
req.end();
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
poll();
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
const main = async () => {
|
|
31
|
+
if (isMac) {
|
|
32
|
+
const serviceCheck = spawnSync('container', ['system', 'status'], { encoding: 'utf8' });
|
|
33
|
+
const isServiceRunning = serviceCheck.stdout?.includes('running');
|
|
34
|
+
|
|
35
|
+
if (!isServiceRunning) {
|
|
36
|
+
console.error('Error: Apple container system service is not running.');
|
|
37
|
+
console.error('Start it with: container system start');
|
|
38
|
+
process.exit(1);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const result = spawnSync('container', ['inspect', CONTAINER_NAME], { encoding: 'utf8' });
|
|
42
|
+
const [info] = JSON.parse(result.stdout || '[]');
|
|
43
|
+
|
|
44
|
+
if (info) {
|
|
45
|
+
if (info.status === 'running') {
|
|
46
|
+
console.info(`Container "${CONTAINER_NAME}" is already running`);
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
execSync(`container rm ${CONTAINER_NAME}`, { stdio: 'inherit' });
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
execSync(
|
|
54
|
+
`container run --detach --name ${CONTAINER_NAME} --publish 8000:8000 ${IMAGE}`,
|
|
55
|
+
{ stdio: 'inherit' }
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
} else {
|
|
59
|
+
execSync(
|
|
60
|
+
'docker compose --project-name dos -f ./docker-compose.yaml up -d',
|
|
61
|
+
{ stdio: 'inherit' }
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const ready = await waitForDynamo();
|
|
66
|
+
|
|
67
|
+
if (!ready) {
|
|
68
|
+
console.error('Error: DynamoDB Local did not become ready in time.');
|
|
69
|
+
process.exit(1);
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
main();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getRawClientConfig.d.ts","sourceRoot":"","sources":["../../../../src/Table/helpers/getRawClientConfig.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAQrE,8CAA8C;AAC9C,QAAA,MAAM,kBAAkB,GAAI,QAAQ,MAAM,EAAE,SAAS,MAAM,KAAG,
|
|
1
|
+
{"version":3,"file":"getRawClientConfig.d.ts","sourceRoot":"","sources":["../../../../src/Table/helpers/getRawClientConfig.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAQrE,8CAA8C;AAC9C,QAAA,MAAM,kBAAkB,GAAI,QAAQ,MAAM,EAAE,SAAS,MAAM,KAAG,oBAiB7D,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
|
|
@@ -18,9 +18,9 @@ const getRawClientConfig = (region, profile) => {
|
|
|
18
18
|
/* istanbul ignore else */
|
|
19
19
|
if (isLocal) {
|
|
20
20
|
config.endpoint = LOCAL_ENDPOINT;
|
|
21
|
+
config.credentials = { accessKeyId: 'local', secretAccessKey: 'local' };
|
|
21
22
|
}
|
|
22
|
-
|
|
23
|
-
if (hasAwsCredentials) {
|
|
23
|
+
else if (hasAwsCredentials) {
|
|
24
24
|
config.credentials = (0, credential_providers_1.fromIni)({ profile });
|
|
25
25
|
}
|
|
26
26
|
return config;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getRawClientConfig.js","sourceRoot":"","sources":["../../../../src/Table/helpers/getRawClientConfig.ts"],"names":[],"mappings":";;AAAA,2BAA6B;AAC7B,wEAAwD;AACxD,2BAAgC;AAChC,uDAAiD;AAGjD,MAAM,IAAI,GAAG,IAAA,YAAO,GAAE,CAAC;AACvB,MAAM,iBAAiB,GAAG,IAAA,eAAU,EAAC,GAAG,IAAI,mBAAmB,CAAC,CAAC;AAEjE,MAAM,cAAc,GAAG,qBAAqB,CAAC;AAC7C,MAAM,oBAAoB,GAAG,EAAE,CAAC;AAEhC,8CAA8C;AAC9C,MAAM,kBAAkB,GAAG,CAAC,MAAc,EAAE,OAAe,EAAwB,EAAE;IACnF,MAAM,MAAM,GAAG;QACb,WAAW,EAAE,oBAAoB;QACjC,MAAM;KACiB,CAAC;IAE1B,MAAM,OAAO,GAAG,MAAM,KAAK,8BAAY,CAAC;IAExC,0BAA0B;IAC1B,IAAI,OAAO,EAAE,CAAC;QACZ,MAAM,CAAC,QAAQ,GAAG,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"getRawClientConfig.js","sourceRoot":"","sources":["../../../../src/Table/helpers/getRawClientConfig.ts"],"names":[],"mappings":";;AAAA,2BAA6B;AAC7B,wEAAwD;AACxD,2BAAgC;AAChC,uDAAiD;AAGjD,MAAM,IAAI,GAAG,IAAA,YAAO,GAAE,CAAC;AACvB,MAAM,iBAAiB,GAAG,IAAA,eAAU,EAAC,GAAG,IAAI,mBAAmB,CAAC,CAAC;AAEjE,MAAM,cAAc,GAAG,qBAAqB,CAAC;AAC7C,MAAM,oBAAoB,GAAG,EAAE,CAAC;AAEhC,8CAA8C;AAC9C,MAAM,kBAAkB,GAAG,CAAC,MAAc,EAAE,OAAe,EAAwB,EAAE;IACnF,MAAM,MAAM,GAAG;QACb,WAAW,EAAE,oBAAoB;QACjC,MAAM;KACiB,CAAC;IAE1B,MAAM,OAAO,GAAG,MAAM,KAAK,8BAAY,CAAC;IAExC,0BAA0B;IAC1B,IAAI,OAAO,EAAE,CAAC;QACZ,MAAM,CAAC,QAAQ,GAAG,cAAc,CAAC;QACjC,MAAM,CAAC,WAAW,GAAG,EAAE,WAAW,EAAE,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,CAAC;IAC1E,CAAC;SAAM,IAAI,iBAAiB,EAAE,CAAC;QAC7B,MAAM,CAAC,WAAW,GAAG,IAAA,8BAAO,EAAC,EAAE,OAAO,EAAE,CAAC,CAAC;IAC5C,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAEF,kBAAe,kBAAkB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kravc/dos-dynamodb",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "CRUD interface for DynamoDB table to be used with @kravc/dos service.",
|
|
5
5
|
"main": "dist/src/index.js",
|
|
6
6
|
"types": "dist/src/index.d.ts",
|
|
@@ -12,12 +12,13 @@
|
|
|
12
12
|
"src": "src"
|
|
13
13
|
},
|
|
14
14
|
"scripts": {
|
|
15
|
-
"test": "eslint --fix src/ example/ && npm run db:up &&
|
|
15
|
+
"test": "eslint --fix src/ example/ && npm run db:up && NODE_OPTIONS=--experimental-vm-modules jest --coverage",
|
|
16
16
|
"prebuild": "rimraf dist",
|
|
17
17
|
"build": "tsc",
|
|
18
18
|
"prepare": "npm run build",
|
|
19
19
|
"prepublishOnly": "npm run build",
|
|
20
|
-
"db:up": "
|
|
20
|
+
"db:up": "node bin/db-up.js",
|
|
21
|
+
"db:down": "node bin/db-down.js"
|
|
21
22
|
},
|
|
22
23
|
"bin": {
|
|
23
24
|
"table": "bin/table.js"
|
|
@@ -196,12 +196,12 @@ describe('Document', () => {
|
|
|
196
196
|
beforeAll(async () => {
|
|
197
197
|
await Asset.table.reset();
|
|
198
198
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
199
|
+
await Promise.all(
|
|
200
|
+
Array.from({ length: 600 + 15 }, (_, i) => createAsset({ name: `Text Document ${i + 1}` }))
|
|
201
|
+
);
|
|
202
202
|
|
|
203
203
|
await createActivity();
|
|
204
|
-
});
|
|
204
|
+
}, 30000);
|
|
205
205
|
|
|
206
206
|
describe('Document._indexAll(query, options)', () => {
|
|
207
207
|
it('gets all documents from a table', async () => {
|
|
@@ -22,10 +22,8 @@ const getRawClientConfig = (region: string, profile: string): DynamoDBClientConf
|
|
|
22
22
|
/* istanbul ignore else */
|
|
23
23
|
if (isLocal) {
|
|
24
24
|
config.endpoint = LOCAL_ENDPOINT;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
/* istanbul ignore else */
|
|
28
|
-
if (hasAwsCredentials) {
|
|
25
|
+
config.credentials = { accessKeyId: 'local', secretAccessKey: 'local' };
|
|
26
|
+
} else if (hasAwsCredentials) {
|
|
29
27
|
config.credentials = fromIni({ profile });
|
|
30
28
|
}
|
|
31
29
|
|