bedloop 0.1.0-alpha.2 → 0.1.0-alpha.3

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/dist/index.cjs CHANGED
@@ -322,8 +322,15 @@ var Client = class {
322
322
  }
323
323
  }
324
324
  }
325
+ async getAuthorization() {
326
+ const now = /* @__PURE__ */ new Date();
327
+ if (!this.authorization || this.authorization.expiresAt <= now) {
328
+ this.authorization = await getAuthorization(this.options);
329
+ }
330
+ return this.authorization;
331
+ }
325
332
  async connect(callback) {
326
- this.authorization = await getAuthorization(this.options);
333
+ await this.getAuthorization();
327
334
  if (this.options.debug) {
328
335
  console.log("Connected:", this.authorization);
329
336
  }
package/dist/index.d.cts CHANGED
@@ -28,6 +28,10 @@ interface ClientOptions {
28
28
  url: string;
29
29
  debug?: boolean;
30
30
  }
31
+ interface Authorization {
32
+ token: string;
33
+ expiresAt: Date;
34
+ }
31
35
  interface PollingOptions {
32
36
  interval: number;
33
37
  beforeDays: number;
@@ -42,6 +46,7 @@ declare class Client {
42
46
  private tokenRefreshInterval?;
43
47
  constructor(options: ClientOptions, pollingOptions?: Partial<PollingOptions>);
44
48
  private refreshToken;
49
+ getAuthorization(): Promise<Authorization>;
45
50
  connect(callback: (events: BedloopEvent[]) => void): Promise<void>;
46
51
  disconnect(): void;
47
52
  }
package/dist/index.d.ts CHANGED
@@ -28,6 +28,10 @@ interface ClientOptions {
28
28
  url: string;
29
29
  debug?: boolean;
30
30
  }
31
+ interface Authorization {
32
+ token: string;
33
+ expiresAt: Date;
34
+ }
31
35
  interface PollingOptions {
32
36
  interval: number;
33
37
  beforeDays: number;
@@ -42,6 +46,7 @@ declare class Client {
42
46
  private tokenRefreshInterval?;
43
47
  constructor(options: ClientOptions, pollingOptions?: Partial<PollingOptions>);
44
48
  private refreshToken;
49
+ getAuthorization(): Promise<Authorization>;
45
50
  connect(callback: (events: BedloopEvent[]) => void): Promise<void>;
46
51
  disconnect(): void;
47
52
  }
package/dist/index.js CHANGED
@@ -285,8 +285,15 @@ var Client = class {
285
285
  }
286
286
  }
287
287
  }
288
+ async getAuthorization() {
289
+ const now = /* @__PURE__ */ new Date();
290
+ if (!this.authorization || this.authorization.expiresAt <= now) {
291
+ this.authorization = await getAuthorization(this.options);
292
+ }
293
+ return this.authorization;
294
+ }
288
295
  async connect(callback) {
289
- this.authorization = await getAuthorization(this.options);
296
+ await this.getAuthorization();
290
297
  if (this.options.debug) {
291
298
  console.log("Connected:", this.authorization);
292
299
  }
package/package.json CHANGED
@@ -1,72 +1,70 @@
1
- {
2
- "name": "bedloop",
3
- "version": "0.1.0-alpha.2",
4
- "type": "module",
5
- "description": "TypeScript client for Bedloop API with real-time messaging and booking management",
6
- "main": "./dist/index.cjs",
7
- "module": "./dist/index.js",
8
- "types": "./dist/index.d.ts",
9
- "exports": {
10
- ".": {
11
- "require": {
12
- "types": "./dist/index.d.cts",
13
- "default": "./dist/index.cjs"
14
- },
15
- "import": {
16
- "types": "./dist/index.d.ts",
17
- "default": "./dist/index.js"
18
- }
19
- }
20
- },
21
- "files": [
22
- "dist",
23
- "README.md",
24
- "LICENSE"
25
- ],
26
- "scripts": {
27
- "build": "tsup",
28
- "dev": "tsc --watch",
29
- "playground": "tsx playground/playground.ts",
30
- "lint": "eslint src/**/*.ts",
31
- "lint:fix": "eslint src/**/*.ts --fix",
32
- "format": "prettier --write \"src/**/*.ts\"",
33
- "typecheck": "tsc --noEmit",
34
- "prepublishOnly": "pnpm build"
35
- },
36
- "devDependencies": {
37
- "@types/node": "24.10.1",
38
- "@typescript-eslint/eslint-plugin": "8.48.0",
39
- "@typescript-eslint/parser": "8.48.0",
40
- "eslint": "9.39.1",
41
- "eslint-config-prettier": "10.1.8",
42
- "eslint-plugin-prettier": "5.5.4",
43
- "prettier": "3.7.3",
44
- "tsup": "8.5.1",
45
- "tsx": "4.20.6",
46
- "typescript": "5.9.3"
47
- },
48
- "keywords": [
49
- "bedloop",
50
- "api",
51
- "client",
52
- "typescript",
53
- "messaging",
54
- "booking",
55
- "real-time",
56
- "polling"
57
- ],
58
- "repository": {
59
- "type": "git",
60
- "url": "https://github.com/johan12361/bedloop.git"
61
- },
62
- "bugs": {
63
- "url": "https://github.com/johan12361/bedloop/issues"
64
- },
65
- "homepage": "https://github.com/johan12361/bedloop#readme",
66
- "author": "johan12361",
67
- "license": "MIT",
68
- "packageManager": "pnpm@10.18.3",
69
- "dependencies": {
70
- "axios": "1.13.2"
71
- }
72
- }
1
+ {
2
+ "name": "bedloop",
3
+ "version": "0.1.0-alpha.3",
4
+ "type": "module",
5
+ "description": "TypeScript client for Bedloop API with real-time messaging and booking management",
6
+ "main": "./dist/index.cjs",
7
+ "module": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "require": {
12
+ "types": "./dist/index.d.cts",
13
+ "default": "./dist/index.cjs"
14
+ },
15
+ "import": {
16
+ "types": "./dist/index.d.ts",
17
+ "default": "./dist/index.js"
18
+ }
19
+ }
20
+ },
21
+ "files": [
22
+ "dist",
23
+ "README.md",
24
+ "LICENSE"
25
+ ],
26
+ "devDependencies": {
27
+ "@types/node": "24.10.1",
28
+ "@typescript-eslint/eslint-plugin": "8.48.0",
29
+ "@typescript-eslint/parser": "8.48.0",
30
+ "eslint": "9.39.1",
31
+ "eslint-config-prettier": "10.1.8",
32
+ "eslint-plugin-prettier": "5.5.4",
33
+ "prettier": "3.7.3",
34
+ "tsup": "8.5.1",
35
+ "tsx": "4.20.6",
36
+ "typescript": "5.9.3"
37
+ },
38
+ "keywords": [
39
+ "bedloop",
40
+ "api",
41
+ "client",
42
+ "typescript",
43
+ "messaging",
44
+ "booking",
45
+ "real-time",
46
+ "polling"
47
+ ],
48
+ "repository": {
49
+ "type": "git",
50
+ "url": "https://github.com/johan12361/bedloop.git"
51
+ },
52
+ "bugs": {
53
+ "url": "https://github.com/johan12361/bedloop/issues"
54
+ },
55
+ "homepage": "https://github.com/johan12361/bedloop#readme",
56
+ "author": "johan12361",
57
+ "license": "MIT",
58
+ "dependencies": {
59
+ "axios": "1.13.2"
60
+ },
61
+ "scripts": {
62
+ "build": "tsup",
63
+ "dev": "tsc --watch",
64
+ "playground": "tsx playground/playground.ts",
65
+ "lint": "eslint src/**/*.ts",
66
+ "lint:fix": "eslint src/**/*.ts --fix",
67
+ "format": "prettier --write \"src/**/*.ts\"",
68
+ "typecheck": "tsc --noEmit"
69
+ }
70
+ }