@kravc/dos-dynamodb 1.0.0 → 1.0.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/README.md CHANGED
@@ -26,6 +26,14 @@ Tests require DynamoDB Local to be running on port 8000.
26
26
 
27
27
  **macOS** — uses [apple/container](https://github.com/apple/container) (requires macOS 26+):
28
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
+
29
37
  ```sh
30
38
  container system start
31
39
  npm test
package/bin/db-up.js CHANGED
@@ -30,7 +30,7 @@ const waitForDynamo = (timeout = 10000) => new Promise(resolve => {
30
30
  const main = async () => {
31
31
  if (isMac) {
32
32
  const serviceCheck = spawnSync('container', ['system', 'status'], { encoding: 'utf8' });
33
- const isServiceRunning = serviceCheck.stdout?.includes('is running');
33
+ const isServiceRunning = serviceCheck.stdout?.includes('running');
34
34
 
35
35
  if (!isServiceRunning) {
36
36
  console.error('Error: Apple container system service is not running.');
@@ -39,10 +39,9 @@ const main = async () => {
39
39
  }
40
40
 
41
41
  const result = spawnSync('container', ['inspect', CONTAINER_NAME], { encoding: 'utf8' });
42
+ const [info] = JSON.parse(result.stdout || '[]');
42
43
 
43
- if (result.status === 0) {
44
- const [info] = JSON.parse(result.stdout);
45
-
44
+ if (info) {
46
45
  if (info.status === 'running') {
47
46
  console.info(`Container "${CONTAINER_NAME}" is already running`);
48
47
  return;
package/bin/table.js CHANGED
@@ -71,12 +71,33 @@ const _reset = async () => {
71
71
  await _create();
72
72
  };
73
73
 
74
- /** Starts dynamodb in the Docker and runs a command. */
74
+ const isMac = process.platform === 'darwin';
75
+ const CONTAINER_NAME = 'dynamo';
76
+ const IMAGE = 'amazon/dynamodb-local:latest';
77
+
78
+ /** Starts dynamodb and runs a command. */
75
79
  const run = async callback => {
76
80
  if (env) {
77
81
  return callback();
78
82
  }
79
83
 
84
+ if (isMac) {
85
+ const { spawnSync, execSync } = require('child_process');
86
+
87
+ const [info] = JSON.parse(spawnSync('container', ['inspect', CONTAINER_NAME], { encoding: 'utf8' }).stdout || '[]');
88
+
89
+ if (info) {
90
+ if (info.status === 'running') {
91
+ return callback();
92
+ }
93
+
94
+ execSync(`container rm ${CONTAINER_NAME}`, { stdio: 'inherit' });
95
+ }
96
+
97
+ execSync(`container run --detach --name ${CONTAINER_NAME} --publish 8000:8000 ${IMAGE}`, { stdio: 'inherit' });
98
+ return callback();
99
+ }
100
+
80
101
  const command = exec('docker compose --project-name dos -f node_modules/@kravc/dos-dynamodb/docker-compose.yaml up -d', callback);
81
102
  command.stdout.on('data', data => console.log(data));
82
103
  command.stderr.on('data', data => console.error(data));
@@ -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,oBAmB7D,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
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
- /* istanbul ignore else */
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;IACnC,CAAC;IAED,0BAA0B;IAC1B,IAAI,iBAAiB,EAAE,CAAC;QACtB,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"}
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.0",
3
+ "version": "1.0.2",
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",
@@ -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