@opra/sqb 1.0.0-alpha.31 → 1.0.0-alpha.33

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.
@@ -33,14 +33,6 @@ class SqbCollectionService extends sqb_entity_service_js_1.SqbEntityService {
33
33
  if (!(await this.exists(id, options)))
34
34
  throw new common_1.ResourceNotAvailableError(this.getResourceName(), id);
35
35
  }
36
- /**
37
- * Creates a new resource
38
- *
39
- * @param {PartialDTO<T>} input - The input data
40
- * @param {SqbCollectionService.CreateOptions} [options] - The options object
41
- * @returns {Promise<PartialDTO<T>>} A promise that resolves to the created resource
42
- * @throws {Error} if an unknown error occurs while creating the resource
43
- */
44
36
  async create(input, options) {
45
37
  const command = {
46
38
  crud: 'create',
@@ -31,14 +31,6 @@ class SqbSingletonService extends sqb_entity_service_js_1.SqbEntityService {
31
31
  if (!(await this.exists(options)))
32
32
  throw new common_1.ResourceNotAvailableError(this.getResourceName());
33
33
  }
34
- /**
35
- * Inserts a single record into the database.
36
- *
37
- * @param {PartialDTO<T>} input - The input data
38
- * @param {SqbSingletonService.CreateOptions} [options] - The options object
39
- * @returns {Promise<PartialDTO<T>>} A promise that resolves to the created resource
40
- * @throws {Error} if an unknown error occurs while creating the resource
41
- */
42
34
  async create(input, options) {
43
35
  const command = {
44
36
  crud: 'create',
@@ -104,12 +96,6 @@ class SqbSingletonService extends sqb_entity_service_js_1.SqbEntityService {
104
96
  return this._exists(command);
105
97
  });
106
98
  }
107
- /**
108
- * Finds the singleton record. Returns `undefined` if not found
109
- *
110
- * @param {SqbSingletonService.FindOneOptions} options - The options for the query.
111
- * @return {Promise<PartialDTO<T> | undefined>} A promise that resolves with the found document or undefined if no document is found.
112
- */
113
99
  async find(options) {
114
100
  const command = {
115
101
  crud: 'read',
@@ -124,28 +110,12 @@ class SqbSingletonService extends sqb_entity_service_js_1.SqbEntityService {
124
110
  return this._findById(command);
125
111
  });
126
112
  }
127
- /**
128
- * Retrieves the singleton record. Throws error if not found.
129
- *
130
- * @param {SqbSingletonService.FindOptions} [options] - Optional options for the `find` operation.
131
- * @returns {Promise<PartialDTO<T>>} - A promise that resolves to the retrieved document,
132
- * or rejects with a ResourceNotFoundError if the document does not exist.
133
- * @throws {ResourceNotAvailableError} - If the document does not exist.
134
- */
135
113
  async get(options) {
136
114
  const out = await this.find(options);
137
115
  if (!out)
138
116
  throw new common_1.ResourceNotAvailableError(this.getResourceName());
139
117
  return out;
140
118
  }
141
- /**
142
- * Updates the singleton.
143
- *
144
- * @param {PatchDTO<T>} input - The partial input object containing the fields to update.
145
- * @param {SqbSingletonService.UpdateOptions} [options] - The options for the update operation.
146
- * @returns {Promise<PartialDTO<T> | undefined>} A promise that resolves to the updated document or
147
- * undefined if the document was not found.
148
- */
149
119
  async update(input, options) {
150
120
  const command = {
151
121
  crud: 'update',
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "module"
3
+ }
@@ -30,14 +30,6 @@ export class SqbCollectionService extends SqbEntityService {
30
30
  if (!(await this.exists(id, options)))
31
31
  throw new ResourceNotAvailableError(this.getResourceName(), id);
32
32
  }
33
- /**
34
- * Creates a new resource
35
- *
36
- * @param {PartialDTO<T>} input - The input data
37
- * @param {SqbCollectionService.CreateOptions} [options] - The options object
38
- * @returns {Promise<PartialDTO<T>>} A promise that resolves to the created resource
39
- * @throws {Error} if an unknown error occurs while creating the resource
40
- */
41
33
  async create(input, options) {
42
34
  const command = {
43
35
  crud: 'create',
@@ -28,14 +28,6 @@ export class SqbSingletonService extends SqbEntityService {
28
28
  if (!(await this.exists(options)))
29
29
  throw new ResourceNotAvailableError(this.getResourceName());
30
30
  }
31
- /**
32
- * Inserts a single record into the database.
33
- *
34
- * @param {PartialDTO<T>} input - The input data
35
- * @param {SqbSingletonService.CreateOptions} [options] - The options object
36
- * @returns {Promise<PartialDTO<T>>} A promise that resolves to the created resource
37
- * @throws {Error} if an unknown error occurs while creating the resource
38
- */
39
31
  async create(input, options) {
40
32
  const command = {
41
33
  crud: 'create',
@@ -101,12 +93,6 @@ export class SqbSingletonService extends SqbEntityService {
101
93
  return this._exists(command);
102
94
  });
103
95
  }
104
- /**
105
- * Finds the singleton record. Returns `undefined` if not found
106
- *
107
- * @param {SqbSingletonService.FindOneOptions} options - The options for the query.
108
- * @return {Promise<PartialDTO<T> | undefined>} A promise that resolves with the found document or undefined if no document is found.
109
- */
110
96
  async find(options) {
111
97
  const command = {
112
98
  crud: 'read',
@@ -121,28 +107,12 @@ export class SqbSingletonService extends SqbEntityService {
121
107
  return this._findById(command);
122
108
  });
123
109
  }
124
- /**
125
- * Retrieves the singleton record. Throws error if not found.
126
- *
127
- * @param {SqbSingletonService.FindOptions} [options] - Optional options for the `find` operation.
128
- * @returns {Promise<PartialDTO<T>>} - A promise that resolves to the retrieved document,
129
- * or rejects with a ResourceNotFoundError if the document does not exist.
130
- * @throws {ResourceNotAvailableError} - If the document does not exist.
131
- */
132
110
  async get(options) {
133
111
  const out = await this.find(options);
134
112
  if (!out)
135
113
  throw new ResourceNotAvailableError(this.getResourceName());
136
114
  return out;
137
115
  }
138
- /**
139
- * Updates the singleton.
140
- *
141
- * @param {PatchDTO<T>} input - The partial input object containing the fields to update.
142
- * @param {SqbSingletonService.UpdateOptions} [options] - The options for the update operation.
143
- * @returns {Promise<PartialDTO<T> | undefined>} A promise that resolves to the updated document or
144
- * undefined if the document was not found.
145
- */
146
116
  async update(input, options) {
147
117
  const command = {
148
118
  crud: 'update',
package/package.json CHANGED
@@ -1,52 +1,41 @@
1
1
  {
2
2
  "name": "@opra/sqb",
3
- "version": "1.0.0-alpha.31",
3
+ "version": "1.0.0-alpha.33",
4
4
  "description": "Opra SQB adapter package",
5
5
  "author": "Panates",
6
6
  "license": "MIT",
7
- "repository": {
8
- "type": "git",
9
- "url": "https://github.com/panates/opra.git",
10
- "directory": "packages/sqb"
11
- },
12
- "scripts": {
13
- "compile": "tsc",
14
- "prebuild": "npm run lint && npm run clean",
15
- "build": "npm run build:cjs && npm run build:esm",
16
- "build:cjs": "tsc -b tsconfig-build-cjs.json",
17
- "build:esm": "tsc -b tsconfig-build-esm.json",
18
- "postbuild": "cp README.md package.json ../../LICENSE ../../build/sqb && cp ../../package.cjs.json ../../build/sqb/cjs/package.json",
19
- "lint": "eslint . --max-warnings=0",
20
- "lint:fix": "eslint . --max-warnings=0 --fix",
21
- "format": "prettier . --write --log-level=warn",
22
- "test": "jest --passWithNoTests",
23
- "cover": "jest --passWithNoTests --collect-coverage",
24
- "clean": "npm run clean:src && npm run clean:test && npm run clean:dist && npm run clean:cover",
25
- "clean:src": "ts-cleanup -s src --all",
26
- "clean:test": "ts-cleanup -s test --all",
27
- "clean:dist": "rimraf ../../build/client",
28
- "clean:cover": "rimraf ../../coverage/client"
29
- },
30
7
  "dependencies": {
31
8
  "reflect-metadata": "^0.2.2",
32
- "tslib": "^2.6.3"
33
- },
34
- "devDependencies": {
35
- "@faker-js/faker": "^8.4.1",
36
- "@sqb/builder": "^4.14.0",
37
- "@sqb/connect": "^4.14.0",
38
- "@sqb/postgres": "^4.14.0",
39
- "postgrejs": "^2.15.4",
40
- "ts-gems": "^3.4.0"
9
+ "tslib": "^2.6.3",
10
+ "valgen": "^5.8.2"
41
11
  },
42
12
  "peerDependencies": {
43
- "@opra/core": "^1.0.0-alpha.31",
13
+ "@opra/core": "^1.0.0-alpha.33",
44
14
  "@sqb/connect": ">= 4.10.6"
45
15
  },
46
16
  "type": "module",
47
- "module": "./esm/index.js",
17
+ "exports": {
18
+ ".": {
19
+ "import": {
20
+ "types": "./types/index.d.ts",
21
+ "default": "./esm/index.js"
22
+ },
23
+ "require": {
24
+ "types": "./types/index.d.ts",
25
+ "default": "./cjs/index.js"
26
+ },
27
+ "default": "./esm/index.js"
28
+ },
29
+ "./package.json": "./package.json"
30
+ },
48
31
  "main": "./cjs/index.js",
32
+ "module": "./esm/index.js",
49
33
  "types": "./types/index.d.ts",
34
+ "repository": {
35
+ "type": "git",
36
+ "url": "https://github.com/panates/opra.git",
37
+ "directory": "packages/sqb"
38
+ },
50
39
  "engines": {
51
40
  "node": ">=16.0",
52
41
  "npm": ">=7.0.0"
@@ -64,4 +53,4 @@
64
53
  "sqb",
65
54
  "adapter"
66
55
  ]
67
- }
56
+ }
@@ -1,4 +1,4 @@
1
- import { PartialDTO, PatchDTO, Type } from 'ts-gems';
1
+ import { PartialDTO, PatchDTO, RequiredSome, Type } from 'ts-gems';
2
2
  import { SQBAdapter } from './sqb-adapter.js';
3
3
  import { SqbEntityService } from './sqb-entity-service.js';
4
4
  /**
@@ -122,7 +122,8 @@ export declare abstract class SqbCollectionService<T extends object = object> ex
122
122
  * @returns {Promise<PartialDTO<T>>} A promise that resolves to the created resource
123
123
  * @throws {Error} if an unknown error occurs while creating the resource
124
124
  */
125
- create(input: PartialDTO<T>, options?: SqbCollectionService.CreateOptions): Promise<PartialDTO<T>>;
125
+ create(input: PartialDTO<T>, options: RequiredSome<SqbCollectionService.CreateOptions, 'projection'>): Promise<PartialDTO<T>>;
126
+ create(input: PartialDTO<T>, options?: SqbCollectionService.CreateOptions): Promise<T>;
126
127
  /**
127
128
  * Returns the count of records based on the provided options
128
129
  *
@@ -1,4 +1,4 @@
1
- import { PartialDTO, PatchDTO, Type } from 'ts-gems';
1
+ import { PartialDTO, PatchDTO, RequiredSome, Type } from 'ts-gems';
2
2
  import { SQBAdapter } from './sqb-adapter.js';
3
3
  import { SqbEntityService } from './sqb-entity-service.js';
4
4
  /**
@@ -84,7 +84,8 @@ export declare abstract class SqbSingletonService<T extends object = object> ext
84
84
  * @returns {Promise<PartialDTO<T>>} A promise that resolves to the created resource
85
85
  * @throws {Error} if an unknown error occurs while creating the resource
86
86
  */
87
- create(input: PartialDTO<T>, options?: SqbSingletonService.CreateOptions): Promise<PartialDTO<T>>;
87
+ create(input: PartialDTO<T>, options: RequiredSome<SqbSingletonService.CreateOptions, 'projection'>): Promise<PartialDTO<T>>;
88
+ create(input: PartialDTO<T>, options?: SqbSingletonService.CreateOptions): Promise<T>;
88
89
  /**
89
90
  * Deletes the singleton record
90
91
  *
@@ -105,7 +106,8 @@ export declare abstract class SqbSingletonService<T extends object = object> ext
105
106
  * @param {SqbSingletonService.FindOneOptions} options - The options for the query.
106
107
  * @return {Promise<PartialDTO<T> | undefined>} A promise that resolves with the found document or undefined if no document is found.
107
108
  */
108
- find(options?: SqbSingletonService.FindOptions): Promise<PartialDTO<T> | undefined>;
109
+ find(options: RequiredSome<SqbSingletonService.FindOptions, 'projection'>): Promise<PartialDTO<T> | undefined>;
110
+ find(options?: SqbSingletonService.FindOptions): Promise<T | undefined>;
109
111
  /**
110
112
  * Retrieves the singleton record. Throws error if not found.
111
113
  *
@@ -114,7 +116,8 @@ export declare abstract class SqbSingletonService<T extends object = object> ext
114
116
  * or rejects with a ResourceNotFoundError if the document does not exist.
115
117
  * @throws {ResourceNotAvailableError} - If the document does not exist.
116
118
  */
117
- get(options?: SqbSingletonService.FindOptions): Promise<PartialDTO<T>>;
119
+ get(options: RequiredSome<SqbSingletonService.FindOptions, 'projection'>): Promise<PartialDTO<T>>;
120
+ get(options?: SqbSingletonService.FindOptions): Promise<T>;
118
121
  /**
119
122
  * Updates the singleton.
120
123
  *
@@ -123,7 +126,8 @@ export declare abstract class SqbSingletonService<T extends object = object> ext
123
126
  * @returns {Promise<PartialDTO<T> | undefined>} A promise that resolves to the updated document or
124
127
  * undefined if the document was not found.
125
128
  */
126
- update(input: PatchDTO<T>, options?: SqbSingletonService.UpdateOptions): Promise<PartialDTO<T> | undefined>;
129
+ update(input: PatchDTO<T>, options: RequiredSome<SqbSingletonService.UpdateOptions, 'projection'>): Promise<PartialDTO<T> | undefined>;
130
+ update(input: PatchDTO<T>, options?: SqbSingletonService.UpdateOptions): Promise<T | undefined>;
127
131
  /**
128
132
  * Updates the singleton and returns updated record count
129
133
  *