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 +8 -1
- package/dist/index.d.cts +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +8 -1
- package/package.json +70 -72
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.
|
|
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.
|
|
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.
|
|
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
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
"
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
"
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
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
|
+
}
|