timezest 1.0.7 → 1.1.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/README.md +1 -1
- package/config/config.d.ts +25 -0
- package/config/config.js +4 -0
- package/config/config.js.map +1 -1
- package/index.d.ts +61 -0
- package/index.js +70 -5
- package/index.js.map +1 -1
- package/package.json +5 -1
- package/utils/logger.d.ts +39 -0
- package/utils/logger.js +20 -1
- package/utils/logger.js.map +1 -1
- package/utils/makeRequest.js +0 -1
- package/utils/makeRequest.js.map +1 -1
package/README.md
CHANGED
|
@@ -106,7 +106,7 @@ Pass TQL statements into the request to filter your results
|
|
|
106
106
|
```typescript
|
|
107
107
|
async function fetchTier1Team() {
|
|
108
108
|
try {
|
|
109
|
-
const teams = await timeZest.getTeams(
|
|
109
|
+
const teams = await timeZest.getTeams("team.internal_name EQ Tier1");
|
|
110
110
|
console.log("Teams:", teams);
|
|
111
111
|
} catch (error) {
|
|
112
112
|
console.error("Error fetching teams:", error);
|
package/config/config.d.ts
CHANGED
|
@@ -1,9 +1,34 @@
|
|
|
1
1
|
import { LogLevel, Logger } from "../utils/logger";
|
|
2
|
+
/**
|
|
3
|
+
* Configuration options for the TimeZest API client.
|
|
4
|
+
*/
|
|
2
5
|
export interface TimeZestAPIConfig {
|
|
6
|
+
/**
|
|
7
|
+
* The log level for the API client (e.g., 'info', 'debug', 'error').
|
|
8
|
+
*/
|
|
3
9
|
logLevel: LogLevel;
|
|
10
|
+
/**
|
|
11
|
+
* The logger instance to use for logging messages.
|
|
12
|
+
*/
|
|
4
13
|
logger: Logger;
|
|
14
|
+
/**
|
|
15
|
+
* The base URL for the TimeZest API.
|
|
16
|
+
*/
|
|
5
17
|
baseUrl: string;
|
|
18
|
+
/**
|
|
19
|
+
* The maximum delay between retries, in milliseconds.
|
|
20
|
+
*/
|
|
6
21
|
maxRetryDelayMs: number;
|
|
22
|
+
/**
|
|
23
|
+
* The maximum total retry time, in milliseconds.
|
|
24
|
+
*/
|
|
7
25
|
maxRetryTimeMs: number;
|
|
26
|
+
/**
|
|
27
|
+
* Whether to validate API responses using Zod schemas.
|
|
28
|
+
*/
|
|
29
|
+
outputValidation: boolean;
|
|
8
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* Default configuration for the TimeZest API client.
|
|
33
|
+
*/
|
|
9
34
|
export declare const CONFIG: TimeZestAPIConfig;
|
package/config/config.js
CHANGED
|
@@ -2,11 +2,15 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CONFIG = void 0;
|
|
4
4
|
const logger_1 = require("../utils/logger");
|
|
5
|
+
/**
|
|
6
|
+
* Default configuration for the TimeZest API client.
|
|
7
|
+
*/
|
|
5
8
|
exports.CONFIG = {
|
|
6
9
|
logLevel: "error",
|
|
7
10
|
logger: logger_1.defaultLogger,
|
|
8
11
|
baseUrl: "https://api.timezest.com/v1",
|
|
9
12
|
maxRetryDelayMs: 1.5 * 60 * 1000, // 1.5 minutes
|
|
10
13
|
maxRetryTimeMs: 15 * 1000, // 15 seconds
|
|
14
|
+
outputValidation: true,
|
|
11
15
|
};
|
|
12
16
|
//# sourceMappingURL=config.js.map
|
package/config/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/config/config.ts"],"names":[],"mappings":";;;AAAA,4CAAkE;
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/config/config.ts"],"names":[],"mappings":";;;AAAA,4CAAkE;AAqClE;;GAEG;AACU,QAAA,MAAM,GAAsB;IACvC,QAAQ,EAAE,OAAO;IACjB,MAAM,EAAE,sBAAa;IACrB,OAAO,EAAE,6BAA6B;IACtC,eAAe,EAAE,GAAG,GAAG,EAAE,GAAG,IAAI,EAAE,cAAc;IAChD,cAAc,EAAE,EAAE,GAAG,IAAI,EAAE,aAAa;IACxC,gBAAgB,EAAE,IAAI;CACvB,CAAC"}
|
package/index.d.ts
CHANGED
|
@@ -15,19 +15,80 @@ export interface TimeZestAPIOptions {
|
|
|
15
15
|
maxRetryDelayMs?: number;
|
|
16
16
|
/** The maximum total retry time, in milliseconds. */
|
|
17
17
|
maxRetryTimeMs?: number;
|
|
18
|
+
/** Whether to use Zod validation for API responses. */
|
|
19
|
+
outputValidation?: boolean;
|
|
18
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* Represents the TimeZest API client.
|
|
23
|
+
* Provides methods to interact with the TimeZest API.
|
|
24
|
+
*/
|
|
19
25
|
export declare class TimeZestAPI {
|
|
20
26
|
private config;
|
|
21
27
|
private apiKey;
|
|
22
28
|
log: log;
|
|
29
|
+
/**
|
|
30
|
+
* Creates an instance of the TimeZestAPI client.
|
|
31
|
+
* @param apiKey - The API key for authenticating with the TimeZest API.
|
|
32
|
+
* @param options - Optional configuration options for the API client.
|
|
33
|
+
*/
|
|
23
34
|
constructor(apiKey: string, options?: TimeZestAPIOptions);
|
|
35
|
+
/**
|
|
36
|
+
* Retrieves the API key used by the client.
|
|
37
|
+
* @returns The API key.
|
|
38
|
+
*/
|
|
24
39
|
getApiKey(): string;
|
|
40
|
+
/**
|
|
41
|
+
* Retrieves the configuration of the API client.
|
|
42
|
+
* @returns The API client configuration.
|
|
43
|
+
*/
|
|
25
44
|
getConfig(): TimeZestAPIConfig;
|
|
45
|
+
/**
|
|
46
|
+
* Fetches resources from the TimeZest API.
|
|
47
|
+
* @param filter - Optional filter string to narrow down results.
|
|
48
|
+
* @returns A promise that resolves to an array of resources.
|
|
49
|
+
*/
|
|
26
50
|
getResources: (filter?: string | null) => Promise<Resource[]>;
|
|
51
|
+
/**
|
|
52
|
+
* Fetches agents from the TimeZest API.
|
|
53
|
+
* @param filter - Optional filter string to narrow down results.
|
|
54
|
+
* @returns A promise that resolves to an array of agents.
|
|
55
|
+
*/
|
|
27
56
|
getAgents(filter?: string | null): Promise<Agent[]>;
|
|
57
|
+
/**
|
|
58
|
+
* Fetches teams from the TimeZest API.
|
|
59
|
+
* @param filter - Optional filter string to narrow down results.
|
|
60
|
+
* @returns A promise that resolves to an array of teams.
|
|
61
|
+
*/
|
|
28
62
|
getTeams(filter?: string | null): Promise<Team[]>;
|
|
63
|
+
/**
|
|
64
|
+
* Fetches appointment types from the TimeZest API.
|
|
65
|
+
* @param filter - Optional filter string to narrow down results.
|
|
66
|
+
* @returns A promise that resolves to an array of appointment types.
|
|
67
|
+
*/
|
|
29
68
|
getAppointmentTypes(filter?: string | null): Promise<AppointmentType[]>;
|
|
69
|
+
/**
|
|
70
|
+
* Fetches a scheduling request by its ID.
|
|
71
|
+
* @param id - The ID of the scheduling request.
|
|
72
|
+
* @returns A promise that resolves to the scheduling request.
|
|
73
|
+
*/
|
|
30
74
|
getSchedulingRequest(id: string): Promise<SchedulingRequest>;
|
|
75
|
+
/**
|
|
76
|
+
* Fetches scheduling requests from the TimeZest API.
|
|
77
|
+
* @param filter - Optional filter string to narrow down results.
|
|
78
|
+
* @returns A promise that resolves to an array of scheduling requests.
|
|
79
|
+
*/
|
|
31
80
|
getSchedulingRequests(filter?: string | null): Promise<SchedulingRequest[]>;
|
|
81
|
+
/**
|
|
82
|
+
* Creates a new scheduling request.
|
|
83
|
+
* @param data - The data for the scheduling request.
|
|
84
|
+
* @returns A promise that resolves to the created scheduling request.
|
|
85
|
+
*/
|
|
32
86
|
createSchedulingRequest(data: SchedulingRequest): Promise<SchedulingRequest>;
|
|
87
|
+
/**
|
|
88
|
+
* Validates API responses using Zod schemas if outputValidation is enabled.
|
|
89
|
+
* @param response - The API response data to validate.
|
|
90
|
+
* @param schema - The Zod schema to validate against.
|
|
91
|
+
* @returns The validated or raw response data.
|
|
92
|
+
*/
|
|
93
|
+
private validateResponse;
|
|
33
94
|
}
|
package/index.js
CHANGED
|
@@ -16,11 +16,25 @@ const makeRequest_1 = require("./utils/makeRequest");
|
|
|
16
16
|
const endpoints_1 = require("./constants/endpoints");
|
|
17
17
|
const logger_1 = require("./utils/logger");
|
|
18
18
|
const makePaginatedRequest_1 = require("./utils/makePaginatedRequest");
|
|
19
|
+
/**
|
|
20
|
+
* Represents the TimeZest API client.
|
|
21
|
+
* Provides methods to interact with the TimeZest API.
|
|
22
|
+
*/
|
|
19
23
|
class TimeZestAPI {
|
|
24
|
+
/**
|
|
25
|
+
* Creates an instance of the TimeZestAPI client.
|
|
26
|
+
* @param apiKey - The API key for authenticating with the TimeZest API.
|
|
27
|
+
* @param options - Optional configuration options for the API client.
|
|
28
|
+
*/
|
|
20
29
|
constructor(apiKey, options) {
|
|
30
|
+
/**
|
|
31
|
+
* Fetches resources from the TimeZest API.
|
|
32
|
+
* @param filter - Optional filter string to narrow down results.
|
|
33
|
+
* @returns A promise that resolves to an array of resources.
|
|
34
|
+
*/
|
|
21
35
|
this.getResources = (...args_1) => __awaiter(this, [...args_1], void 0, function* (filter = null) {
|
|
22
36
|
const response = yield (0, makePaginatedRequest_1.makePaginatedRequest)(this, endpoints_1.API_ENDPOINTS.RESOURCES, "GET", null, filter);
|
|
23
|
-
return
|
|
37
|
+
return this.validateResponse(response, schemas_1.ResourceSchema);
|
|
24
38
|
});
|
|
25
39
|
this.apiKey = apiKey;
|
|
26
40
|
this.config = {
|
|
@@ -29,6 +43,7 @@ class TimeZestAPI {
|
|
|
29
43
|
baseUrl: (options === null || options === void 0 ? void 0 : options.baseUrl) || config_1.CONFIG.baseUrl,
|
|
30
44
|
maxRetryDelayMs: (options === null || options === void 0 ? void 0 : options.maxRetryDelayMs) || config_1.CONFIG.maxRetryDelayMs,
|
|
31
45
|
maxRetryTimeMs: (options === null || options === void 0 ? void 0 : options.maxRetryTimeMs) || config_1.CONFIG.maxRetryTimeMs,
|
|
46
|
+
outputValidation: (options === null || options === void 0 ? void 0 : options.outputValidation) || config_1.CONFIG.outputValidation,
|
|
32
47
|
};
|
|
33
48
|
this.log = (0, logger_1.buildLogger)(this.config.logger, this.config.logLevel);
|
|
34
49
|
// Log the initialization of the API client but remove apiKey
|
|
@@ -43,48 +58,98 @@ class TimeZestAPI {
|
|
|
43
58
|
this.getSchedulingRequest = (0, logger_1.withLogging)(this.getSchedulingRequest.bind(this), this, "getSchedulingRequest");
|
|
44
59
|
this.createSchedulingRequest = (0, logger_1.withLogging)(this.createSchedulingRequest.bind(this), this, "createSchedulingRequest");
|
|
45
60
|
}
|
|
61
|
+
/**
|
|
62
|
+
* Retrieves the API key used by the client.
|
|
63
|
+
* @returns The API key.
|
|
64
|
+
*/
|
|
46
65
|
getApiKey() {
|
|
47
66
|
return this.apiKey;
|
|
48
67
|
}
|
|
68
|
+
/**
|
|
69
|
+
* Retrieves the configuration of the API client.
|
|
70
|
+
* @returns The API client configuration.
|
|
71
|
+
*/
|
|
49
72
|
getConfig() {
|
|
50
73
|
return this.config;
|
|
51
74
|
}
|
|
75
|
+
/**
|
|
76
|
+
* Fetches agents from the TimeZest API.
|
|
77
|
+
* @param filter - Optional filter string to narrow down results.
|
|
78
|
+
* @returns A promise that resolves to an array of agents.
|
|
79
|
+
*/
|
|
52
80
|
getAgents() {
|
|
53
81
|
return __awaiter(this, arguments, void 0, function* (filter = null) {
|
|
54
82
|
const response = yield (0, makePaginatedRequest_1.makePaginatedRequest)(this, endpoints_1.API_ENDPOINTS.AGENTS, "GET", null, filter);
|
|
55
|
-
return
|
|
83
|
+
return this.validateResponse(response, schemas_1.AgentSchema);
|
|
56
84
|
});
|
|
57
85
|
}
|
|
86
|
+
/**
|
|
87
|
+
* Fetches teams from the TimeZest API.
|
|
88
|
+
* @param filter - Optional filter string to narrow down results.
|
|
89
|
+
* @returns A promise that resolves to an array of teams.
|
|
90
|
+
*/
|
|
58
91
|
getTeams() {
|
|
59
92
|
return __awaiter(this, arguments, void 0, function* (filter = null) {
|
|
60
93
|
const response = yield (0, makePaginatedRequest_1.makePaginatedRequest)(this, endpoints_1.API_ENDPOINTS.TEAMS, "GET", null, filter);
|
|
61
|
-
return
|
|
94
|
+
return this.validateResponse(response, schemas_1.TeamSchema);
|
|
62
95
|
});
|
|
63
96
|
}
|
|
97
|
+
/**
|
|
98
|
+
* Fetches appointment types from the TimeZest API.
|
|
99
|
+
* @param filter - Optional filter string to narrow down results.
|
|
100
|
+
* @returns A promise that resolves to an array of appointment types.
|
|
101
|
+
*/
|
|
64
102
|
getAppointmentTypes() {
|
|
65
103
|
return __awaiter(this, arguments, void 0, function* (filter = null) {
|
|
66
104
|
const response = yield (0, makePaginatedRequest_1.makePaginatedRequest)(this, endpoints_1.API_ENDPOINTS.APPOINTMENT_TYPES, "GET", null, filter);
|
|
67
|
-
return
|
|
105
|
+
return this.validateResponse(response, schemas_1.AppointmentTypeSchema);
|
|
68
106
|
});
|
|
69
107
|
}
|
|
108
|
+
/**
|
|
109
|
+
* Fetches a scheduling request by its ID.
|
|
110
|
+
* @param id - The ID of the scheduling request.
|
|
111
|
+
* @returns A promise that resolves to the scheduling request.
|
|
112
|
+
*/
|
|
70
113
|
getSchedulingRequest(id) {
|
|
71
114
|
return __awaiter(this, void 0, void 0, function* () {
|
|
72
115
|
const response = yield (0, makeRequest_1.makeRequest)(this.log, this.apiKey, this.config.baseUrl, `${endpoints_1.API_ENDPOINTS.SCHEDULING_REQUESTS}/${id}`, "GET", null, this.config.maxRetryTimeMs, this.config.maxRetryDelayMs);
|
|
73
116
|
return schemas_1.SchedulingRequestSchema.parse(response);
|
|
74
117
|
});
|
|
75
118
|
}
|
|
119
|
+
/**
|
|
120
|
+
* Fetches scheduling requests from the TimeZest API.
|
|
121
|
+
* @param filter - Optional filter string to narrow down results.
|
|
122
|
+
* @returns A promise that resolves to an array of scheduling requests.
|
|
123
|
+
*/
|
|
76
124
|
getSchedulingRequests() {
|
|
77
125
|
return __awaiter(this, arguments, void 0, function* (filter = null) {
|
|
78
126
|
const response = yield (0, makePaginatedRequest_1.makePaginatedRequest)(this, endpoints_1.API_ENDPOINTS.SCHEDULING_REQUESTS, "GET", null, filter);
|
|
79
|
-
return
|
|
127
|
+
return this.validateResponse(response, schemas_1.SchedulingRequestSchema);
|
|
80
128
|
});
|
|
81
129
|
}
|
|
130
|
+
/**
|
|
131
|
+
* Creates a new scheduling request.
|
|
132
|
+
* @param data - The data for the scheduling request.
|
|
133
|
+
* @returns A promise that resolves to the created scheduling request.
|
|
134
|
+
*/
|
|
82
135
|
createSchedulingRequest(data) {
|
|
83
136
|
return __awaiter(this, void 0, void 0, function* () {
|
|
84
137
|
const response = yield (0, makeRequest_1.makeRequest)(this.log, this.apiKey, this.config.baseUrl, endpoints_1.API_ENDPOINTS.SCHEDULING_REQUESTS, "POST", data, this.config.maxRetryTimeMs, this.config.maxRetryDelayMs);
|
|
85
138
|
return response;
|
|
86
139
|
});
|
|
87
140
|
}
|
|
141
|
+
/**
|
|
142
|
+
* Validates API responses using Zod schemas if outputValidation is enabled.
|
|
143
|
+
* @param response - The API response data to validate.
|
|
144
|
+
* @param schema - The Zod schema to validate against.
|
|
145
|
+
* @returns The validated or raw response data.
|
|
146
|
+
*/
|
|
147
|
+
validateResponse(response, schema) {
|
|
148
|
+
if (this.config.outputValidation) {
|
|
149
|
+
return response.map((item) => schema.parse(item));
|
|
150
|
+
}
|
|
151
|
+
return response;
|
|
152
|
+
}
|
|
88
153
|
}
|
|
89
154
|
exports.TimeZestAPI = TimeZestAPI;
|
|
90
155
|
//# sourceMappingURL=index.js.map
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AASA,gDAM4B;AAC5B,4CAAyC;AACzC,qDAAkD;AAClD,qDAAsD;AACtD,2CAA0D;AAC1D,uEAAoE;AA0BpE;;;GAGG;AACH,MAAa,WAAW;IAKtB;;;;OAIG;IACH,YAAY,MAAc,EAAE,OAA4B;QA6DxD;;;;WAIG;QACH,iBAAY,GAAG,YAA0D,EAAE,iDAArD,SAAwB,IAAI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AC;KAAA;IAED;;;;OAIG;IACG,uBAAuB,CAC3B,IAAuB;;YAEvB,MAAM,QAAQ,GAAG,MAAM,IAAA,yBAAW,EAChC,IAAI,CAAC,GAAG,EACR,IAAI,CAAC,MAAM,EACX,IAAI,CAAC,MAAM,CAAC,OAAO,EACnB,yBAAa,CAAC,mBAAmB,EACjC,MAAM,EACN,IAAI,EACJ,IAAI,CAAC,MAAM,CAAC,cAAc,EAC1B,IAAI,CAAC,MAAM,CAAC,eAAe,CAC5B,CAAC;YACF,OAAO,QAAQ,CAAC;QAClB,CAAC;KAAA;IAED;;;;;OAKG;IACK,gBAAgB,CAAI,QAAa,EAAE,MAAiB;QAC1D,IAAI,IAAI,CAAC,MAAM,CAAC,gBAAgB,EAAE,CAAC;YACjC,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;QACpD,CAAC;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF;AA/MD,kCA+MC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "timezest",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "tsc",
|
|
@@ -23,5 +23,9 @@
|
|
|
23
23
|
"prettier": "^3.5.3",
|
|
24
24
|
"@types/node": "^22.15.3",
|
|
25
25
|
"typescript": "^5.8.3"
|
|
26
|
+
},
|
|
27
|
+
"repository": {
|
|
28
|
+
"type": "git",
|
|
29
|
+
"url": "git+https://github.com/pncit/timezest.git"
|
|
26
30
|
}
|
|
27
31
|
}
|
package/utils/logger.d.ts
CHANGED
|
@@ -1,20 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents a logging function that logs messages at a specific log level.
|
|
3
|
+
* @param level - The log level of the message (e.g., 'info', 'error').
|
|
4
|
+
* @param message - The message to log.
|
|
5
|
+
* @param data - Optional additional data to log.
|
|
6
|
+
*/
|
|
1
7
|
export type log = {
|
|
2
8
|
(level: LogLevel, message: string, data?: any): void;
|
|
3
9
|
};
|
|
10
|
+
/**
|
|
11
|
+
* Interface for a logger with various log levels.
|
|
12
|
+
*/
|
|
4
13
|
export interface Logger {
|
|
14
|
+
/** Logs a silent message (no output). */
|
|
5
15
|
silent: (message: string, data?: any) => void;
|
|
16
|
+
/** Logs an error message. */
|
|
6
17
|
error: (message: string, data?: any) => void;
|
|
18
|
+
/** Logs a warning message. */
|
|
7
19
|
warn: (message: string, data?: any) => void;
|
|
20
|
+
/** Logs an informational message. */
|
|
8
21
|
info: (message: string, data?: any) => void;
|
|
22
|
+
/** Logs an HTTP-related message. */
|
|
9
23
|
http: (message: string, data?: any) => void;
|
|
24
|
+
/** Logs a verbose message. */
|
|
10
25
|
verbose: (message: string, data?: any) => void;
|
|
26
|
+
/** Logs a debug message. */
|
|
11
27
|
debug: (message: string, data?: any) => void;
|
|
28
|
+
/** Logs a silly (very detailed) message. */
|
|
12
29
|
silly: (message: string, data?: any) => void;
|
|
13
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* Represents the available log levels and their priorities.
|
|
33
|
+
*/
|
|
14
34
|
export type LogLevel = "silent" | "error" | "warn" | "info" | "http" | "verbose" | "debug" | "silly";
|
|
35
|
+
/**
|
|
36
|
+
* A mapping of log levels to their priority values.
|
|
37
|
+
*/
|
|
15
38
|
export declare const logLevelPriority: Record<LogLevel, number>;
|
|
39
|
+
/**
|
|
40
|
+
* The default logger implementation that logs messages to the console.
|
|
41
|
+
*/
|
|
16
42
|
export declare const defaultLogger: Logger;
|
|
43
|
+
/**
|
|
44
|
+
* Builds a logger function that logs messages at or above the specified log level.
|
|
45
|
+
* @param logger - The logger instance to use for logging.
|
|
46
|
+
* @param logLevel - The minimum log level to log messages.
|
|
47
|
+
* @returns A function that logs messages at the specified log level.
|
|
48
|
+
*/
|
|
17
49
|
export declare function buildLogger(logger: Logger, logLevel: LogLevel): (level: LogLevel, message: string, data?: any) => void;
|
|
50
|
+
/**
|
|
51
|
+
* Wraps an asynchronous function with logging for entry, exit, and errors.
|
|
52
|
+
* @param fn - The asynchronous function to wrap.
|
|
53
|
+
* @param instance - The instance containing the logger.
|
|
54
|
+
* @param functionName - The name of the function being wrapped.
|
|
55
|
+
* @returns A wrapped function with logging.
|
|
56
|
+
*/
|
|
18
57
|
export declare function withLogging<T>(fn: (...args: any[]) => Promise<T>, instance: {
|
|
19
58
|
log: (level: LogLevel, message: string, data?: any) => void;
|
|
20
59
|
}, functionName: string): (...args: any[]) => Promise<T>;
|
package/utils/logger.js
CHANGED
|
@@ -12,6 +12,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.defaultLogger = exports.logLevelPriority = void 0;
|
|
13
13
|
exports.buildLogger = buildLogger;
|
|
14
14
|
exports.withLogging = withLogging;
|
|
15
|
+
/**
|
|
16
|
+
* A mapping of log levels to their priority values.
|
|
17
|
+
*/
|
|
15
18
|
exports.logLevelPriority = {
|
|
16
19
|
silent: -1,
|
|
17
20
|
error: 0,
|
|
@@ -22,16 +25,25 @@ exports.logLevelPriority = {
|
|
|
22
25
|
debug: 5,
|
|
23
26
|
silly: 6,
|
|
24
27
|
};
|
|
28
|
+
/**
|
|
29
|
+
* The default logger implementation that logs messages to the console.
|
|
30
|
+
*/
|
|
25
31
|
exports.defaultLogger = {
|
|
26
32
|
silent: (_message, _data) => { },
|
|
27
33
|
error: (message, data) => data ? console.error(message, data) : console.error(message),
|
|
28
34
|
warn: (message, data) => data ? console.warn(message, data) : console.warn(message),
|
|
29
|
-
info: (message, data) => data ? console.info(message, data) : console.info,
|
|
35
|
+
info: (message, data) => data ? console.info(message, data) : console.info(message),
|
|
30
36
|
http: (message, data) => data ? console.log(message, data) : console.log(message),
|
|
31
37
|
verbose: (message, data) => data ? console.debug(message, data) : console.debug(message),
|
|
32
38
|
debug: (message, data) => data ? console.debug(message, data) : console.debug(message),
|
|
33
39
|
silly: (message, data) => data ? console.debug(message, data) : console.debug(message),
|
|
34
40
|
};
|
|
41
|
+
/**
|
|
42
|
+
* Builds a logger function that logs messages at or above the specified log level.
|
|
43
|
+
* @param logger - The logger instance to use for logging.
|
|
44
|
+
* @param logLevel - The minimum log level to log messages.
|
|
45
|
+
* @returns A function that logs messages at the specified log level.
|
|
46
|
+
*/
|
|
35
47
|
function buildLogger(logger, logLevel) {
|
|
36
48
|
return (level, message, data) => {
|
|
37
49
|
if (exports.logLevelPriority[level] <= exports.logLevelPriority[logLevel]) {
|
|
@@ -39,6 +51,13 @@ function buildLogger(logger, logLevel) {
|
|
|
39
51
|
}
|
|
40
52
|
};
|
|
41
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* Wraps an asynchronous function with logging for entry, exit, and errors.
|
|
56
|
+
* @param fn - The asynchronous function to wrap.
|
|
57
|
+
* @param instance - The instance containing the logger.
|
|
58
|
+
* @param functionName - The name of the function being wrapped.
|
|
59
|
+
* @returns A wrapped function with logging.
|
|
60
|
+
*/
|
|
42
61
|
function withLogging(fn, instance, functionName) {
|
|
43
62
|
return (...args) => __awaiter(this, void 0, void 0, function* () {
|
|
44
63
|
instance.log("debug", `Entering ${functionName}`);
|
package/utils/logger.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":";;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":";;;;;;;;;;;;AA6FA,kCASC;AASD,kCAsBC;AAjFD;;GAEG;AACU,QAAA,gBAAgB,GAA6B;IACxD,MAAM,EAAE,CAAC,CAAC;IACV,KAAK,EAAE,CAAC;IACR,IAAI,EAAE,CAAC;IACP,IAAI,EAAE,CAAC;IACP,IAAI,EAAE,CAAC;IACP,OAAO,EAAE,CAAC;IACV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AAC;QAChB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,QAAQ,CAAC,GAAG,CAAC,OAAO,EAAE,YAAY,YAAY,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;YAC7D,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC,CAAA,CAAC;AACJ,CAAC"}
|
package/utils/makeRequest.js
CHANGED
package/utils/makeRequest.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"makeRequest.js","sourceRoot":"","sources":["../../src/utils/makeRequest.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAkBA,
|
|
1
|
+
{"version":3,"file":"makeRequest.js","sourceRoot":"","sources":["../../src/utils/makeRequest.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAkBA,kCA+DC;AAjFD,kDAA0B;AAC1B,+CAA4C;AAI5C;;;;;;;;;;;;GAYG;AACH,SAAsB,WAAW,CAC/B,GAA2D,EAC3D,MAAc,EACd,OAAe,EACf,QAAqB,EACrB,MAAsB,EACtB,IAAS,EACT,cAAsB,EACtB,eAAuB;;;QAEvB,IAAI,gBAAgB,GAAG,CAAC,CAAC;QACzB,IAAI,OAAO,GAAG,CAAC,CAAC;QAEhB,OAAO,gBAAgB,GAAG,cAAc,EAAE,CAAC;YACzC,IAAI,CAAC;gBACH,GAAG,CACD,OAAO,EACP,yBAAyB,QAAQ,kBAAkB,OAAO,EAAE,CAC7D,CAAC;gBACF,MAAM,QAAQ,GAAG,MAAM,IAAA,eAAK,EAAC;oBAC3B,GAAG,EAAE,GAAG,OAAO,GAAG,QAAQ,EAAE;oBAC5B,MAAM;oBACN,OAAO,EAAE;wBACP,aAAa,EAAE,UAAU,MAAM,EAAE;wBACjC,cAAc,EAAE,kBAAkB;qBACnC;oBACD,IAAI;iBACL,CAAC,CAAC;gBACH,OAAO,QAAQ,CAAC,IAAI,CAAC;YACvB,CAAC;YAAC,OAAO,KAAU,EAAE,CAAC;gBACpB,IAAI,C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