tering-serieuze-sdk 3.11.0 → 3.13.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/src/index.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { AbstractCache, NullCache } from './cache';
2
- import { AuthModule, JingleModule, K8sModule, UserModule } from './api';
3
1
  import type { Dto } from 'tering-serieuze-types';
2
+ import { AuthModule, JingleModule, K8sModule, UserModule } from './api';
3
+ import { AbstractCache, NullCache } from './cache';
4
4
 
5
5
  export * from './api';
6
6
  export * from './cache';
@@ -27,7 +27,10 @@ export type CacheConfiguration = {
27
27
  };
28
28
 
29
29
  export class ErrorResponse extends Error {
30
- constructor(public readonly status: number, public readonly message: string) {
30
+ constructor(
31
+ public readonly status: number,
32
+ public readonly message: string,
33
+ ) {
31
34
  super();
32
35
  }
33
36
  }
@@ -38,7 +41,10 @@ export class TssApi {
38
41
  k8s: K8sModule;
39
42
  user: UserModule;
40
43
 
41
- constructor(protected readonly apiConfiguration: ApiConfiguration, cacheConfiguration?: CacheConfiguration) {
44
+ constructor(
45
+ protected readonly apiConfiguration: ApiConfiguration,
46
+ cacheConfiguration?: CacheConfiguration,
47
+ ) {
42
48
  this.jingle = new JingleModule(this, cacheConfiguration?.jingle ?? new NullCache('jingle'));
43
49
  this.auth = new AuthModule(this, cacheConfiguration?.auth ?? new NullCache('auth'));
44
50
  this.k8s = new K8sModule(this, cacheConfiguration?.k8s ?? new NullCache('k8s'));
@@ -67,10 +73,10 @@ export class TssApi {
67
73
  const fullUrl = `${apiPrefix}/api/${url}`;
68
74
  console.log('Fetching url', fullUrl);
69
75
 
70
- let response;
76
+ let response: Response;
71
77
  try {
72
78
  response = await fetch(fullUrl, config);
73
- } catch (e) {
79
+ } catch (_e) {
74
80
  throw new ErrorResponse(503, 'API erg dood');
75
81
  }
76
82
 
@@ -82,12 +88,7 @@ export class TssApi {
82
88
  return response;
83
89
  }
84
90
 
85
- protected async fetchPossibleEmptyResponse<T>(
86
- method: HttpMethod,
87
- url: string,
88
- dto: Dto,
89
- config: SDKRequestInit = {},
90
- ) {
91
+ protected fetchPossibleEmptyResponse(method: HttpMethod, url: string, dto: Dto, config: SDKRequestInit = {}) {
91
92
  return this.fetch(url, {
92
93
  method,
93
94
  ...config,
@@ -95,36 +96,36 @@ export class TssApi {
95
96
  });
96
97
  }
97
98
 
98
- async get<T>(url: string) {
99
+ async get<T>(url: string): Promise<T> {
99
100
  const response = await this.fetch(url);
100
- return response.json() as Promise<T>;
101
+ return (await response.json()) as Promise<T>;
101
102
  }
102
103
 
103
104
  async post<T>(url: string, dto: Dto, config: SDKRequestInit = {}) {
104
- const response = await this.fetchPossibleEmptyResponse<T>('POST', url, dto, config);
105
+ const response = await this.fetchPossibleEmptyResponse('POST', url, dto, config);
105
106
  if (response === undefined) {
106
107
  throw new Error('Response was undefined');
107
108
  }
108
109
  return (await response.json()) as Promise<T>;
109
110
  }
110
111
 
111
- async postPossibleEmptyResponse(url: string, dto: Dto) {
112
+ postPossibleEmptyResponse(url: string, dto: Dto) {
112
113
  return this.fetchPossibleEmptyResponse('POST', url, dto);
113
114
  }
114
115
 
115
116
  async put<T>(url: string, dto: Dto) {
116
- const response = await this.fetchPossibleEmptyResponse<T>('PUT', url, dto);
117
+ const response = await this.fetchPossibleEmptyResponse('PUT', url, dto);
117
118
  if (response === undefined) {
118
119
  throw new Error('Response was undefined');
119
120
  }
120
121
  return (await response.json()) as Promise<T>;
121
122
  }
122
123
 
123
- async putPossibleEmptyResponse(url: string, dto: Dto) {
124
+ putPossibleEmptyResponse(url: string, dto: Dto) {
124
125
  return this.fetchPossibleEmptyResponse('PUT', url, dto);
125
126
  }
126
127
 
127
- async delete<T>(url: string, config: SDKRequestInit = {}) {
128
+ delete(url: string, config: SDKRequestInit = {}) {
128
129
  return this.fetch(url, {
129
130
  method: 'DELETE',
130
131
  ...config,
@@ -1,6 +1,6 @@
1
1
  import { describe, expect, it } from 'vitest';
2
+ import { NullCache, TssApi } from '../../src';
2
3
  import { BaseModule } from '../../src/api/base';
3
- import { TssApi, NullCache } from '../../src';
4
4
 
5
5
  describe('Base module', () => {
6
6
  it('returns the cache', () => {
@@ -1,5 +1,5 @@
1
1
  import { describe, expect, it } from 'vitest';
2
- import { TssApi, NullCache, OnePasswordCache } from '../../src';
2
+ import { NullCache, OnePasswordCache, TssApi } from '../../src';
3
3
 
4
4
  describe('Jingle API', () => {
5
5
  const api = new TssApi(
@@ -28,7 +28,7 @@ describe('Jingle API', () => {
28
28
  });
29
29
 
30
30
  it('Plays a jingle', async () => {
31
- const result: any = await api.jingle.play({ folder: 'keeskankerkachel', file: 'aan.mp3' });
31
+ const result = await api.jingle.play({ folder: 'keeskankerkachel', file: 'aan.mp3' });
32
32
  expect(result.success).toBe(true);
33
33
  });
34
34
  });
@@ -1,7 +1,7 @@
1
+ import { existsSync, unlinkSync } from 'node:fs';
2
+ import path from 'node:path';
1
3
  import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
2
- import { FilesystemCache } from '../../src/cache';
3
- import { existsSync, unlinkSync, writeFileSync } from 'fs';
4
- import path from 'path';
4
+ import { FilesystemCache } from '../../src';
5
5
 
6
6
  describe('filesystemCache', () => {
7
7
  let cache: FilesystemCache;
@@ -59,7 +59,7 @@ describe('filesystemCache', () => {
59
59
  });
60
60
 
61
61
  it('Should use the function name as key, when no key is passed', async () => {
62
- let expected: number = 0;
62
+ let expected = 0;
63
63
  await (async function doeHet() {
64
64
  expected = await cache.cacheOrGet(() => Promise.resolve(50));
65
65
  })();
@@ -95,7 +95,7 @@ describe('filesystemCache', () => {
95
95
  expect(cachedValue).toBe(otherCorrectValue);
96
96
  });
97
97
 
98
- it('Should be able to clear the cache', async () => {
98
+ it('Should be able to clear the cache', () => {
99
99
  expect(existsSync(cache.getFilePath())).toBe(false);
100
100
  cache.set('test', 1);
101
101
  expect(existsSync(cache.getFilePath())).toBe(true);
@@ -37,7 +37,7 @@ describe('NullCache', () => {
37
37
  let catchedException = false;
38
38
  try {
39
39
  cache.getCacheKey();
40
- } catch (e) {
40
+ } catch (_e) {
41
41
  catchedException = true;
42
42
  }
43
43
 
package/tsconfig.json CHANGED
@@ -1,17 +1,17 @@
1
1
  {
2
- "compilerOptions": {
3
- "rootDir": "src",
4
- "outDir": "dist",
5
- "strict": true,
6
- "target": "ESNext",
7
- "module": "ES2022",
8
- "sourceMap": true,
9
- "esModuleInterop": true,
10
- "moduleResolution": "node",
11
- "strictNullChecks": true,
12
- "noImplicitAny": true,
13
- "experimentalDecorators": true,
14
- "strictPropertyInitialization": false,
15
- "verbatimModuleSyntax": true
16
- }
17
- }
2
+ "compilerOptions": {
3
+ "rootDir": "src",
4
+ "outDir": "dist",
5
+ "strict": true,
6
+ "target": "ESNext",
7
+ "module": "ES2022",
8
+ "sourceMap": true,
9
+ "esModuleInterop": true,
10
+ "moduleResolution": "node",
11
+ "strictNullChecks": true,
12
+ "noImplicitAny": true,
13
+ "experimentalDecorators": true,
14
+ "strictPropertyInitialization": false,
15
+ "verbatimModuleSyntax": true
16
+ }
17
+ }
@@ -1,3 +1,4 @@
1
+ /** biome-ignore-all lint/style/noNamespace: moet wel want global scope */
1
2
  declare global {
2
3
  namespace NodeJS {
3
4
  interface ProcessEnv {
package/.prettierrc DELETED
@@ -1,6 +0,0 @@
1
- {
2
- "singleQuote": true,
3
- "trailingComma": "all",
4
- "tabWidth": 4,
5
- "printWidth": 120,
6
- }