@yamf/services-postgres 0.1.2 → 0.9.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2017 mcbrumagin
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Postgres.js wrapper for YAMF: parameterized SQL templates, camelCase result mapping, and safe placeholder validation.
4
4
 
5
- [![Node](https://img.shields.io/badge/node-%3E%3D20.0.0-brightgreen)]()
5
+ [![Node](https://img.shields.io/badge/node-%3E%3D22.0.0-brightgreen)]()
6
6
  [![License](https://img.shields.io/badge/license-MIT-blue)]()
7
7
 
8
8
  ## Installation
@@ -17,18 +17,18 @@ Peer dependencies: `@yamf/core`, `@yamf/shared`. The package uses [postgres](htt
17
17
 
18
18
  ```javascript
19
19
  import { registryServer, createService, callService } from '@yamf/core'
20
- import createPostgreSqlService from '@yamf/services-postgres'
20
+ import createPostgresService from '@yamf/services-postgres'
21
21
 
22
22
  await registryServer()
23
23
 
24
- const postgres = await createPostgreSqlService({
25
- serviceName: 'postgres-service',
24
+ const postgres = await createPostgresService({
25
+ serviceName: 'postgres',
26
26
  psqlConfig: 'postgres://user:pass@localhost/dbname'
27
27
  // or: { PGDATABASE: 'yamf', PGUSER: 'yamf', PGPASSWORD: 'changeme' }
28
28
  })
29
29
 
30
30
  // Call from another service or gateway
31
- const [row] = await callService('postgres-service', {
31
+ const [row] = await callService('postgres', {
32
32
  template: `SELECT user_id, username, is_active FROM yamf.user WHERE username = :username`,
33
33
  data: { username: 'alice@example.com' }
34
34
  })
@@ -44,11 +44,11 @@ const [row] = await callService('postgres-service', {
44
44
 
45
45
  ## API
46
46
 
47
- ### `createPostgreSqlService(options)`
47
+ ### `createPostgresService(options)`
48
48
 
49
49
  | Option | Default | Description |
50
50
  |---------------|---------------------|-------------|
51
- | `serviceName` | `'postgres-service'` | YAMF service name to register. |
51
+ | `serviceName` | `'postgres'` | YAMF service name to register. |
52
52
  | `psqlConfig` | env / `{ PGDATABASE, PGUSER, PGPASSWORD }` | Postgres connection string or config object. |
53
53
  | `schema` | `null` | Optional schema setup. |
54
54
  | `seed` | `null` | Optional seed logic. |
@@ -72,7 +72,7 @@ Returns the result of the query (array of rows, or raw result from postgres.js).
72
72
  Example:
73
73
 
74
74
  ```javascript
75
- await callService('postgres-service', {
75
+ await callService('postgres', {
76
76
  template: `
77
77
  SELECT user_id, username, is_registered, is_active
78
78
  FROM yamf.user
package/package.json CHANGED
@@ -1,8 +1,11 @@
1
1
  {
2
2
  "name": "@yamf/services-postgres",
3
- "version": "0.1.2",
3
+ "version": "0.9.0",
4
4
  "description": "",
5
- "license": "ISC",
5
+ "license": "MIT",
6
+ "engines": {
7
+ "node": ">=22.0.0"
8
+ },
6
9
  "author": "",
7
10
  "type": "module",
8
11
  "main": "service.js",
@@ -14,14 +17,15 @@
14
17
  "postgres": "^3.4.8"
15
18
  },
16
19
  "peerDependencies": {
17
- "@yamf/core": "0.4.0",
18
- "@yamf/shared": "0.1.2"
20
+ "@yamf/shared": "0.9.0",
21
+ "@yamf/core": "0.9.0"
19
22
  },
20
23
  "devDependencies": {
21
- "@yamf/cli": "0.2.0",
22
- "@yamf/test": "0.1.4"
24
+ "@yamf/cli": "0.9.0",
25
+ "@yamf/test": "0.9.0"
23
26
  },
24
27
  "scripts": {
25
- "test": "yamf test -d ."
28
+ "test": "echo 'No unit tests for postgres wrapper service' && exit 0",
29
+ "test:all": "yamf test -d . --include-e2e"
26
30
  }
27
31
  }
package/service.js CHANGED
@@ -28,12 +28,13 @@ function validatePlaceholderName(name) {
28
28
  return true
29
29
  }
30
30
 
31
- export default async function createPostgreSqlService({
32
- serviceName = 'postgres-service',
31
+ export default async function createPostgresService ({
32
+ serviceName = 'postgres',
33
+
33
34
  psqlConfig = defaultPsqlConfig,
34
35
  schema = null,
35
36
  seed = null
36
- }) {
37
+ } = {}) {
37
38
  const sql = postgres(psqlConfig) // psql environment variables
38
39
 
39
40
  /**