@cap-js/cds-types 0.1.0 → 0.2.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/apis/test.d.ts CHANGED
@@ -1,68 +1,91 @@
1
- import { AxiosInstance } from 'axios';
2
- import chai from 'chai';
3
- import * as http from 'http';
4
- import { Service } from './services';
1
+ import { AxiosInstance } from 'axios'
2
+ import chai from 'chai'
3
+ import * as http from 'http'
4
+ import { Service } from './services'
5
5
  import * as cds from './cds'
6
6
 
7
7
  type _cds = typeof cds
8
8
 
9
9
  declare class Axios {
10
- get axios(): AxiosInstance;
11
-
12
- get : AxiosInstance['get'];
13
- put : AxiosInstance['put'];
14
- post : AxiosInstance['post'];
15
- patch : AxiosInstance['patch'];
16
- delete : AxiosInstance['delete'];
17
- options : AxiosInstance['options'];
18
-
19
- get GET() : Axios['get'];
20
- get PUT() : Axios['put'];
21
- get POST() : Axios['post'];
22
- get PATCH() : Axios['patch'];
23
- get DELETE() : Axios['delete'];
24
- get OPTIONS() : Axios['options'];
10
+
11
+ get axios (): AxiosInstance
12
+ get: AxiosInstance['get'];
13
+
14
+ put: AxiosInstance['put']
15
+
16
+ post: AxiosInstance['post']
17
+
18
+ patch: AxiosInstance['patch']
19
+
20
+ delete: AxiosInstance['delete']
21
+
22
+ options: AxiosInstance['options']
23
+
24
+ get GET (): Axios['get']
25
+
26
+ get PUT (): Axios['put']
27
+
28
+ get POST (): Axios['post']
29
+
30
+ get PATCH (): Axios['patch']
31
+
32
+ get DELETE (): Axios['delete']
33
+
34
+ get OPTIONS (): Axios['options']
35
+
25
36
  }
26
37
 
27
38
  declare class DataUtil {
28
- delete(db?: Service): Promise<void>;
29
- reset(db?: Service): Promise<void>;
39
+
40
+ delete (db?: Service): Promise<void>
41
+
42
+ reset (db?: Service): Promise<void>
43
+
30
44
  /**
31
45
  * @deprecated if needed, call `reset()`, considering test performance
32
46
  */
33
- autoReset(enabled: boolean): this;
47
+ autoReset (enabled: boolean): this
48
+
34
49
  }
35
50
 
36
51
  declare class Test extends Axios {
37
52
 
38
- test : Test
53
+ test: Test
54
+
55
+ run (cmd: string, ...args: string[]): this
56
+
57
+ in (...paths: string[]): this
58
+
59
+ silent (): this
39
60
 
40
- run(cmd: string, ...args: string[]): this;
41
- in(...paths: string[]): this;
42
- silent(): this;
43
61
  /**
44
62
  * @deprecated Server log is shown by default. Use `log()` to get control over it.
45
63
  */
46
- verbose(v: boolean): this;
47
-
48
- get chai(): typeof chai;
49
- get expect(): typeof chai.expect;
50
- get assert(): typeof chai.assert;
51
- get data(): DataUtil;
52
- get cds(): _cds
53
-
54
- log() : {
55
- output: string
56
- clear(): void
57
- release(): void
64
+ verbose (v: boolean): this
65
+
66
+ get chai (): typeof chai
67
+
68
+ get expect (): typeof chai.expect
69
+
70
+ get assert (): typeof chai.assert
71
+
72
+ get data (): DataUtil
73
+
74
+ get cds (): _cds
75
+
76
+ log (): {
77
+ output: string,
78
+ clear(): void,
79
+ release(): void,
58
80
  }
59
81
 
60
- then(r: (args: { server: http.Server, url: string }) => void): void;
82
+ then (r: (args: { server: http.Server, url: string }) => void): void
61
83
 
62
84
  // get sleep(): (ms: number) => Promise<void>;
63
85
  // get spy(): <T, K extends keyof T>(o: T, f: K) => T[K] extends (...args: infer TArgs) => infer TReturnValue
64
86
  // ? Spy<TArgs, TReturnValue>
65
87
  // : Spy;
88
+
66
89
  }
67
90
 
68
91
  // typings for spy inspired by @types/sinon
@@ -73,15 +96,17 @@ declare class Test extends Axios {
73
96
  // }
74
97
 
75
98
  declare const test: {
76
- Test: typeof Test
77
- /**
99
+ Test: typeof Test,
100
+
101
+ /**
78
102
  * @see [capire docs](https://cap.cloud.sap/docs/node.js/cds-test#class-cds-test-test)
79
103
  */
80
- (dirname: string): Test;
81
- /**
104
+ (dirname: string): Test,
105
+
106
+ /**
82
107
  * @see [capire docs](https://cap.cloud.sap/docs/node.js/cds-test#class-cds-test-test)
83
108
  */
84
- (command: string, ...args: string[]): Test;
109
+ (command: string, ...args: string[]): Test,
85
110
 
86
- in (dirname: string) : Test
111
+ in (dirname: string): Test,
87
112
  }
package/apis/utils.d.ts CHANGED
@@ -3,87 +3,88 @@ import * as fs from 'node:fs'
3
3
  /**
4
4
  * Provides a set of utility functionss
5
5
  */
6
- declare const utils : {
7
- /**
6
+ declare const utils: {
7
+
8
+ /**
8
9
  * Generates a new v4 UUID
9
10
  * @see https://cap.cloud.sap/docs/node.js/cds-facade#cds-utils
10
11
  */
11
- uuid () : string
12
+ uuid (): string,
12
13
 
13
- /**
14
+ /**
14
15
  * @see https://cap.cloud.sap/docs/node.js/cds-utils#decodeuri
15
16
  */
16
- decodeURI(input: string): string
17
+ decodeURI(input: string): string,
17
18
 
18
- /**
19
+ /**
19
20
  * @see https://cap.cloud.sap/docs/node.js/cds-utils#decodeuricomponent
20
21
  */
21
- decodeURIComponent(input: string): string
22
+ decodeURIComponent(input: string): string,
22
23
 
23
- /**
24
+ /**
24
25
  * @see https://cap.cloud.sap/docs/node.js/cds-utils#local-filename
25
26
  */
26
- local(filename: string): string
27
+ local(filename: string): string,
27
28
 
28
- /**
29
+ /**
29
30
  * @see https://cap.cloud.sap/docs/node.js/cds-utils#exists-file
30
31
  */
31
- exist(file: string): boolean
32
+ exist(file: string): boolean,
32
33
 
33
- /**
34
+ /**
34
35
  * @see https://cap.cloud.sap/docs/node.js/cds-utils#isdir-file
35
36
  */
36
- isdir(file: string): string
37
+ isdir(file: string): string,
37
38
 
38
- /**
39
+ /**
39
40
  * @see https://cap.cloud.sap/docs/node.js/cds-utils#isdir-file
40
41
  */
41
- isfile(file: string): string
42
+ isfile(file: string): string,
42
43
 
43
- /**
44
+ /**
44
45
  * @see https://cap.cloud.sap/docs/node.js/cds-utils#async-read-file
45
46
  */
46
- read(file: string): Promise<Buffer | {}>
47
+ read(file: string): Promise<Buffer | object>,
47
48
 
48
- /**
49
+ /**
49
50
  * @see https://cap.cloud.sap/docs/node.js/cds-utils#async-write-data-to-file
50
51
  */
51
- write: {
52
- (data: Object): {
53
- to(...file: string[]): Promise<ReturnType<typeof fs.promises.writeFile>>
54
- }
55
- (file: string, data: Object): Promise<ReturnType<typeof fs.promises.writeFile>>
56
- }
57
-
58
- /**
52
+ write: {
53
+ (data: object): {
54
+ to(...file: string[]): Promise<ReturnType<typeof fs.promises.writeFile>>,
55
+ },
56
+ (file: string, data: object): Promise<ReturnType<typeof fs.promises.writeFile>>,
57
+ },
58
+
59
+ /**
59
60
  * @see https://cap.cloud.sap/docs/node.js/cds-utils#async-copy-src-to-dst
60
61
  */
61
- copy: {
62
- (src: string): {
63
- to(...dst: string[]): Promise<ReturnType<typeof fs.promises.copyFile>>
64
- }
65
- (dst: string, src: string): Promise<ReturnType<typeof fs.promises.copyFile>>
66
- }
67
-
68
- /**
62
+ copy: {
63
+ (src: string): {
64
+ to(...dst: string[]): Promise<ReturnType<typeof fs.promises.copyFile>>,
65
+ },
66
+ (dst: string, src: string): Promise<ReturnType<typeof fs.promises.copyFile>>,
67
+ },
68
+
69
+ /**
69
70
  * @see https://cap.cloud.sap/docs/node.js/cds-utils#async-mkdirp-path
70
71
  */
71
- mkdirp: (...path: string[]) => Promise<string>
72
-
73
- /**
72
+ mkdirp: (...path: string[]) => Promise<string>,
73
+
74
+ /**
74
75
  * @see https://cap.cloud.sap/docs/node.js/cds-utils#async-rmdir-path
75
76
  */
76
- rmdir: (...path: string[]) => Promise<ReturnType<typeof fs.promises.rm>>
77
-
77
+ rmdir: (...path: string[]) => Promise<ReturnType<typeof fs.promises.rm>>,
78
+
78
79
 
79
- /**
80
+ /**
80
81
  * @see https://cap.cloud.sap/docs/node.js/cds-utils#async-rimraf-path
81
82
  */
82
- rimraf: (...path: string[]) => Promise<ReturnType<typeof fs.promises.rm>>
83
-
83
+ rimraf: (...path: string[]) => Promise<ReturnType<typeof fs.promises.rm>>,
84
+
84
85
 
85
- /**
86
+ /**
86
87
  * @see https://cap.cloud.sap/docs/node.js/cds-utils#async-rm-path
87
88
  */
88
- rm: (...path: string[]) => Promise<ReturnType<typeof fs.promises.rm>>
89
+ rm: (...path: string[]) => Promise<ReturnType<typeof fs.promises.rm>>,
89
90
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cap-js/cds-types",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Type definitions for main packages of CAP, like `@sap/cds`",
5
5
  "repository": "github:cap-js/cds-types",
6
6
  "homepage": "https://cap.cloud.sap/",
@@ -19,16 +19,24 @@
19
19
  ],
20
20
  "scripts": {
21
21
  "test": "jest --silent",
22
- "api-extractor": "api-extractor run --local --verbose"
22
+ "api-extractor": "api-extractor run --local --verbose",
23
+ "lint": "eslint . --ext .ts",
24
+ "lint:fix": "eslint . --ext .ts --fix",
25
+ "setup": "npm i && npm i file:. --no-save --force"
23
26
  },
24
27
  "peerDependencies": {
25
28
  "@sap/cds": ">=7"
26
29
  },
27
30
  "devDependencies": {
28
- "@sap/cds": "^7.4.0",
31
+ "@sap/cds": "^7.5.0",
32
+ "@stylistic/eslint-plugin": "^1.5.3",
33
+ "@types/jest": "^29.5.11",
29
34
  "@types/node": "^20",
35
+ "@typescript-eslint/eslint-plugin": "^6.18.1",
36
+ "@typescript-eslint/parser": "^6.18.1",
30
37
  "axios": "^1.6.2",
31
38
  "chai": "^4.3.10",
39
+ "eslint": "^8.56.0",
32
40
  "jest": "^29.7.0",
33
41
  "ts-jest": "^29.1.1",
34
42
  "typescript": "^5.3.2",