timezest 1.0.8 → 1.1.1
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 +34 -0
- package/{dist/config → config}/config.js +4 -0
- package/config/config.js.map +1 -0
- package/{dist/index.d.ts → index.d.ts} +9 -0
- package/{dist/index.js → index.js} +18 -5
- package/index.js.map +1 -0
- package/package.json +2 -2
- package/utils/logger.d.ts +59 -0
- package/{dist/utils → utils}/logger.js +20 -1
- package/utils/logger.js.map +1 -0
- package/{dist/utils → utils}/makeRequest.js +0 -1
- package/{dist/utils → utils}/makeRequest.js.map +1 -1
- package/.env +0 -1
- package/dist/LICENSE +0 -9
- package/dist/README.md +0 -196
- package/dist/config/config.d.ts +0 -9
- package/dist/config/config.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/package.json +0 -27
- package/dist/utils/logger.d.ts +0 -20
- package/dist/utils/logger.js.map +0 -1
- package/timezest-1.0.1.tgz +0 -0
- package/timezest-1.0.2.tgz +0 -0
- package/timezest-1.0.3.tgz +0 -0
- /package/{dist/constants → constants}/endpoints.d.ts +0 -0
- /package/{dist/constants → constants}/endpoints.js +0 -0
- /package/{dist/constants → constants}/endpoints.js.map +0 -0
- /package/{dist/entities → entities}/entities.d.ts +0 -0
- /package/{dist/entities → entities}/entities.js +0 -0
- /package/{dist/entities → entities}/entities.js.map +0 -0
- /package/{dist/entities → entities}/schemas.d.ts +0 -0
- /package/{dist/entities → entities}/schemas.js +0 -0
- /package/{dist/entities → entities}/schemas.js.map +0 -0
- /package/{dist/utils → utils}/handleError.d.ts +0 -0
- /package/{dist/utils → utils}/handleError.js +0 -0
- /package/{dist/utils → utils}/handleError.js.map +0 -0
- /package/{dist/utils → utils}/makePaginatedRequest.d.ts +0 -0
- /package/{dist/utils → utils}/makePaginatedRequest.js +0 -0
- /package/{dist/utils → utils}/makePaginatedRequest.js.map +0 -0
- /package/{dist/utils → utils}/makeRequest.d.ts +0 -0
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);
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { LogLevel, Logger } from "../utils/logger";
|
|
2
|
+
/**
|
|
3
|
+
* Configuration options for the TimeZest API client.
|
|
4
|
+
*/
|
|
5
|
+
export interface TimeZestAPIConfig {
|
|
6
|
+
/**
|
|
7
|
+
* The log level for the API client (e.g., 'info', 'debug', 'error').
|
|
8
|
+
*/
|
|
9
|
+
logLevel: LogLevel;
|
|
10
|
+
/**
|
|
11
|
+
* The logger instance to use for logging messages.
|
|
12
|
+
*/
|
|
13
|
+
logger: Logger;
|
|
14
|
+
/**
|
|
15
|
+
* The base URL for the TimeZest API.
|
|
16
|
+
*/
|
|
17
|
+
baseUrl: string;
|
|
18
|
+
/**
|
|
19
|
+
* The maximum delay between retries, in milliseconds.
|
|
20
|
+
*/
|
|
21
|
+
maxRetryDelayMs: number;
|
|
22
|
+
/**
|
|
23
|
+
* The maximum total retry time, in milliseconds.
|
|
24
|
+
*/
|
|
25
|
+
maxRetryTimeMs: number;
|
|
26
|
+
/**
|
|
27
|
+
* Whether to validate API responses using Zod schemas.
|
|
28
|
+
*/
|
|
29
|
+
outputValidation: boolean;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Default configuration for the TimeZest API client.
|
|
33
|
+
*/
|
|
34
|
+
export declare const CONFIG: TimeZestAPIConfig;
|
|
@@ -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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -15,6 +15,8 @@ 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
|
}
|
|
19
21
|
/**
|
|
20
22
|
* Represents the TimeZest API client.
|
|
@@ -82,4 +84,11 @@ export declare class TimeZestAPI {
|
|
|
82
84
|
* @returns A promise that resolves to the created scheduling request.
|
|
83
85
|
*/
|
|
84
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;
|
|
85
94
|
}
|
|
@@ -34,7 +34,7 @@ class TimeZestAPI {
|
|
|
34
34
|
*/
|
|
35
35
|
this.getResources = (...args_1) => __awaiter(this, [...args_1], void 0, function* (filter = null) {
|
|
36
36
|
const response = yield (0, makePaginatedRequest_1.makePaginatedRequest)(this, endpoints_1.API_ENDPOINTS.RESOURCES, "GET", null, filter);
|
|
37
|
-
return
|
|
37
|
+
return this.validateResponse(response, schemas_1.ResourceSchema);
|
|
38
38
|
});
|
|
39
39
|
this.apiKey = apiKey;
|
|
40
40
|
this.config = {
|
|
@@ -43,6 +43,7 @@ class TimeZestAPI {
|
|
|
43
43
|
baseUrl: (options === null || options === void 0 ? void 0 : options.baseUrl) || config_1.CONFIG.baseUrl,
|
|
44
44
|
maxRetryDelayMs: (options === null || options === void 0 ? void 0 : options.maxRetryDelayMs) || config_1.CONFIG.maxRetryDelayMs,
|
|
45
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) !== undefined ? options.outputValidation : config_1.CONFIG.outputValidation
|
|
46
47
|
};
|
|
47
48
|
this.log = (0, logger_1.buildLogger)(this.config.logger, this.config.logLevel);
|
|
48
49
|
// Log the initialization of the API client but remove apiKey
|
|
@@ -79,7 +80,7 @@ class TimeZestAPI {
|
|
|
79
80
|
getAgents() {
|
|
80
81
|
return __awaiter(this, arguments, void 0, function* (filter = null) {
|
|
81
82
|
const response = yield (0, makePaginatedRequest_1.makePaginatedRequest)(this, endpoints_1.API_ENDPOINTS.AGENTS, "GET", null, filter);
|
|
82
|
-
return
|
|
83
|
+
return this.validateResponse(response, schemas_1.AgentSchema);
|
|
83
84
|
});
|
|
84
85
|
}
|
|
85
86
|
/**
|
|
@@ -90,7 +91,7 @@ class TimeZestAPI {
|
|
|
90
91
|
getTeams() {
|
|
91
92
|
return __awaiter(this, arguments, void 0, function* (filter = null) {
|
|
92
93
|
const response = yield (0, makePaginatedRequest_1.makePaginatedRequest)(this, endpoints_1.API_ENDPOINTS.TEAMS, "GET", null, filter);
|
|
93
|
-
return
|
|
94
|
+
return this.validateResponse(response, schemas_1.TeamSchema);
|
|
94
95
|
});
|
|
95
96
|
}
|
|
96
97
|
/**
|
|
@@ -101,7 +102,7 @@ class TimeZestAPI {
|
|
|
101
102
|
getAppointmentTypes() {
|
|
102
103
|
return __awaiter(this, arguments, void 0, function* (filter = null) {
|
|
103
104
|
const response = yield (0, makePaginatedRequest_1.makePaginatedRequest)(this, endpoints_1.API_ENDPOINTS.APPOINTMENT_TYPES, "GET", null, filter);
|
|
104
|
-
return
|
|
105
|
+
return this.validateResponse(response, schemas_1.AppointmentTypeSchema);
|
|
105
106
|
});
|
|
106
107
|
}
|
|
107
108
|
/**
|
|
@@ -123,7 +124,7 @@ class TimeZestAPI {
|
|
|
123
124
|
getSchedulingRequests() {
|
|
124
125
|
return __awaiter(this, arguments, void 0, function* (filter = null) {
|
|
125
126
|
const response = yield (0, makePaginatedRequest_1.makePaginatedRequest)(this, endpoints_1.API_ENDPOINTS.SCHEDULING_REQUESTS, "GET", null, filter);
|
|
126
|
-
return
|
|
127
|
+
return this.validateResponse(response, schemas_1.SchedulingRequestSchema);
|
|
127
128
|
});
|
|
128
129
|
}
|
|
129
130
|
/**
|
|
@@ -137,6 +138,18 @@ class TimeZestAPI {
|
|
|
137
138
|
return response;
|
|
138
139
|
});
|
|
139
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
|
+
}
|
|
140
153
|
}
|
|
141
154
|
exports.TimeZestAPI = TimeZestAPI;
|
|
142
155
|
//# sourceMappingURL=index.js.map
|
package/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
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;YAChD,MAAM,QAAQ,GAAG,MAAM,IAAA,2CAAoB,EACzC,IAAI,EACJ,yBAAa,CAAC,SAAS,EACvB,KAAK,EACL,IAAI,EACJ,MAAM,CACP,CAAC;YACF,OAAO,IAAI,CAAC,gBAAgB,CAAC,QAAQ,EAAE,wBAAc,CAAC,CAAC;QACzD,CAAC,CAAA,CAAC;QA1EA,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,MAAM,GAAG;YACZ,QAAQ,EAAE,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,QAAQ,KAAI,eAAM,CAAC,QAAQ;YAC9C,MAAM,EAAE,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,MAAM,KAAI,eAAM,CAAC,MAAM;YACxC,OAAO,EAAE,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,OAAO,KAAI,eAAM,CAAC,OAAO;YAC3C,eAAe,EAAE,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,eAAe,KAAI,eAAM,CAAC,eAAe;YACnE,cAAc,EAAE,CA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ClB,CAAC;CACF;AA/MD,kCA+MC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "timezest",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "tsc",
|
|
@@ -26,6 +26,6 @@
|
|
|
26
26
|
},
|
|
27
27
|
"repository": {
|
|
28
28
|
"type": "git",
|
|
29
|
-
"url": "https://github.com/pncit/timezest.git"
|
|
29
|
+
"url": "git+https://github.com/pncit/timezest.git"
|
|
30
30
|
}
|
|
31
31
|
}
|
|
@@ -0,0 +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
|
+
*/
|
|
7
|
+
export type log = {
|
|
8
|
+
(level: LogLevel, message: string, data?: any): void;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Interface for a logger with various log levels.
|
|
12
|
+
*/
|
|
13
|
+
export interface Logger {
|
|
14
|
+
/** Logs a silent message (no output). */
|
|
15
|
+
silent: (message: string, data?: any) => void;
|
|
16
|
+
/** Logs an error message. */
|
|
17
|
+
error: (message: string, data?: any) => void;
|
|
18
|
+
/** Logs a warning message. */
|
|
19
|
+
warn: (message: string, data?: any) => void;
|
|
20
|
+
/** Logs an informational message. */
|
|
21
|
+
info: (message: string, data?: any) => void;
|
|
22
|
+
/** Logs an HTTP-related message. */
|
|
23
|
+
http: (message: string, data?: any) => void;
|
|
24
|
+
/** Logs a verbose message. */
|
|
25
|
+
verbose: (message: string, data?: any) => void;
|
|
26
|
+
/** Logs a debug message. */
|
|
27
|
+
debug: (message: string, data?: any) => void;
|
|
28
|
+
/** Logs a silly (very detailed) message. */
|
|
29
|
+
silly: (message: string, data?: any) => void;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Represents the available log levels and their priorities.
|
|
33
|
+
*/
|
|
34
|
+
export type LogLevel = "silent" | "error" | "warn" | "info" | "http" | "verbose" | "debug" | "silly";
|
|
35
|
+
/**
|
|
36
|
+
* A mapping of log levels to their priority values.
|
|
37
|
+
*/
|
|
38
|
+
export declare const logLevelPriority: Record<LogLevel, number>;
|
|
39
|
+
/**
|
|
40
|
+
* The default logger implementation that logs messages to the console.
|
|
41
|
+
*/
|
|
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
|
+
*/
|
|
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
|
+
*/
|
|
57
|
+
export declare function withLogging<T>(fn: (...args: any[]) => Promise<T>, instance: {
|
|
58
|
+
log: (level: LogLevel, message: string, data?: any) => void;
|
|
59
|
+
}, functionName: string): (...args: any[]) => Promise<T>;
|
|
@@ -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}`);
|
|
@@ -0,0 +1 @@
|
|
|
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,KAAK,EAAE,CAAC;IACR,KAAK,EAAE,CAAC;CACT,CAAC;AAEF;;GAEG;AACU,QAAA,aAAa,GAAW;IACnC,MAAM,EAAE,CAAC,QAAgB,EAAE,KAAW,EAAE,EAAE,GAAE,CAAC;IAC7C,KAAK,EAAE,CAAC,OAAe,EAAE,IAAU,EAAE,EAAE,CACrC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC;IAC9D,IAAI,EAAE,CAAC,OAAe,EAAE,IAAU,EAAE,EAAE,CACpC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC;IAC5D,IAAI,EAAE,CAAC,OAAe,EAAE,IAAU,EAAE,EAAE,CACpC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC;IAC5D,IAAI,EAAE,CAAC,OAAe,EAAE,IAAU,EAAE,EAAE,CACpC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,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AY,YAAY,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QAC1E,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC;YACjC,QAAQ,CAAC,GAAG,CAAC,OAAO,EAAE,WAAW,YAAY,eAAe,CAAC,CAAC;YAC9D,MAAM;gBACJ,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,EAAE,WAAW,YAAY,eAAe,EAAE;oBAC5D,MAAM;iBACP,CAAC;gBACJ,CAAC,CAAC,IAAI,CAAC;YACT,OAAO,MAAM,CAAC;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"}
|
|
@@ -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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EAAC,GAAG,EAAE,KAAK,CAAC,CAAC;gBAC1B,CAAC;YACH,CAAC;QACH,CAAC;QAED,MAAM,IAAI,KAAK,CACb,qBAAqB,cAAc,yBAAyB,QAAQ,EAAE,CACvE,CAAC;IACJ,CAAC;CAAA"}
|
package/.env
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
TIMEZEST_API_KEY=vrY7zjB222oYoJkehdl6s9SuItPXfLYE
|
package/dist/LICENSE
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2025 PNC IT
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
-
|
|
7
|
-
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
-
|
|
9
|
-
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/dist/README.md
DELETED
|
@@ -1,196 +0,0 @@
|
|
|
1
|
-
# TimeZest Node.js Module
|
|
2
|
-
|
|
3
|
-
This Node.js module provides a convenient and fully-typed interface for interacting with the [TimeZest API](https://developer.timezest.com/). It abstracts away the complexities of making HTTP requests, handling pagination, and managing API configurations, allowing developers to focus on building their applications.
|
|
4
|
-
|
|
5
|
-
## Features
|
|
6
|
-
|
|
7
|
-
- Simplified API interaction with the TimeZest API.
|
|
8
|
-
- Built-in support for logging and error handling.
|
|
9
|
-
- Automatic handling of paginated responses.
|
|
10
|
-
- Built-in support for request retries
|
|
11
|
-
- Fully typed with TypeScript for enhanced developer experience.
|
|
12
|
-
|
|
13
|
-
## Installation
|
|
14
|
-
|
|
15
|
-
Install the module using npm:
|
|
16
|
-
|
|
17
|
-
```bash
|
|
18
|
-
npm install timezest
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
## Getting Started
|
|
22
|
-
|
|
23
|
-
### Authentication and Configuration
|
|
24
|
-
|
|
25
|
-
To use the TimeZest API, you need an API key. Generate one from your TimeZest account under the API Keys section. Use the `TimeZestAPI` class to configure and interact with the API:
|
|
26
|
-
|
|
27
|
-
```typescript
|
|
28
|
-
import TimeZestAPI from "./index";
|
|
29
|
-
|
|
30
|
-
const apiKey = "your-api-key";
|
|
31
|
-
|
|
32
|
-
const timeZest = new TimeZestAPI(apiKey);
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
### Example Usage
|
|
36
|
-
|
|
37
|
-
#### Retrieve Agents
|
|
38
|
-
|
|
39
|
-
```typescript
|
|
40
|
-
async function fetchAgents() {
|
|
41
|
-
try {
|
|
42
|
-
const agents = await timeZest.getAgents();
|
|
43
|
-
console.log("Agents:", agents);
|
|
44
|
-
} catch (error) {
|
|
45
|
-
console.error("Error fetching agents:", error);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
fetchAgents();
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
#### Create a Scheduling Request
|
|
53
|
-
|
|
54
|
-
```typescript
|
|
55
|
-
async function createSchedulingRequest() {
|
|
56
|
-
try {
|
|
57
|
-
const request = await timeZest.createSchedulingRequest({
|
|
58
|
-
appointment_type_id: "12345",
|
|
59
|
-
end_user_email: "user@example.com",
|
|
60
|
-
end_user_name: "John Doe",
|
|
61
|
-
resources: [],
|
|
62
|
-
scheduled_agents: [],
|
|
63
|
-
selected_start_time: new Date().toISOString(),
|
|
64
|
-
selected_time_zone: "UTC",
|
|
65
|
-
});
|
|
66
|
-
console.log("Created Scheduling Request:", request);
|
|
67
|
-
} catch (error) {
|
|
68
|
-
console.error("Error creating scheduling request:", error);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
createSchedulingRequest();
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
### Supported Endpoints
|
|
76
|
-
|
|
77
|
-
The `TimeZestAPI` supports the following methods for interacting with the TimeZest public API:
|
|
78
|
-
|
|
79
|
-
```typescript
|
|
80
|
-
// Retrieve all agents
|
|
81
|
-
timeZest.getAgents(filter: string | null = null): Promise<Agent[]>
|
|
82
|
-
|
|
83
|
-
// Retrieve all appointment types
|
|
84
|
-
timeZest.getAppointmentTypes(filter: string | null = null): Promise<AppointmentType[]>
|
|
85
|
-
|
|
86
|
-
// Retrieve all resources
|
|
87
|
-
timeZest.getResources(filter: string | null = null): Promise<Resource[]>
|
|
88
|
-
|
|
89
|
-
// Retreive all scheduling reuests
|
|
90
|
-
timeZest.getSchedulingRequests(filter: string | null = null): Promise<SchedulingRequest[]>
|
|
91
|
-
|
|
92
|
-
// Retrieve a scheduling request by id
|
|
93
|
-
timeZest.getSchedulingRequest(id: string): Promise<SchedulingRequest>
|
|
94
|
-
|
|
95
|
-
// Create a scheduling request
|
|
96
|
-
timeZest.createSchedulingRequest(data: SchedulingRequest): Promise<SchedulingRequest>
|
|
97
|
-
|
|
98
|
-
// Retrieve all teams
|
|
99
|
-
timeZest.getTeams(filter: string | null = null): Promise<Team[]>
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
### Filtering Requests
|
|
103
|
-
|
|
104
|
-
Pass TQL statements into the request to filter your results
|
|
105
|
-
|
|
106
|
-
```typescript
|
|
107
|
-
async function fetchTier1Team() {
|
|
108
|
-
try {
|
|
109
|
-
const teams = await timeZest.getTeams('team.internal_name EQ Tier1');
|
|
110
|
-
console.log("Teams:", teams);
|
|
111
|
-
} catch (error) {
|
|
112
|
-
console.error("Error fetching teams:", error);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
fetchTier1Team();
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
### Paginated Requests
|
|
120
|
-
|
|
121
|
-
For endpoints that return paginated data, the library automatically handles pagination:
|
|
122
|
-
|
|
123
|
-
```typescript
|
|
124
|
-
async function fetchAllResources() {
|
|
125
|
-
try {
|
|
126
|
-
const resources = await timeZest.getResources();
|
|
127
|
-
console.log("Resources:", resources);
|
|
128
|
-
} catch (error) {
|
|
129
|
-
console.error("Error fetching resources:", error);
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
fetchAllResources();
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
## Retry Logic
|
|
137
|
-
|
|
138
|
-
The `TimeZestAPI` class includes built-in retry logic for handling transient errors, such as network issues or rate-limiting responses from the TimeZest API. You can configure the retry behavior using the following options when initializing the class:
|
|
139
|
-
|
|
140
|
-
- **`maxRetryTimeMs`**: The maximum amount of time (in milliseconds) to spend retrying a request. Defaults to a reasonable value defined in the configuration.
|
|
141
|
-
- **`maxRetryDelayMs`**: The maximum delay (in milliseconds) between retry attempts. This helps prevent excessive delays during retries.
|
|
142
|
-
|
|
143
|
-
### Example Configuration
|
|
144
|
-
|
|
145
|
-
```typescript
|
|
146
|
-
const options = {
|
|
147
|
-
maxRetryTimeMs: 30000, // Retry for up to 30 seconds
|
|
148
|
-
maxRetryDelayMs: 2000, // Wait up to 2 seconds between retries
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
const timeZest = new TimeZestAPI("your-api-key", options);
|
|
152
|
-
```
|
|
153
|
-
|
|
154
|
-
### How It Works
|
|
155
|
-
|
|
156
|
-
When a request fails due to a transient error (e.g., a 429 Too Many Requests response or a network timeout), the library will automatically retry the request until the `maxRetryTimeMs` limit is reached. The delay between retries is capped by `maxRetryDelayMs` and may increase with each attempt to avoid overwhelming the server.
|
|
157
|
-
|
|
158
|
-
This retry logic ensures that your application can gracefully handle temporary issues without requiring manual intervention.
|
|
159
|
-
|
|
160
|
-
## Logging
|
|
161
|
-
|
|
162
|
-
The `TimeZestAPI` class includes built-in logging. By default, it uses `console` for logging. You can configure the log level using the `logLevel` option when initializing the class. Supported log levels include `silent`, `error`, `warn`, `info`, and `debug`.
|
|
163
|
-
|
|
164
|
-
You can also pass a custom logger by providing a `logger` object with methods corresponding to the log levels (e.g., `info`, `error`, etc.).
|
|
165
|
-
|
|
166
|
-
Example:
|
|
167
|
-
|
|
168
|
-
```typescript
|
|
169
|
-
const customLogger = {
|
|
170
|
-
info: (message: string, data?: any) => {
|
|
171
|
-
/* custom implementation */
|
|
172
|
-
},
|
|
173
|
-
error: (message: string, data?: any) => {
|
|
174
|
-
/* custom implementation */
|
|
175
|
-
},
|
|
176
|
-
// ...other log levels
|
|
177
|
-
};
|
|
178
|
-
|
|
179
|
-
const options = {
|
|
180
|
-
logger: customLogger,
|
|
181
|
-
logLevel: "info",
|
|
182
|
-
};
|
|
183
|
-
|
|
184
|
-
const timeZest = new TimeZestAPI(apiKey, options);
|
|
185
|
-
|
|
186
|
-
timeZest.log("info", "This is an informational message");
|
|
187
|
-
timeZest.log("error", "This is an error message");
|
|
188
|
-
```
|
|
189
|
-
|
|
190
|
-
## Documentation
|
|
191
|
-
|
|
192
|
-
For detailed API documentation, visit the [TimeZest API Documentation](https://developer.timezest.com/).
|
|
193
|
-
|
|
194
|
-
## License
|
|
195
|
-
|
|
196
|
-
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
|
package/dist/config/config.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/config/config.ts"],"names":[],"mappings":";;;AAAA,4CAAkE;AAUrD,QAAA,MAAM,GAAsB;IACvC,QAAQ,EAAE,O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
7
|
-
"test": "node dist/src/tests/test.js",
|
|
8
|
-
"format": "prettier --write .",
|
|
9
|
-
"clean": "if exist dist rmdir /s /q dist",
|
|
10
|
-
"prep-publish": "npm run clean && npm run build && copy package.json dist\\package.json && copy README.md dist\\README.md && copy LICENSE dist\\LICENSE",
|
|
11
|
-
"publish": "npm run prep-publish && npm publish .\\dist"
|
|
12
|
-
},
|
|
13
|
-
"keywords": [],
|
|
14
|
-
"author": "",
|
|
15
|
-
"license": "MIT",
|
|
16
|
-
"description": "",
|
|
17
|
-
"dependencies": {
|
|
18
|
-
"axios": "^1.9.0",
|
|
19
|
-
"dotenv": "^16.5.0",
|
|
20
|
-
"zod": "^3.24.3"
|
|
21
|
-
},
|
|
22
|
-
"devDependencies": {
|
|
23
|
-
"prettier": "^3.5.3",
|
|
24
|
-
"@types/node": "^22.15.3",
|
|
25
|
-
"typescript": "^5.8.3"
|
|
26
|
-
}
|
|
27
|
-
}
|
package/dist/utils/logger.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export type log = {
|
|
2
|
-
(level: LogLevel, message: string, data?: any): void;
|
|
3
|
-
};
|
|
4
|
-
export interface Logger {
|
|
5
|
-
silent: (message: string, data?: any) => void;
|
|
6
|
-
error: (message: string, data?: any) => void;
|
|
7
|
-
warn: (message: string, data?: any) => void;
|
|
8
|
-
info: (message: string, data?: any) => void;
|
|
9
|
-
http: (message: string, data?: any) => void;
|
|
10
|
-
verbose: (message: string, data?: any) => void;
|
|
11
|
-
debug: (message: string, data?: any) => void;
|
|
12
|
-
silly: (message: string, data?: any) => void;
|
|
13
|
-
}
|
|
14
|
-
export type LogLevel = "silent" | "error" | "warn" | "info" | "http" | "verbose" | "debug" | "silly";
|
|
15
|
-
export declare const logLevelPriority: Record<LogLevel, number>;
|
|
16
|
-
export declare const defaultLogger: Logger;
|
|
17
|
-
export declare function buildLogger(logger: Logger, logLevel: LogLevel): (level: LogLevel, message: string, data?: any) => void;
|
|
18
|
-
export declare function withLogging<T>(fn: (...args: any[]) => Promise<T>, instance: {
|
|
19
|
-
log: (level: LogLevel, message: string, data?: any) => void;
|
|
20
|
-
}, functionName: string): (...args: any[]) => Promise<T>;
|
package/dist/utils/logger.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":";;;;;;;;;;;;AAsDA,kCASC;AAED,kCAsBC;AA9DY,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,KAAK,EAAE,CAAC;IACR,KAAK,EAAE,CAAC;CACT,CAAC;AAEW,QAAA,aAAa,GAAW;IACnC,MAAM,EAAE,CAAC,QAAgB,EAAE,KAAW,EAAE,EAAE,GAAE,CAAC;IAC7C,KAAK,EAAE,CAAC,OAAe,EAAE,IAAU,EAAE,EAAE,CACrC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC;IAC9D,IAAI,EAAE,CAAC,OAAe,EAAE,IAAU,EAAE,EAAE,CACpC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC;IAC5D,IAAI,EAAE,CAAC,OAAe,EAAE,IAAU,EAAE,EAAE,CACpC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI;IACnD,IAAI,EAAE,CAAC,OAAe,EAAE,IAAU,EAAE,EAAE,CACpC,IAAI,CAAC,CAAC,CAAC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Y,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QAC1E,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC;YACjC,QAAQ,CAAC,GAAG,CAAC,OAAO,EAAE,WAAW,YAAY,eAAe,CAAC,CAAC;YAC9D,MAAM;gBACJ,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,EAAE,WAAW,YAAY,eAAe,EAAE;oBAC5D,MAAM;iBACP,CAAC;gBACJ,CAAC,CAAC,IAAI,CAAC;YACT,OAAO,MAAM,CAAC;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/timezest-1.0.1.tgz
DELETED
|
Binary file
|
package/timezest-1.0.2.tgz
DELETED
|
Binary file
|
package/timezest-1.0.3.tgz
DELETED
|
Binary file
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|