@worknice/js-sdk 0.13.11 → 0.13.12
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/{_types-BiXOGWxp.d.ts → _types-CeswTuBG.d.ts} +1 -0
- package/dist/api/WorkniceIntegrationLogger.d.ts +17 -5
- package/dist/api/WorkniceIntegrationLogger.js +28 -11
- package/dist/api/WorkniceIntegrationLogger.js.map +1 -1
- package/dist/api/_types.d.ts +1 -1
- package/dist/api/_types.js.map +1 -1
- package/dist/api/createApiOperation.d.ts +1 -1
- package/dist/api/createWorkniceClient.d.ts +1 -1
- package/dist/api/createWorkniceClient.js +5 -5
- package/dist/api/createWorkniceClient.js.map +1 -1
- package/dist/api/operations/activateIntegration.d.ts +1 -1
- package/dist/api/operations/authorizeIntegration.d.ts +1 -1
- package/dist/api/operations/completeSync.d.ts +1 -1
- package/dist/api/operations/createApiToken.d.ts +1 -1
- package/dist/api/operations/createDataImport.d.ts +1 -1
- package/dist/api/operations/createLeaveRequest.d.ts +1 -1
- package/dist/api/operations/createPerson.d.ts +1 -1
- package/dist/api/operations/createPersonConnection.d.ts +1 -1
- package/dist/api/operations/createPersonDataImportLine.d.ts +1 -1
- package/dist/api/operations/deleteApiToken.d.ts +1 -1
- package/dist/api/operations/deletePersonConnection.d.ts +1 -1
- package/dist/api/operations/getApiTokens.d.ts +1 -1
- package/dist/api/operations/getIntegration.d.ts +1 -1
- package/dist/api/operations/getLeaveRequests.d.ts +1 -1
- package/dist/api/operations/getMyApps.d.ts +1 -1
- package/dist/api/operations/getPeople.d.ts +1 -1
- package/dist/api/operations/getPersonConnections.d.ts +1 -1
- package/dist/api/operations/initializeIntegration.d.ts +1 -1
- package/dist/api/operations/updateLeaveRequest.d.ts +1 -1
- package/dist/api/operations/updatePerson.d.ts +1 -1
- package/dist/api/operations/updatePersonConnection.d.ts +1 -1
- package/dist/helpers/_types.d.ts +1 -1
- package/dist/helpers/handleApproveLeaveRequestWebhook.d.ts +3 -3
- package/dist/helpers/handleCancelLeaveRequestWebhook.d.ts +3 -3
- package/dist/helpers/handleCreateIntegrationWebhook.d.ts +2 -2
- package/dist/helpers/handleCreateLeaveRequestWebhook.d.ts +3 -3
- package/dist/helpers/handleDenyLeaveRequestWebhook.d.ts +3 -3
- package/dist/helpers/handleGetAuthorizationUrlWebhook.d.ts +2 -2
- package/dist/helpers/handleGetConfigurationUrlWebhook.d.ts +2 -2
- package/dist/helpers/handleGetLeaveBalancesWebhook.d.ts +2 -2
- package/dist/helpers/handleGetLeaveCategoriesWebhook.d.ts +3 -3
- package/dist/helpers/handleGetLeaveRequestHoursWebhook.d.ts +2 -2
- package/dist/helpers/handleGetOpenUrlWebhook.d.ts +2 -2
- package/dist/helpers/handleIntegrationArchivedWebhook.d.ts +2 -2
- package/dist/helpers/handlePersonConnectedWebhook.d.ts +2 -2
- package/dist/helpers/handleProcessLeaveRequestWebhook.d.ts +3 -3
- package/dist/helpers/handleRequest.d.ts +2 -2
- package/dist/helpers/handleRequest.js +64 -47
- package/dist/helpers/handleRequest.js.map +1 -1
- package/dist/helpers/handleRequestWithWorknice.d.ts +2 -2
- package/dist/helpers/handleRequestWithWorknice.js +3 -0
- package/dist/helpers/handleRequestWithWorknice.js.map +1 -1
- package/dist/helpers/handleTriggerIntegrationSyncWebhook.d.ts +2 -2
- package/dist/helpers/index.d.ts +1 -1
- package/package.json +3 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { W as WorkniceClient } from '../_types-
|
|
1
|
+
import { W as WorkniceClient } from '../_types-CeswTuBG.js';
|
|
2
2
|
import './_generated.js';
|
|
3
3
|
|
|
4
4
|
type Logger = Pick<Console, "debug" | "error" | "info" | "warn"> & Partial<Pick<Console, "group" | "groupEnd">>;
|
|
@@ -22,6 +22,10 @@ type WorkniceIntegrationLoggerOptions = {
|
|
|
22
22
|
* A Console-like object with which messages will be logger.
|
|
23
23
|
*/
|
|
24
24
|
logger: Logger;
|
|
25
|
+
/**
|
|
26
|
+
* The correlation ID to include in all log messages.
|
|
27
|
+
*/
|
|
28
|
+
correlationId?: string;
|
|
25
29
|
};
|
|
26
30
|
/**
|
|
27
31
|
* A logger that can log messages to both a Console-like object and to a
|
|
@@ -62,9 +66,11 @@ declare class WorkniceIntegrationLogger {
|
|
|
62
66
|
*/
|
|
63
67
|
private integrationId;
|
|
64
68
|
/**
|
|
65
|
-
* The
|
|
69
|
+
* The ID for the integration log to which the logs will be appended.
|
|
70
|
+
* This is set to the same value as correlationId to enable easy tracing
|
|
71
|
+
* between integration logs visible to users and platform logs in Axiom.
|
|
66
72
|
*/
|
|
67
|
-
|
|
73
|
+
readonly integrationLogId: string;
|
|
68
74
|
/**
|
|
69
75
|
* Determines when the logger should flush the logs. Calling info(), error(),
|
|
70
76
|
* warn(), indent() or dedent() will automatically flush the logs if the last
|
|
@@ -95,12 +101,18 @@ declare class WorkniceIntegrationLogger {
|
|
|
95
101
|
* @param options.debugLogType The type of console logging to use for debug messages. Defaults to "debug".
|
|
96
102
|
* @param options.delayBetweenFlushes The delay between flushes in milliseconds. Defaults to 1000 (1 second).
|
|
97
103
|
* @param options.logger A Console-like object with which messages can be logged. Defaults to the global console object.
|
|
104
|
+
* @param options.correlationId The correlation ID to include in all log messages.
|
|
98
105
|
* @example
|
|
99
106
|
* ```js
|
|
100
|
-
* const logger = new WorkniceIntegrationLogger({ logger: console });
|
|
107
|
+
* const logger = new WorkniceIntegrationLogger({ logger: console, correlationId: "abc123" });
|
|
101
108
|
* ```
|
|
102
109
|
*/
|
|
103
110
|
constructor(options?: Partial<WorkniceIntegrationLoggerOptions>);
|
|
111
|
+
/**
|
|
112
|
+
* Gets the correlation ID for this logger session.
|
|
113
|
+
* This will always return a value as correlationId is set during initialization.
|
|
114
|
+
*/
|
|
115
|
+
get correlationId(): string;
|
|
104
116
|
/**
|
|
105
117
|
* Connects the logger to a Worknice integration. If there are previously
|
|
106
118
|
* logged messages that need to be flushed, a new integration log will be
|
|
@@ -118,7 +130,7 @@ declare class WorkniceIntegrationLogger {
|
|
|
118
130
|
/**
|
|
119
131
|
* Logs an error of any type. The error will be logged to the configured logger
|
|
120
132
|
* with full stack traces and a chain of error causes. A simplified error
|
|
121
|
-
* message will sent to the Worknice integration logs (if connected) and
|
|
133
|
+
* message will be sent to the Worknice integration logs (if connected) and
|
|
122
134
|
* returned for displaying to the user. If the error is not an instance of
|
|
123
135
|
* Error, it will be coerced into a string before being logged.
|
|
124
136
|
*/
|
|
@@ -20,7 +20,9 @@ class WorkniceIntegrationLogger {
|
|
|
20
20
|
*/
|
|
21
21
|
integrationId = void 0;
|
|
22
22
|
/**
|
|
23
|
-
* The
|
|
23
|
+
* The ID for the integration log to which the logs will be appended.
|
|
24
|
+
* This is set to the same value as correlationId to enable easy tracing
|
|
25
|
+
* between integration logs visible to users and platform logs in Axiom.
|
|
24
26
|
*/
|
|
25
27
|
integrationLogId;
|
|
26
28
|
/**
|
|
@@ -53,19 +55,29 @@ class WorkniceIntegrationLogger {
|
|
|
53
55
|
* @param options.debugLogType The type of console logging to use for debug messages. Defaults to "debug".
|
|
54
56
|
* @param options.delayBetweenFlushes The delay between flushes in milliseconds. Defaults to 1000 (1 second).
|
|
55
57
|
* @param options.logger A Console-like object with which messages can be logged. Defaults to the global console object.
|
|
58
|
+
* @param options.correlationId The correlation ID to include in all log messages.
|
|
56
59
|
* @example
|
|
57
60
|
* ```js
|
|
58
|
-
* const logger = new WorkniceIntegrationLogger({ logger: console });
|
|
61
|
+
* const logger = new WorkniceIntegrationLogger({ logger: console, correlationId: "abc123" });
|
|
59
62
|
* ```
|
|
60
63
|
*/
|
|
61
64
|
constructor(options) {
|
|
62
|
-
|
|
65
|
+
const correlationId = options?.correlationId?.trim() || uuid();
|
|
66
|
+
this.integrationLogId = correlationId;
|
|
63
67
|
this.options = {
|
|
64
68
|
debugLogType: options?.debugLogType ?? "debug",
|
|
65
69
|
delayBetweenFlushes: options?.delayBetweenFlushes ?? 1e3,
|
|
66
|
-
logger: options?.logger ?? console
|
|
70
|
+
logger: options?.logger ?? console,
|
|
71
|
+
correlationId
|
|
67
72
|
};
|
|
68
73
|
}
|
|
74
|
+
/**
|
|
75
|
+
* Gets the correlation ID for this logger session.
|
|
76
|
+
* This will always return a value as correlationId is set during initialization.
|
|
77
|
+
*/
|
|
78
|
+
get correlationId() {
|
|
79
|
+
return this.options.correlationId;
|
|
80
|
+
}
|
|
69
81
|
/**
|
|
70
82
|
* Connects the logger to a Worknice integration. If there are previously
|
|
71
83
|
* logged messages that need to be flushed, a new integration log will be
|
|
@@ -82,8 +94,10 @@ class WorkniceIntegrationLogger {
|
|
|
82
94
|
* and are never sent to the Worknice integration logs.
|
|
83
95
|
*/
|
|
84
96
|
debug(message) {
|
|
85
|
-
|
|
86
|
-
|
|
97
|
+
const meta = { correlationId: this.options.correlationId };
|
|
98
|
+
if (this.options.debugLogType === "debug") {
|
|
99
|
+
this.options.logger.debug(message, meta);
|
|
100
|
+
} else this.options.logger.info(message, meta);
|
|
87
101
|
}
|
|
88
102
|
dedent(message) {
|
|
89
103
|
if (message !== void 0) this.info(message);
|
|
@@ -108,7 +122,7 @@ class WorkniceIntegrationLogger {
|
|
|
108
122
|
/**
|
|
109
123
|
* Logs an error of any type. The error will be logged to the configured logger
|
|
110
124
|
* with full stack traces and a chain of error causes. A simplified error
|
|
111
|
-
* message will sent to the Worknice integration logs (if connected) and
|
|
125
|
+
* message will be sent to the Worknice integration logs (if connected) and
|
|
112
126
|
* returned for displaying to the user. If the error is not an instance of
|
|
113
127
|
* Error, it will be coerced into a string before being logged.
|
|
114
128
|
*/
|
|
@@ -121,7 +135,8 @@ class WorkniceIntegrationLogger {
|
|
|
121
135
|
format: "simple",
|
|
122
136
|
stack: false
|
|
123
137
|
});
|
|
124
|
-
this.options.
|
|
138
|
+
const meta = { correlationId: this.options.correlationId };
|
|
139
|
+
this.options.logger.error(verboseMessage, meta);
|
|
125
140
|
this.enqueue(simpleMessage);
|
|
126
141
|
return simpleMessage;
|
|
127
142
|
}
|
|
@@ -162,7 +177,7 @@ class WorkniceIntegrationLogger {
|
|
|
162
177
|
`,
|
|
163
178
|
{
|
|
164
179
|
// Only create a new log the first time the logger is flushed.
|
|
165
|
-
createNewLog: this.logCreated
|
|
180
|
+
createNewLog: !this.logCreated,
|
|
166
181
|
entries,
|
|
167
182
|
integrationId: this.integrationId,
|
|
168
183
|
integrationLogId: this.integrationLogId
|
|
@@ -182,14 +197,16 @@ class WorkniceIntegrationLogger {
|
|
|
182
197
|
* logger and flushed to the Worknice integration logs if/when connected.
|
|
183
198
|
*/
|
|
184
199
|
info(message) {
|
|
185
|
-
this.options.
|
|
200
|
+
const meta = { correlationId: this.options.correlationId };
|
|
201
|
+
this.options.logger.info(message, meta);
|
|
186
202
|
this.enqueue(message);
|
|
187
203
|
}
|
|
188
204
|
timeSinceLastFlush() {
|
|
189
205
|
return this.lastFlush === null ? Number.MAX_SAFE_INTEGER : Temporal.Now.instant().since(this.lastFlush).total("milliseconds");
|
|
190
206
|
}
|
|
191
207
|
warn(message) {
|
|
192
|
-
this.options.
|
|
208
|
+
const meta = { correlationId: this.options.correlationId };
|
|
209
|
+
this.options.logger.warn(message, meta);
|
|
193
210
|
this.enqueue(message);
|
|
194
211
|
}
|
|
195
212
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/api/WorkniceIntegrationLogger.ts"],"sourcesContent":["import gql from \"dedent\";\nimport { Temporal } from \"temporal-polyfill\";\nimport { v4 as uuid } from \"uuid\";\n\nimport errorToString from \"../utils/errorToString.js\";\nimport type { WorkniceClient } from \"./_types.js\";\n\nexport type Logger = Pick<Console, \"debug\" | \"error\" | \"info\" | \"warn\"> &\n Partial<Pick<Console, \"group\" | \"groupEnd\">>;\n\nexport type WorkniceIntegrationLoggerOptions = {\n /**\n * The type of log to use for debug messages. If set to \"debug\", debug\n * messages will be logged using the logger.debug() method, but if set to\n * \"info\", debug messages will be logged using the logger.info() method.\n *\n * Irrespective of this option, debug messages are only logged to the\n * configured logger and are never sent to the Worknice integration logs.\n *\n * Defaults to \"debug\".\n */\n debugLogType: \"debug\" | \"info\";\n\n /**\n * The delay between flushes in milliseconds. Defaults to 1000 (1 second).\n */\n delayBetweenFlushes: number;\n\n /**\n * A Console-like object with which messages will be logger.\n */\n logger: Logger;\n};\n\n/**\n * A logger that can log messages to both a Console-like object and to a\n * Worknice integration's logs which can be viewed by a Worknice user.\n *\n * By default, messages are only logged to the configured logger, but when a\n * Worknice integration is connected using the connect() method, the messages\n * will also be sent to the Worknice integration logs.\n *\n * @example\n * ```js\n * const logger = new WorkniceIntegrationLogger();\n * logger.info(\"Hello, World!\");\n * logger.debug(\"This message will only be logged to the console.\");\n * logger.error(Error(\"This is an error message.\")); // full stack traces are logged to the console, but only the error message is sent to Worknice\n * logger.connect(workniceClient, integrationId); // connect the logger to a Worknice integration (can be done at any time, messages are buffered until the logger is connected)\n * logger.indent(\"Hello again!\"); // subsequent messages will be indented\n * logger.info(\"This message is indented.\"); // indented\n * logger.dedent(\"Goodbye!\"); // indented, subsequent messages will not be indented\n * await logger.flush(); // sends any unsent messages to Worknice (should be called at the end of the script to ensure all messages are sent)\n * ```\n */\nclass WorkniceIntegrationLogger {\n /**\n * The Worknice client used to send the logs to the server. If null, the logs\n * will be buffered until the logger is initialized.\n */\n private client: WorkniceClient | null = null;\n\n /**\n * A promise used to ensure that only one request is in progress at a time. If\n * a flush is called while a request is in progress, the flush will wait for\n * the request to finish before starting a new one.\n */\n private currentRequest: Promise<unknown> | null = null;\n\n /**\n * The integration ID the logs will be associated with. If undefined, the\n * logs will be buffered until the logger has been initialized.\n */\n private integrationId: string | undefined = undefined;\n\n /**\n * The random ID for the integration log to which the logs will be appended.\n */\n private integrationLogId: string;\n\n /**\n * Determines when the logger should flush the logs. Calling info(), error(),\n * warn(), indent() or dedent() will automatically flush the logs if the last\n * flush was more than 1 second ago.\n */\n private lastFlush: Temporal.Instant | null = null;\n\n /**\n * A flag is used to determine whether a new log should be created when the\n * logger is flushed. The first time the logger is flushed, a new log will be\n * created. Subsequent flushes will append to the existing log.\n */\n private logCreated = false;\n\n /**\n * Backlog of log messages that have not yet been sent to Worknice. The logs\n * will be sent to the server when the logger is flushed and the backlog will\n * be cleared.\n */\n private logs: Array<{ time: Temporal.Instant; message: string }> = [];\n\n /**\n * Determines the current indentation level of the log messages. The indent()\n * and dedent() functions can be used to increase or decrease the indentation\n * level.\n */\n private messageIndent = 0;\n\n private options: WorkniceIntegrationLoggerOptions;\n\n private timeout: NodeJS.Timeout | null = null;\n\n /**\n * @param options.debugLogType The type of console logging to use for debug messages. Defaults to \"debug\".\n * @param options.delayBetweenFlushes The delay between flushes in milliseconds. Defaults to 1000 (1 second).\n * @param options.logger A Console-like object with which messages can be logged. Defaults to the global console object.\n * @example\n * ```js\n * const logger = new WorkniceIntegrationLogger({ logger: console });\n * ```\n */\n constructor(options?: Partial<WorkniceIntegrationLoggerOptions>) {\n this.integrationLogId = uuid();\n this.options = {\n debugLogType: options?.debugLogType ?? \"debug\",\n delayBetweenFlushes: options?.delayBetweenFlushes ?? 1000,\n logger: options?.logger ?? console,\n };\n }\n\n /**\n * Connects the logger to a Worknice integration. If there are previously\n * logged messages that need to be flushed, a new integration log will be\n * instantly created and the messages flushed to it. Otherwise, an integration\n * log will be created if/when the first message is logged.\n */\n public connect(client: WorkniceClient, integrationId: string) {\n this.client = client;\n this.integrationId = integrationId;\n this.flush();\n }\n\n /**\n * Logs a debug message. Debug messages are only logged to the configured logger\n * and are never sent to the Worknice integration logs.\n */\n public debug(message: string) {\n if (this.options.debugLogType === \"debug\") this.options.logger.debug(message);\n else this.options.logger.info(message);\n }\n\n public dedent(message?: string) {\n if (message !== undefined) this.info(message);\n if (this.options.logger.groupEnd) this.options.logger.groupEnd();\n this.messageIndent = Math.max(0, this.messageIndent - 1);\n }\n\n private enqueue(message: string) {\n this.logs.push({\n time: Temporal.Now.instant(),\n message: message\n .split(\"\\n\")\n .map((line) => `${\" \".repeat(this.messageIndent * 2)}${line}`)\n .join(\"\\n\"),\n });\n\n // If the last flush was more than the delay between flushes, flush the logs\n // immediately. Otherwise, schedule a new flush unless one is already\n // scheduled.\n if (this.timeSinceLastFlush() >= this.options.delayBetweenFlushes) {\n this.flush();\n } else if (this.timeout === null) {\n this.timeout = setTimeout(() => {\n if (this.timeSinceLastFlush() >= this.options.delayBetweenFlushes) {\n this.flush();\n }\n }, this.options.delayBetweenFlushes - this.timeSinceLastFlush());\n }\n }\n\n /**\n * Logs an error of any type. The error will be logged to the configured logger\n * with full stack traces and a chain of error causes. A simplified error\n * message will sent to the Worknice integration logs (if connected) and\n * returned for displaying to the user. If the error is not an instance of\n * Error, it will be coerced into a string before being logged.\n */\n public error(error: unknown) {\n const verboseMessage = errorToString(error, {\n format: \"chain\",\n stack: true,\n });\n\n const simpleMessage = errorToString(error, {\n format: \"simple\",\n stack: false,\n });\n\n this.options.logger.error(verboseMessage);\n this.enqueue(simpleMessage);\n\n return simpleMessage;\n }\n\n /**\n * Flushes the log buffer to the server. The info() function will\n * automatically flush the logs if the last flush was more than 1 second\n * ago, but the flush() function should be called manually at the end of the\n * script to ensure that all logs are sent to the server.\n */\n public async flush() {\n // Clear any scheduled flushes.\n if (this.timeout) {\n clearTimeout(this.timeout);\n this.timeout = null;\n }\n\n // Update the last flush time to the current time so that any calls to\n // enqueue will not unnecessarily try to flush the logs again.\n this.lastFlush = Temporal.Now.instant();\n\n // If there's already a request in progress, wait for it to finish before\n // starting a new one.\n if (this.currentRequest) await this.currentRequest;\n\n // If there are no pending logs or the logger hasn't been initialized,\n // don't do anything (any logs will remain in the buffer until the next\n // flush).\n if (this.logs.length === 0 || this.client === null || this.integrationId === null) return;\n\n const entries = this.logs.splice(0).map(({ time, message }) => ({\n time: time.toString({ timeZone: \"Australia/Sydney\", smallestUnit: \"second\" }),\n message,\n }));\n\n this.currentRequest = this.client.fetchFromApi(\n gql`\n mutation AppendIntegrationLog(\n $createNewLog: Boolean!\n $entries: [IntegrationLogInput!]!\n $integrationId: ID!\n $integrationLogId: ID!\n ) {\n createIntegrationLog(integrationId: $integrationId, integrationLogId: $integrationLogId)\n @include(if: $createNewLog) {\n id\n }\n appendIntegrationLog(integrationLogId: $integrationLogId, entries: $entries) {\n id\n }\n }\n `,\n {\n // Only create a new log the first time the logger is flushed.\n createNewLog: this.logCreated === false,\n entries,\n integrationId: this.integrationId,\n integrationLogId: this.integrationLogId,\n },\n );\n\n // Only create a new log the first time the logger is flushed.\n this.logCreated = true;\n\n await this.currentRequest;\n\n // Clear the request promise so that the next flush can start a new request.\n this.currentRequest = null;\n }\n\n public indent(message?: string) {\n if (message !== undefined) this.info(message);\n if (this.options.logger.group) this.options.logger.group();\n this.messageIndent += 1;\n }\n\n /**\n * Logs an informational message. The message will be logged to the configured\n * logger and flushed to the Worknice integration logs if/when connected.\n */\n public info(message: string) {\n this.options.logger.info(message);\n this.enqueue(message);\n }\n\n private timeSinceLastFlush() {\n return this.lastFlush === null\n ? Number.MAX_SAFE_INTEGER\n : Temporal.Now.instant().since(this.lastFlush).total(\"milliseconds\");\n }\n\n public warn(message: string) {\n this.options.logger.warn(message);\n this.enqueue(message);\n }\n}\n\nexport default WorkniceIntegrationLogger;\n"],"mappings":"AAAA,OAAO,SAAS;AAChB,SAAS,gBAAgB;AACzB,SAAS,MAAM,YAAY;AAE3B,OAAO,mBAAmB;AAmD1B,MAAM,0BAA0B;AAAA;AAAA;AAAA;AAAA;AAAA,EAKtB,SAAgC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOhC,iBAA0C;AAAA;AAAA;AAAA;AAAA;AAAA,EAM1C,gBAAoC;AAAA;AAAA;AAAA;AAAA,EAKpC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,YAAqC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOrC,aAAa;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOb,OAA2D,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAO5D,gB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AAGX,SAAK,iBAAiB;AAAA,EACxB;AAAA,EAEO,OAAO,SAAkB;AAC9B,QAAI,YAAY,OAAW,MAAK,KAAK,OAAO;AAC5C,QAAI,KAAK,QAAQ,OAAO,MAAO,MAAK,QAAQ,OAAO,MAAM;AACzD,SAAK,iBAAiB;AAAA,EACxB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMO,KAAK,SAAiB;AAC3B,SAAK,QAAQ,OAAO,KAAK,OAAO;AAChC,SAAK,QAAQ,OAAO;AAAA,EACtB;AAAA,EAEQ,qBAAqB;AAC3B,WAAO,KAAK,cAAc,OACtB,OAAO,mBACP,SAAS,IAAI,QAAQ,EAAE,MAAM,KAAK,SAAS,EAAE,MAAM,cAAc;AAAA,EACvE;AAAA,EAEO,KAAK,SAAiB;AAC3B,SAAK,QAAQ,OAAO,KAAK,OAAO;AAChC,SAAK,QAAQ,OAAO;AAAA,EACtB;AACF;AAEA,IAAO,oCAAQ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/api/WorkniceIntegrationLogger.ts"],"sourcesContent":["import gql from \"dedent\";\nimport { Temporal } from \"temporal-polyfill\";\nimport { v4 as uuid } from \"uuid\";\n\nimport errorToString from \"../utils/errorToString.js\";\nimport type { WorkniceClient } from \"./_types.js\";\n\nexport type Logger = Pick<Console, \"debug\" | \"error\" | \"info\" | \"warn\"> &\n Partial<Pick<Console, \"group\" | \"groupEnd\">>;\n\nexport type WorkniceIntegrationLoggerOptions = {\n /**\n * The type of log to use for debug messages. If set to \"debug\", debug\n * messages will be logged using the logger.debug() method, but if set to\n * \"info\", debug messages will be logged using the logger.info() method.\n *\n * Irrespective of this option, debug messages are only logged to the\n * configured logger and are never sent to the Worknice integration logs.\n *\n * Defaults to \"debug\".\n */\n debugLogType: \"debug\" | \"info\";\n\n /**\n * The delay between flushes in milliseconds. Defaults to 1000 (1 second).\n */\n delayBetweenFlushes: number;\n\n /**\n * A Console-like object with which messages will be logger.\n */\n logger: Logger;\n\n /**\n * The correlation ID to include in all log messages.\n */\n correlationId?: string;\n};\n\n/**\n * A logger that can log messages to both a Console-like object and to a\n * Worknice integration's logs which can be viewed by a Worknice user.\n *\n * By default, messages are only logged to the configured logger, but when a\n * Worknice integration is connected using the connect() method, the messages\n * will also be sent to the Worknice integration logs.\n *\n * @example\n * ```js\n * const logger = new WorkniceIntegrationLogger();\n * logger.info(\"Hello, World!\");\n * logger.debug(\"This message will only be logged to the console.\");\n * logger.error(Error(\"This is an error message.\")); // full stack traces are logged to the console, but only the error message is sent to Worknice\n * logger.connect(workniceClient, integrationId); // connect the logger to a Worknice integration (can be done at any time, messages are buffered until the logger is connected)\n * logger.indent(\"Hello again!\"); // subsequent messages will be indented\n * logger.info(\"This message is indented.\"); // indented\n * logger.dedent(\"Goodbye!\"); // indented, subsequent messages will not be indented\n * await logger.flush(); // sends any unsent messages to Worknice (should be called at the end of the script to ensure all messages are sent)\n * ```\n */\nclass WorkniceIntegrationLogger {\n /**\n * The Worknice client used to send the logs to the server. If null, the logs\n * will be buffered until the logger is initialized.\n */\n private client: WorkniceClient | null = null;\n\n /**\n * A promise used to ensure that only one request is in progress at a time. If\n * a flush is called while a request is in progress, the flush will wait for\n * the request to finish before starting a new one.\n */\n private currentRequest: Promise<unknown> | null = null;\n\n /**\n * The integration ID the logs will be associated with. If undefined, the\n * logs will be buffered until the logger has been initialized.\n */\n private integrationId: string | undefined = undefined;\n\n /**\n * The ID for the integration log to which the logs will be appended.\n * This is set to the same value as correlationId to enable easy tracing\n * between integration logs visible to users and platform logs in Axiom.\n */\n public readonly integrationLogId: string;\n\n /**\n * Determines when the logger should flush the logs. Calling info(), error(),\n * warn(), indent() or dedent() will automatically flush the logs if the last\n * flush was more than 1 second ago.\n */\n private lastFlush: Temporal.Instant | null = null;\n\n /**\n * A flag is used to determine whether a new log should be created when the\n * logger is flushed. The first time the logger is flushed, a new log will be\n * created. Subsequent flushes will append to the existing log.\n */\n private logCreated = false;\n\n /**\n * Backlog of log messages that have not yet been sent to Worknice. The logs\n * will be sent to the server when the logger is flushed and the backlog will\n * be cleared.\n */\n private logs: Array<{ time: Temporal.Instant; message: string }> = [];\n\n /**\n * Determines the current indentation level of the log messages. The indent()\n * and dedent() functions can be used to increase or decrease the indentation\n * level.\n */\n private messageIndent = 0;\n\n private options: WorkniceIntegrationLoggerOptions;\n\n private timeout: NodeJS.Timeout | null = null;\n\n /**\n * @param options.debugLogType The type of console logging to use for debug messages. Defaults to \"debug\".\n * @param options.delayBetweenFlushes The delay between flushes in milliseconds. Defaults to 1000 (1 second).\n * @param options.logger A Console-like object with which messages can be logged. Defaults to the global console object.\n * @param options.correlationId The correlation ID to include in all log messages.\n * @example\n * ```js\n * const logger = new WorkniceIntegrationLogger({ logger: console, correlationId: \"abc123\" });\n * ```\n */\n constructor(options?: Partial<WorkniceIntegrationLoggerOptions>) {\n const correlationId = options?.correlationId?.trim() || uuid();\n this.integrationLogId = correlationId;\n this.options = {\n debugLogType: options?.debugLogType ?? \"debug\",\n delayBetweenFlushes: options?.delayBetweenFlushes ?? 1000,\n logger: options?.logger ?? console,\n correlationId,\n };\n }\n\n /**\n * Gets the correlation ID for this logger session.\n * This will always return a value as correlationId is set during initialization.\n */\n get correlationId(): string {\n return this.options.correlationId!;\n }\n\n /**\n * Connects the logger to a Worknice integration. If there are previously\n * logged messages that need to be flushed, a new integration log will be\n * instantly created and the messages flushed to it. Otherwise, an integration\n * log will be created if/when the first message is logged.\n */\n public connect(client: WorkniceClient, integrationId: string) {\n this.client = client;\n this.integrationId = integrationId;\n this.flush();\n }\n\n /**\n * Logs a debug message. Debug messages are only logged to the configured logger\n * and are never sent to the Worknice integration logs.\n */\n public debug(message: string) {\n const meta = { correlationId: this.options.correlationId };\n if (this.options.debugLogType === \"debug\") {\n this.options.logger.debug(message, meta);\n } else this.options.logger.info(message, meta);\n }\n\n public dedent(message?: string) {\n if (message !== undefined) this.info(message);\n if (this.options.logger.groupEnd) this.options.logger.groupEnd();\n this.messageIndent = Math.max(0, this.messageIndent - 1);\n }\n\n private enqueue(message: string) {\n this.logs.push({\n time: Temporal.Now.instant(),\n message: message\n .split(\"\\n\")\n .map((line) => `${\" \".repeat(this.messageIndent * 2)}${line}`)\n .join(\"\\n\"),\n });\n\n // If the last flush was more than the delay between flushes, flush the logs\n // immediately. Otherwise, schedule a new flush unless one is already\n // scheduled.\n if (this.timeSinceLastFlush() >= this.options.delayBetweenFlushes) {\n this.flush();\n } else if (this.timeout === null) {\n this.timeout = setTimeout(() => {\n if (this.timeSinceLastFlush() >= this.options.delayBetweenFlushes) {\n this.flush();\n }\n }, this.options.delayBetweenFlushes - this.timeSinceLastFlush());\n }\n }\n\n /**\n * Logs an error of any type. The error will be logged to the configured logger\n * with full stack traces and a chain of error causes. A simplified error\n * message will be sent to the Worknice integration logs (if connected) and\n * returned for displaying to the user. If the error is not an instance of\n * Error, it will be coerced into a string before being logged.\n */\n public error(error: unknown) {\n const verboseMessage = errorToString(error, {\n format: \"chain\",\n stack: true,\n });\n\n const simpleMessage = errorToString(error, {\n format: \"simple\",\n stack: false,\n });\n\n const meta = { correlationId: this.options.correlationId };\n this.options.logger.error(verboseMessage, meta);\n this.enqueue(simpleMessage);\n\n return simpleMessage;\n }\n\n /**\n * Flushes the log buffer to the server. The info() function will\n * automatically flush the logs if the last flush was more than 1 second\n * ago, but the flush() function should be called manually at the end of the\n * script to ensure that all logs are sent to the server.\n */\n public async flush() {\n // Clear any scheduled flushes.\n if (this.timeout) {\n clearTimeout(this.timeout);\n this.timeout = null;\n }\n\n // Update the last flush time to the current time so that any calls to\n // enqueue will not unnecessarily try to flush the logs again.\n this.lastFlush = Temporal.Now.instant();\n\n // If there's already a request in progress, wait for it to finish before\n // starting a new one.\n if (this.currentRequest) await this.currentRequest;\n\n // If there are no pending logs or the logger hasn't been initialized,\n // don't do anything (any logs will remain in the buffer until the next\n // flush).\n if (this.logs.length === 0 || this.client === null || this.integrationId === null) return;\n\n const entries = this.logs.splice(0).map(({ time, message }) => ({\n time: time.toString({ timeZone: \"Australia/Sydney\", smallestUnit: \"second\" }),\n message,\n }));\n\n this.currentRequest = this.client.fetchFromApi(\n gql`\n mutation AppendIntegrationLog(\n $createNewLog: Boolean!\n $entries: [IntegrationLogInput!]!\n $integrationId: ID!\n $integrationLogId: ID!\n ) {\n createIntegrationLog(integrationId: $integrationId, integrationLogId: $integrationLogId)\n @include(if: $createNewLog) {\n id\n }\n appendIntegrationLog(integrationLogId: $integrationLogId, entries: $entries) {\n id\n }\n }\n `,\n {\n // Only create a new log the first time the logger is flushed.\n createNewLog: !this.logCreated,\n entries,\n integrationId: this.integrationId,\n integrationLogId: this.integrationLogId,\n },\n );\n\n // Only create a new log the first time the logger is flushed.\n this.logCreated = true;\n\n await this.currentRequest;\n\n // Clear the request promise so that the next flush can start a new request.\n this.currentRequest = null;\n }\n\n public indent(message?: string) {\n if (message !== undefined) this.info(message);\n if (this.options.logger.group) this.options.logger.group();\n this.messageIndent += 1;\n }\n\n /**\n * Logs an informational message. The message will be logged to the configured\n * logger and flushed to the Worknice integration logs if/when connected.\n */\n public info(message: string) {\n const meta = { correlationId: this.options.correlationId };\n this.options.logger.info(message, meta);\n this.enqueue(message);\n }\n\n private timeSinceLastFlush() {\n return this.lastFlush === null\n ? Number.MAX_SAFE_INTEGER\n : Temporal.Now.instant().since(this.lastFlush).total(\"milliseconds\");\n }\n\n public warn(message: string) {\n const meta = { correlationId: this.options.correlationId };\n this.options.logger.warn(message, meta);\n this.enqueue(message);\n }\n}\n\nexport default WorkniceIntegrationLogger;\n"],"mappings":"AAAA,OAAO,SAAS;AAChB,SAAS,gBAAgB;AACzB,SAAS,MAAM,YAAY;AAE3B,OAAO,mBAAmB;AAwD1B,MAAM,0BAA0B;AAAA;AAAA;AAAA;AAAA;AAAA,EAKtB,SAAgC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOhC,iBAA0C;AAAA;AAAA;AAAA;AAAA;AAAA,EAM1C,gBAAoC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,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1,2 +1,2 @@
|
|
|
1
|
-
export { C as ClientConfig, a as FailedQueryResult, F as FetchOptions, Q as QueryResult, S as SuccessfulQueryResult, W as WorkniceClient } from '../_types-
|
|
1
|
+
export { C as ClientConfig, a as FailedQueryResult, F as FetchOptions, Q as QueryResult, S as SuccessfulQueryResult, W as WorkniceClient } from '../_types-CeswTuBG.js';
|
|
2
2
|
export { Account, AccountAppsArgs, AccountFeatures, AccountFeaturesInput, AccountFlag, ActivateIntegrationMutation, ActivateIntegrationMutationVariables, AllocationMethod, AnniversaryEvent, ApiToken, App, AppCategory, AppConfig, AppConfigWebhooks, AppStatus, AppendIntegrationLogMutation, AppendIntegrationLogMutationVariables, Approval, ApprovalStatus, ApprovalSummary, Archivable, Assignment, AssignmentNotification, AssignmentNotificationsArgs, AssignmentRelation, AssignmentStatus, AssignmentType, AuthMethod, AuthProvider, AuthState, AuthorizeIntegrationMutation, AuthorizeIntegrationMutationVariables, BasicAbnForm, BasicAbnFormNotificationsArgs, BasicAbnFormTemplate, BasicBankAccountForm, BasicBankAccountFormNotificationsArgs, BasicBankAccountFormTemplate, BasicEmergencyContactForm, BasicEmergencyContactFormNotificationsArgs, BasicEmergencyContactFormTemplate, BasicPersonalDetailsForm, BasicPersonalDetailsFormNotificationsArgs, BasicPersonalDetailsFormTemplate, BasicPreEmploymentForm, BasicPreEmploymentFormNotificationsArgs, BasicPreEmploymentFormTemplate, BasicSuperForm, BasicSuperFormNotificationsArgs, BasicSuperFormTemplate, BasicTaxForm, BasicTaxFormNotificationsArgs, BasicTaxFormTemplate, Birthday, BirthdayEvent, BirthdayInput, Bundle, BundledPaperworkType, BundledPaperworkTypeConnection, BundledPerson, BundledPersonConnection, BundledTemplate, BundledTemplateInput, Certificate, CertificateNotificationsArgs, CertificateProof, CertificateTemplate, ChoiceDocumentField, ChoiceDocumentFieldConfigInput, ChoiceDocumentFieldConfigOptionInput, ChoiceDocumentFieldInput, ChoiceDocumentFieldOption, ChoiceDocumentFieldOptionInput, CompleteSyncMutation, CompleteSyncMutationVariables, ConnectionRemote, ConnectionRemoteInput, ConnectionStatus, CreateApiTokenMutation, CreateApiTokenMutationVariables, CreateDataImportMutation, CreateDataImportMutationVariables, CreateLeaveRequestMutation, CreateLeaveRequestMutationVariables, CreateNoteAttachmentInput, CreatePersonConnectionMutation, CreatePersonConnectionMutationVariables, CreatePersonDataImportLineMutation, CreatePersonDataImportLineMutationVariables, CreatePersonMutation, CreatePersonMutationVariables, CustomTable, CustomTableColumn, CustomTableColumnInput, CustomTableConfig, CustomTableConfigFilter, CustomTableConfigFilterInput, CustomTableConfigInput, CustomTableConfigSorting, CustomTableConfigSortingInput, DataExport, DataExportType, DataImport, DataImportLine, DateDocumentField, DateDocumentFieldConfigInput, DateDocumentFieldInput, DeleteApiTokenMutation, DeleteApiTokenMutationVariables, DeletePersonConnectionMutation, DeletePersonConnectionMutationVariables, Department, DepartmentPositionsArgs, Document, DocumentField, DocumentFieldConfigInput, DocumentFieldInput, DocumentFieldResponder, DocumentNotificationsArgs, DocumentTemplate, EmailNotificationSettings, EmailNotificationSettingsInput, Exact, ExpiryStatus, FieldPresence, Gender, GenericIntegration, GenericIntegrationFeaturesArgs, GetApiTokensQuery, GetApiTokensQueryVariables, GetIntegrationQuery, GetIntegrationQueryVariables, GetLeaveRequestsQuery, GetLeaveRequestsQueryVariables, GetMyAppsQuery, GetMyAppsQueryVariables, GetPeopleQuery, GetPeopleQueryVariables, GetPersonConnectionsQuery, GetPersonConnectionsQueryVariables, Incremental, InitializeIntegrationMutation, InitializeIntegrationMutationVariables, InputMaybe, Integration, IntegrationConnection, IntegrationFeatures, IntegrationFeaturesArgs, IntegrationFeaturesInput, IntegrationLog, IntegrationLogInput, IntegrationStatus, IntegrationSync, IntegrationSyncEvent, IntegrationSyncEventType, IntegrationSyncStatus, IntegrationType, Job, JobStatus, KeypayBusiness, KeypayEmployee, KeypayEmployeeForm, KeypayEmployeeFormNotificationsArgs, KeypayEmployeeFormTemplate, KeypayEmployeeStatus, KeypayEmploymentType, KeypayGender, KeypayIntegration, KeypayIntegrationFeaturesArgs, KeypayLeaveEmployee, KeypayLeaveIntegration, KeypayLeaveIntegrationFeaturesArgs, LeaveBalance, LeaveCategory, LeaveCategoryInput, LeaveHoursEstimate, LeaveRequest, LeaveRequestNotification, LeaveRequestNotificationsArgs, LeaveRequestRelation, LeaveRequestStatus, Location, Login, MakeEmpty, MakeMaybe, MakeOptional, Maybe, Media, MultiLineTextDocumentField, MultiLineTextDocumentFieldConfigInput, MultiLineTextDocumentFieldInput, Mutation, MutationAcceptLoginArgs, MutationActivateIntegrationArgs, MutationActivatePersonArgs, MutationAddPeopleToBundlesArgs, MutationAddPeopleToTagsArgs, MutationAppendIntegrationLogArgs, MutationApproveAssignmentArgs, MutationApproveKeypayLeaveLeaveRequestArgs, MutationApproveLeaveRequestArgs, MutationApproveXeroLeaveRequestArgs, MutationArchiveAssignmentArgs, MutationArchiveBundleArgs, MutationArchiveCustomTableArgs, MutationArchiveIntegrationArgs, MutationArchiveLocationArgs, MutationArchiveNotesArgs, MutationArchiveOrgArgs, MutationArchivePaperworkTypeArgs, MutationArchivePersonArgs, MutationArchivePositionArgs, MutationArchiveReviewCycleArgs, MutationArchiveSavedQuestionArgs, MutationArchiveStandardReviewArgs, MutationArchiveStandardReviewTemplateArgs, MutationArchiveTemplateArgs, MutationAssignAssignmentsArgs, MutationAssignBasicAbnFormArgs, MutationAssignBasicBankAccountFormArgs, MutationAssignBasicEmergencyContactFormArgs, MutationAssignBasicPersonalDetailsFormArgs, MutationAssignBasicPreEmploymentFormArgs, MutationAssignBasicSuperFormArgs, MutationAssignBasicTaxFormArgs, MutationAssignCertificateArgs, MutationAssignDocumentArgs, MutationAssignKeypayEmployeeFormArgs, MutationAssignQuestionnaireArgs, MutationAssignStandardReviewArgs, MutationAssignTaskArgs, MutationAuthorizeIntegrationArgs, MutationCancelLeaveRequestArgs, MutationCompleteIntegrationSyncArgs, MutationCompletePasswordResetArgs, MutationConfirmEmailArgs, MutationConfirmProfileArgs, MutationConfirmProviderArgs, MutationCreateAccountArgs, MutationCreateApiTokenArgs, MutationCreateAssignmentsArgs, MutationCreateBasicAbnFormArgs, MutationCreateBasicAbnFormTemplateArgs, MutationCreateBasicBankAccountFormArgs, MutationCreateBasicBankAccountFormTemplateArgs, MutationCreateBasicEmergencyContactFormArgs, MutationCreateBasicEmergencyContactFormTemplateArgs, MutationCreateBasicPersonalDetailsFormArgs, MutationCreateBasicPersonalDetailsFormTemplateArgs, MutationCreateBasicPreEmploymentFormArgs, MutationCreateBasicPreEmploymentFormTemplateArgs, MutationCreateBasicSuperFormArgs, MutationCreateBasicSuperFormTemplateArgs, MutationCreateBasicTaxFormArgs, MutationCreateBasicTaxFormTemplateArgs, MutationCreateBundleArgs, MutationCreateBundledPersonArgs, MutationCreateCertificateArgs, MutationCreateCertificateTemplateArgs, MutationCreateCustomTableArgs, MutationCreateDataExportArgs, MutationCreateDataImportArgs, MutationCreateDocumentArgs, MutationCreateDocumentTemplateArgs, MutationCreateIntegrationArgs, MutationCreateIntegrationLogArgs, MutationCreateJobArgs, MutationCreateKeypayEmployeeFormArgs, MutationCreateKeypayEmployeeFormTemplateArgs, MutationCreateKeypayLeaveLeaveRequestArgs, MutationCreateLeaveRequestArgs, MutationCreateLocalPersonConnectionsArgs, MutationCreateLocationArgs, MutationCreateLoginArgs, MutationCreateManualDataImportArgs, MutationCreateNoteArgs, MutationCreateNoteAttachmentsArgs, MutationCreateOrgArgs, MutationCreatePaperworkTypeArgs, MutationCreatePersonArgs, MutationCreatePersonConnectionArgs, MutationCreatePersonDataImportLineArgs, MutationCreatePositionArgs, MutationCreateQuestionnaireArgs, MutationCreateQuestionnaireTemplateArgs, MutationCreateReviewCycleArgs, MutationCreateSavedQuestionArgs, MutationCreateStandaloneCertificateArgs, MutationCreateStandaloneDocumentArgs, MutationCreateStandaloneQuestionnaireArgs, MutationCreateStandaloneStandardReviewArgs, MutationCreateStandaloneTaskArgs, MutationCreateStandardReviewArgs, MutationCreateStandardReviewQuestionArgs, MutationCreateStandardReviewTemplateArgs, MutationCreateStandardReviewTemplateQuestionArgs, MutationCreateTagArgs, MutationCreateTagsArgs, MutationCreateTaskArgs, MutationCreateTaskTemplateArgs, MutationCreateXeroLeaveRequestArgs, MutationDeleteApiTokenArgs, MutationDeleteApprovalsArgs, MutationDeleteBundledPersonArgs, MutationDeleteJobArgs, MutationDeleteLeaveRequestArgs, MutationDeleteLoginArgs, MutationDeletePersonConnectionArgs, MutationDeletePersonConnectionsArgs, MutationDeletePositionArgs, MutationDeleteStandardReviewQuestionArgs, MutationDeleteStandardReviewTemplateQuestionArgs, MutationDeleteTagArgs, MutationDenyKeypayLeaveLeaveRequestArgs, MutationDenyLeaveRequestArgs, MutationDenyXeroLeaveRequestArgs, MutationDuplicatePaperworkTypeArgs, MutationDuplicateTemplateArgs, MutationInitializeIntegrationArgs, MutationInvitePeopleArgs, MutationInvitePersonArgs, MutationJoinOrgArgs, MutationLogInArgs, MutationLogInWithProviderArgs, MutationMarkNotificationsReadArgs, MutationMarkNotificationsUnreadArgs, MutationMergePaperworkTypesArgs, MutationPauseIntegrationArgs, MutationProcessAssignmentArgs, MutationProcessAssignmentsArgs, MutationProcessLeaveRequestArgs, MutationProcessStandardReviewArgs, MutationReassignAssignmentArgs, MutationReassignCertificateArgs, MutationReassignTaskArgs, MutationReinviteLoginArgs, MutationReinvitePeopleArgs, MutationReinvitePersonArgs, MutationRemovePaperworkTypeFromBundlesArgs, MutationRemovePeopleFromBundlesArgs, MutationRemovePeopleFromTagsArgs, MutationRequestApprovalsArgs, MutationRequestPasswordResetArgs, MutationResetXeroAuIntegrationArgs, MutationRestoreAssignmentArgs, MutationRestoreBundleArgs, MutationRestoreIntegrationArgs, MutationRestoreNotesArgs, MutationRestorePaperworkTypeArgs, MutationRestorePersonArgs, MutationRestoreReviewCycleArgs, MutationRestoreSavedQuestionArgs, MutationRestoreStandardReviewArgs, MutationRestoreStandardReviewTemplateArgs, MutationRestoreTemplateArgs, MutationScheduleStandardReviewArgs, MutationSetActiveLoginArgs, MutationSignUpArgs, MutationSubmitBasicAbnFormArgs, MutationSubmitBasicBankAccountFormArgs, MutationSubmitBasicEmergencyContactFormArgs, MutationSubmitBasicPersonalDetailsFormArgs, MutationSubmitBasicPreEmploymentFormArgs, MutationSubmitBasicSuperFormArgs, MutationSubmitBasicTaxFormArgs, MutationSubmitCertificateArgs, MutationSubmitDocumentArgs, MutationSubmitKeypayEmployeeFormArgs, MutationSubmitQuestionnaireArgs, MutationSubmitStandardReviewArgs, MutationSubmitStandardReviewQuestionArgs, MutationSubmitTaskArgs, MutationTerminatePersonArgs, MutationTriggerIntegrationSyncArgs, MutationUnmatchPersonConnectionsArgs, MutationUnpauseIntegrationArgs, MutationUnscheduleStandardReviewArgs, MutationUpdateAccountArgs, MutationUpdateAssignmentArgs, MutationUpdateAssignmentsArgs, MutationUpdateBasicAbnFormTemplateArgs, MutationUpdateBasicBankAccountFormTemplateArgs, MutationUpdateBasicEmergencyContactFormTemplateArgs, MutationUpdateBasicPersonalDetailsFormTemplateArgs, MutationUpdateBasicPreEmploymentFormTemplateArgs, MutationUpdateBasicSuperFormTemplateArgs, MutationUpdateBasicTaxFormTemplateArgs, MutationUpdateBundleArgs, MutationUpdateCertificateArgs, MutationUpdateCertificateTemplateArgs, MutationUpdateCustomTableArgs, MutationUpdateDocumentArgs, MutationUpdateDocumentTemplateArgs, MutationUpdateIntegrationArgs, MutationUpdateJobArgs, MutationUpdateKeypayEmployeeFormTemplateArgs, MutationUpdateKeypayIntegrationArgs, MutationUpdateKeypayLeaveIntegrationArgs, MutationUpdateLocationArgs, MutationUpdateNoteArgs, MutationUpdateOnboardingAssignmentsArgs, MutationUpdateOrgArgs, MutationUpdatePaperworkAssignmentArgs, MutationUpdatePaperworkTypeArgs, MutationUpdatePersonArgs, MutationUpdatePersonConnectionArgs, MutationUpdatePersonTagsArgs, MutationUpdatePositionArgs, MutationUpdatePositionsArgs, MutationUpdateQuestionnaireArgs, MutationUpdateQuestionnaireTemplateArgs, MutationUpdateReviewCycleArgs, MutationUpdateSavedQuestionArgs, MutationUpdateStandardReviewArgs, MutationUpdateStandardReviewQuestionArgs, MutationUpdateStandardReviewTemplateArgs, MutationUpdateStandardReviewTemplateQuestionArgs, MutationUpdateTagArgs, MutationUpdateTaskArgs, MutationUpdateTaskTemplateArgs, MutationUpdateUserPasswordArgs, MutationUpdateXeroAuIntegrationArgs, MutationUpdateXeroLeaveIntegrationArgs, Note, NoteAttachment, Notification, NotificationType, Org, OrgBundlesArgs, OrgFeatures, OrgFeaturesInput, OrgIntegrationsArgs, OrgLocationsArgs, OrgPaperworkSummariesArgs, OrgPaperworkTypesArgs, OrgPeopleArgs, OrgPositionsArgs, OrgReviewCyclesArgs, OrgSavedQuestionsArgs, OrgTemplatesArgs, PageInfo, PaperworkAssignment, PaperworkAssignmentNotificationsArgs, PaperworkSummary, PaperworkSummaryNew, PaperworkSummaryStatus, PaperworkTemplate, PaperworkTemplateConnection, PaperworkTemplateEdge, PaperworkType, PaperworkTypeTemplatesArgs, PayPeriod, Person, PersonAssignmentsArgs, PersonBankAccountsChange, PersonBankAccountsChangeInput, PersonCertificatesArgs, PersonChange, PersonConnection, PersonConnectionLeaveHoursEstimateArgs, PersonConnectionLeaveRequestsArgs, PersonCustomTablesArgs, PersonDataImportLine, PersonDataTransferConfigInput, PersonDateOfBirthChange, PersonDateOfBirthChangeInput, PersonDocumentsArgs, PersonEmergencyContactsChange, PersonEmergencyContactsChangeInput, PersonFullDetailsFragment, PersonFullNameChange, PersonFullNameChangeInput, PersonGenderChange, PersonGenderChangeInput, PersonNotesArgs, PersonNotificationsArgs, PersonPersonalEmailChange, PersonPersonalEmailChangeInput, PersonPersonalPhoneChange, PersonPersonalPhoneChangeInput, PersonPostalAddressChange, PersonPostalAddressChangeInput, PersonQuestionnairesArgs, PersonRemunerationChange, PersonResidentialAddressChange, PersonResidentialAddressChangeInput, PersonReviewsArgs, PersonRole, PersonStatus, PersonSuperFundsChange, PersonSuperFundsChangeInput, PersonTasksArgs, PersonTaxDetailsChange, PersonTaxDetailsChangeInput, PersonTenureChange, PersonTenureChangeInput, Position, Query, QueryAccountArgs, QueryAssignmentArgs, QueryBasicAbnFormTemplateArgs, QueryBasicBankAccountFormTemplateArgs, QueryBasicEmergencyContactFormTemplateArgs, QueryBasicPersonalDetailsFormTemplateArgs, QueryBasicPreEmploymentFormTemplateArgs, QueryBasicSuperFormTemplateArgs, QueryBasicTaxFormTemplateArgs, QueryBundleArgs, QueryCertificateArgs, QueryCertificateTemplateArgs, QueryCustomTableArgs, QueryDataImportArgs, QueryDataImportLineArgs, QueryDocumentArgs, QueryDocumentTemplateArgs, QueryIntegrationArgs, QueryJobArgs, QueryKeypayEmployeeArgs, QueryKeypayEmployeeFormTemplateArgs, QueryKeypayLeaveEmployeeArgs, QueryLeaveRequestArgs, QueryNoteArgs, QueryOrgArgs, QueryPaperworkTypeArgs, QueryPersonArgs, QueryPersonConnectionArgs, QueryPositionArgs, QueryQuestionnaireArgs, QueryQuestionnaireTemplateArgs, QueryReviewCycleArgs, QuerySavedQuestionArgs, QueryStandardReviewArgs, QueryStandardReviewTemplateArgs, QueryTaskArgs, QueryTaskTemplateArgs, QueryTemplateArgs, QueryUserArgs, Question, QuestionConfig, QuestionConfigInput, QuestionLikert5Config, QuestionLikert5ConfigInput, QuestionLikert5Response, QuestionLikert5ResponseInput, QuestionMultipleChoiceConfig, QuestionMultipleChoiceConfigInput, QuestionMultipleChoiceOtherConfig, QuestionMultipleChoiceOtherConfigInput, QuestionMultipleChoiceOtherResponse, QuestionMultipleChoiceOtherResponseInput, QuestionMultipleChoiceResponse, QuestionMultipleChoiceResponseInput, QuestionResponse, QuestionResponseInput, QuestionTemplateInput, QuestionTextConfig, QuestionTextConfigInput, QuestionTextResponse, QuestionTextResponseInput, QuestionType, Questionnaire, QuestionnaireNotificationsArgs, QuestionnaireQuestion, QuestionnaireQuestionAnswerInput, QuestionnaireQuestionInput, QuestionnaireTemplate, QuestionnaireTemplateQuestion, ReviewCycle, ReviewCycleReviewsArgs, ReviewRelation, SavedQuestion, Scalars, Session, SharedCalendarEvent, SignatureUploadDocumentField, SignatureUploadDocumentFieldConfigInput, SignatureUploadDocumentFieldInput, SmartDocumentField, SmartDocumentFieldConfigInput, SmartDocumentFieldInput, SmartDocumentFieldType, StandardReview, StandardReviewNotification, StandardReviewNotificationsArgs, StandardReviewQuestion, StandardReviewQuestionRespondent, StandardReviewQuestionsArgs, StandardReviewStatus, StandardReviewTemplate, StandardReviewTemplateQuestion, StartDateEvent, SuperFundNomination, Tag, TagColor, TagInput, Task, TaskNotificationsArgs, TaskTemplate, TaxEmploymentBasis, TaxFileNumberExemption, TaxResidencyStatus, Template, TemplateInput, TemplateParameter, TemplateParameterInput, TemplateParameterInputValue, TemplateParameterType, TemplateParameterValue, TextDocumentField, TextDocumentFieldConfigInput, TextDocumentFieldInput, UpdateLeaveRequestMutation, UpdateLeaveRequestMutationVariables, UpdateNoteAttachmentInput, UpdatePersonConnectionMutation, UpdatePersonConnectionMutationVariables, UpdatePersonMutation, UpdatePersonMutationVariables, Upload, User, XeroAuBankAccount, XeroAuEmployee, XeroAuEmploymentBasis, XeroAuGender, XeroAuIntegration, XeroAuIntegrationFeaturesArgs, XeroAuResidencyStatus, XeroAuSuperFund, XeroAuSuperMembership, XeroAuTfnExemptionType, XeroLeaveEmployee, XeroLeaveIntegration, XeroLeaveIntegrationFeaturesArgs } from './_generated.js';
|
package/dist/api/_types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/api/_types.ts"],"sourcesContent":["import type createWorkniceClient from \"./createWorkniceClient.js\";\n\nexport * from \"./_generated.js\";\n\nexport type SuccessfulQueryResult<Data extends object = object> =\n | Readonly<{ data: Data }>\n | Readonly<{ data: Data; errors: ReadonlyArray<GraphQLFormattedError> }>;\n\nexport type FailedQueryResult =\n | Readonly<{ data: null; errors: ReadonlyArray<GraphQLFormattedError> }>\n | Readonly<{ errors: ReadonlyArray<GraphQLFormattedError> }>;\n\nexport type QueryResult<Data extends object = object> =\n | SuccessfulQueryResult<Data>\n | FailedQueryResult;\n\nexport type FetchOptions = {\n signal?: AbortSignal;\n};\n\nexport type ClientConfig = {\n accessToken?: string;\n apiUrl?: string;\n};\n\nexport type WorkniceClient = ReturnType<typeof createWorkniceClient>;\n\ninterface GraphQLFormattedError {\n /**\n * A short, human-readable summary of the problem that **SHOULD NOT** change\n * from occurrence to occurrence of the problem, except for purposes of\n * localization.\n */\n readonly message: string;\n /**\n * If an error can be associated to a particular point in the requested\n * GraphQL document, it should contain a list of locations.\n */\n readonly locations?: ReadonlyArray<SourceLocation>;\n /**\n * If an error can be associated to a particular field in the GraphQL result,\n * it _must_ contain an entry with the key `path` that details the path of\n * the response field which experienced the error. This allows clients to\n * identify whether a null result is intentional or caused by a runtime error.\n */\n readonly path?: ReadonlyArray<string | number>;\n /**\n * Reserved for implementors to extend the protocol however they see fit,\n * and hence there are no additional restrictions on its contents.\n */\n readonly extensions?: {\n [key: string]: unknown;\n };\n}\n\ninterface SourceLocation {\n readonly line: number;\n readonly column: number;\n}\n"],"mappings":"AAEA,cAAc;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/api/_types.ts"],"sourcesContent":["import type createWorkniceClient from \"./createWorkniceClient.js\";\n\nexport * from \"./_generated.js\";\n\nexport type SuccessfulQueryResult<Data extends object = object> =\n | Readonly<{ data: Data }>\n | Readonly<{ data: Data; errors: ReadonlyArray<GraphQLFormattedError> }>;\n\nexport type FailedQueryResult =\n | Readonly<{ data: null; errors: ReadonlyArray<GraphQLFormattedError> }>\n | Readonly<{ errors: ReadonlyArray<GraphQLFormattedError> }>;\n\nexport type QueryResult<Data extends object = object> =\n | SuccessfulQueryResult<Data>\n | FailedQueryResult;\n\nexport type FetchOptions = {\n signal?: AbortSignal;\n};\n\nexport type ClientConfig = {\n accessToken?: string;\n apiUrl?: string;\n correlationId?: string;\n};\n\nexport type WorkniceClient = ReturnType<typeof createWorkniceClient>;\n\ninterface GraphQLFormattedError {\n /**\n * A short, human-readable summary of the problem that **SHOULD NOT** change\n * from occurrence to occurrence of the problem, except for purposes of\n * localization.\n */\n readonly message: string;\n /**\n * If an error can be associated to a particular point in the requested\n * GraphQL document, it should contain a list of locations.\n */\n readonly locations?: ReadonlyArray<SourceLocation>;\n /**\n * If an error can be associated to a particular field in the GraphQL result,\n * it _must_ contain an entry with the key `path` that details the path of\n * the response field which experienced the error. This allows clients to\n * identify whether a null result is intentional or caused by a runtime error.\n */\n readonly path?: ReadonlyArray<string | number>;\n /**\n * Reserved for implementors to extend the protocol however they see fit,\n * and hence there are no additional restrictions on its contents.\n */\n readonly extensions?: {\n [key: string]: unknown;\n };\n}\n\ninterface SourceLocation {\n readonly line: number;\n readonly column: number;\n}\n"],"mappings":"AAEA,cAAc;","names":[]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import './_generated.js';
|
|
2
|
-
export { c as default } from '../_types-
|
|
2
|
+
export { c as default } from '../_types-CeswTuBG.js';
|
|
@@ -23,11 +23,11 @@ import updatePerson from "./operations/updatePerson.js";
|
|
|
23
23
|
import updatePersonConnection from "./operations/updatePersonConnection.js";
|
|
24
24
|
const createWorkniceClient = (clientConfig) => {
|
|
25
25
|
const apiUrl = clientConfig?.apiUrl ?? "https://app.worknice.com/api/graphql";
|
|
26
|
-
const headers =
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
|
|
30
|
-
"
|
|
26
|
+
const headers = {
|
|
27
|
+
"content-type": "application/json",
|
|
28
|
+
...clientConfig?.accessToken && { "worknice-api-token": clientConfig.accessToken },
|
|
29
|
+
// TODO: replace the manual setting of the `X-Request-ID` header in favour of PROD-3608
|
|
30
|
+
...clientConfig?.correlationId && { "X-Request-ID": clientConfig.correlationId }
|
|
31
31
|
};
|
|
32
32
|
const fetchFromApi = async (query, variables, fetchOptions) => {
|
|
33
33
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/api/createWorkniceClient.ts"],"sourcesContent":["import RequestError from \"@worknice/utils/errors/RequestError\";\n\nimport type { ClientConfig, FetchOptions, SuccessfulQueryResult } from \"./_types.js\";\nimport ApiError, { ApiErrorCode } from \"./ApiError.js\";\nimport activateIntegration from \"./operations/activateIntegration.js\";\nimport authorizeIntegration from \"./operations/authorizeIntegration.js\";\nimport completeSync from \"./operations/completeSync.js\";\nimport createApiToken from \"./operations/createApiToken.js\";\nimport createDataImport from \"./operations/createDataImport.js\";\nimport createLeaveRequest from \"./operations/createLeaveRequest.js\";\nimport createPerson from \"./operations/createPerson.js\";\nimport createPersonConnection from \"./operations/createPersonConnection.js\";\nimport createPersonDataImportLine from \"./operations/createPersonDataImportLine.js\";\nimport deleteApiToken from \"./operations/deleteApiToken.js\";\nimport deletePersonConnection from \"./operations/deletePersonConnection.js\";\nimport getApiTokens from \"./operations/getApiTokens.js\";\nimport getIntegration from \"./operations/getIntegration.js\";\nimport getLeaveRequests from \"./operations/getLeaveRequests.js\";\nimport getMyApps from \"./operations/getMyApps.js\";\nimport getPeople from \"./operations/getPeople.js\";\nimport getPersonConnections from \"./operations/getPersonConnections.js\";\nimport initializeIntegration from \"./operations/initializeIntegration.js\";\nimport updateLeaveRequest from \"./operations/updateLeaveRequest.js\";\nimport updatePerson from \"./operations/updatePerson.js\";\nimport updatePersonConnection from \"./operations/updatePersonConnection.js\";\n\nconst createWorkniceClient = (clientConfig?: ClientConfig) => {\n const apiUrl = clientConfig?.apiUrl ?? \"https://app.worknice.com/api/graphql\";\n\n const headers: HeadersInit =
|
|
1
|
+
{"version":3,"sources":["../../src/api/createWorkniceClient.ts"],"sourcesContent":["import RequestError from \"@worknice/utils/errors/RequestError\";\n\nimport type { ClientConfig, FetchOptions, SuccessfulQueryResult } from \"./_types.js\";\nimport ApiError, { ApiErrorCode } from \"./ApiError.js\";\nimport activateIntegration from \"./operations/activateIntegration.js\";\nimport authorizeIntegration from \"./operations/authorizeIntegration.js\";\nimport completeSync from \"./operations/completeSync.js\";\nimport createApiToken from \"./operations/createApiToken.js\";\nimport createDataImport from \"./operations/createDataImport.js\";\nimport createLeaveRequest from \"./operations/createLeaveRequest.js\";\nimport createPerson from \"./operations/createPerson.js\";\nimport createPersonConnection from \"./operations/createPersonConnection.js\";\nimport createPersonDataImportLine from \"./operations/createPersonDataImportLine.js\";\nimport deleteApiToken from \"./operations/deleteApiToken.js\";\nimport deletePersonConnection from \"./operations/deletePersonConnection.js\";\nimport getApiTokens from \"./operations/getApiTokens.js\";\nimport getIntegration from \"./operations/getIntegration.js\";\nimport getLeaveRequests from \"./operations/getLeaveRequests.js\";\nimport getMyApps from \"./operations/getMyApps.js\";\nimport getPeople from \"./operations/getPeople.js\";\nimport getPersonConnections from \"./operations/getPersonConnections.js\";\nimport initializeIntegration from \"./operations/initializeIntegration.js\";\nimport updateLeaveRequest from \"./operations/updateLeaveRequest.js\";\nimport updatePerson from \"./operations/updatePerson.js\";\nimport updatePersonConnection from \"./operations/updatePersonConnection.js\";\n\nconst createWorkniceClient = (clientConfig?: ClientConfig) => {\n const apiUrl = clientConfig?.apiUrl ?? \"https://app.worknice.com/api/graphql\";\n\n const headers: HeadersInit = {\n \"content-type\": \"application/json\",\n ...(clientConfig?.accessToken && { \"worknice-api-token\": clientConfig.accessToken }),\n // TODO: replace the manual setting of the `X-Request-ID` header in favour of PROD-3608\n ...(clientConfig?.correlationId && { \"X-Request-ID\": clientConfig.correlationId }),\n };\n\n /**\n * Generic helper function for interacting with the Worknice GraphQL API.\n */\n const fetchFromApi = async <Data extends object, Variables extends object>(\n query: string,\n variables?: Variables,\n fetchOptions?: FetchOptions,\n ): Promise<SuccessfulQueryResult<Data>> => {\n try {\n const response = await fetch(apiUrl, {\n ...fetchOptions,\n body: JSON.stringify({\n query,\n variables,\n }),\n credentials: \"include\",\n headers,\n method: \"POST\",\n });\n\n if (!response.ok) {\n throw new RequestError(\"POST\", response);\n }\n\n let result: unknown;\n\n try {\n result = await response.json();\n } catch (error) {\n throw Error(\"Unable to parse response body as JSON.\", { cause: error });\n }\n\n if (typeof result !== \"object\" || result === null) {\n throw Error(\"Response body is not an object.\");\n }\n\n if (!(\"data\" in result) || result.data === null) {\n const cause =\n \"errors\" in result && Array.isArray(result.errors)\n ? new AggregateError(\n result.errors.map((error: unknown) =>\n Error(\n typeof error === \"object\" &&\n error !== null &&\n \"message\" in error &&\n typeof error.message === \"string\"\n ? error.message\n : \"Unknown error.\",\n ),\n ),\n )\n : undefined;\n\n if (!(\"data\" in result)) {\n throw new ApiError(ApiErrorCode.INVALID_QUERY, { cause });\n }\n\n if (result.data === null) {\n throw new ApiError(ApiErrorCode.QUERY_EXECUTION_FAILED, { cause });\n }\n }\n\n return result as SuccessfulQueryResult<Data>;\n } catch (error) {\n if (error instanceof ApiError) {\n throw error;\n }\n throw new ApiError(ApiErrorCode.UNEXPECTED_RESPONSE, { cause: error });\n }\n };\n\n const context = {\n fetchFromApi,\n };\n\n return {\n fetchFromApi,\n\n /**\n * Transitions an integration with an 'UNAUTHORIZED' or 'UNCONFIGURED'\n * status to an 'ACTIVE' status. Optionally, the name of the integration can\n * be set at the same time.\n */\n activateIntegration: activateIntegration(context),\n\n authorizeIntegration: authorizeIntegration(context),\n\n completeSync: completeSync(context),\n\n /**\n * Creates a new API token belonging to the current person.\n */\n createApiToken: createApiToken(context),\n\n createDataImport: createDataImport(context),\n\n createLeaveRequest: createLeaveRequest(context),\n\n createPerson: createPerson(context),\n\n createPersonConnection: createPersonConnection(context),\n\n createPersonDataImportLine: createPersonDataImportLine(context),\n\n /**\n * Permanently deletes an API token belonging to the current person.\n */\n deleteApiToken: deleteApiToken(context),\n\n deletePersonConnection: deletePersonConnection(context),\n\n /**\n * Transitions an integration with an 'UNINITIALIZED' status to an 'UNAUTHORIZED' status.\n */\n initializeIntegration: initializeIntegration(context),\n\n /**\n * Returns a list of API tokens belonging to the current person. This will not\n * include the token values themselves as they are only available when the\n * token is initially created.\n *\n * If there is no person associated with the session, a `NO_PERSON` error will\n * be thrown.\n */\n getApiTokens: getApiTokens(context),\n\n getMyApps: getMyApps(context),\n\n getIntegration: getIntegration(context),\n\n getLeaveRequests: getLeaveRequests(context),\n\n getPeople: getPeople(context),\n\n getPersonConnections: getPersonConnections(context),\n\n updateLeaveRequest: updateLeaveRequest(context),\n\n updatePerson: updatePerson(context),\n\n updatePersonConnection: updatePersonConnection(context),\n };\n};\n\nexport default createWorkniceClient;\n"],"mappings":"AAAA,OAAO,kBAAkB;AAGzB,OAAO,YAAY,oBAAoB;AACvC,OAAO,yBAAyB;AAChC,OAAO,0BAA0B;AACjC,OAAO,kBAAkB;AACzB,OAAO,oBAAoB;AAC3B,OAAO,sBAAsB;AAC7B,OAAO,wBAAwB;AAC/B,OAAO,kBAAkB;AACzB,OAAO,4BAA4B;AACnC,OAAO,gCAAgC;AACvC,OAAO,oBAAoB;AAC3B,OAAO,4BAA4B;AACnC,OAAO,kBAAkB;AACzB,OAAO,oBAAoB;AAC3B,OAAO,sBAAsB;AAC7B,OAAO,eAAe;AACtB,OAAO,eAAe;AACtB,OAAO,0BAA0B;AACjC,OAAO,2BAA2B;AAClC,OAAO,wBAAwB;AAC/B,OAAO,kBAAkB;AACzB,OAAO,4BAA4B;AAEnC,MAAM,uBAAuB,CAAC,iBAAgC;AAC5D,QAAM,SAAS,cAAc,UAAU;AAEvC,QAAM,UAAuB;AAAA,IAC3B,gBAAgB;AAAA,IAChB,GAAI,cAAc,eAAe,EAAE,sBAAsB,aAAa,YAAY;AAAA;AAAA,IAElF,GAAI,cAAc,iBAAiB,EAAE,gBAAgB,aAAa,cAAc;AAAA,EAClF;AAKA,QAAM,eAAe,OACnB,OACA,WACA,iBACyC;AACzC,QAAI;AACF,YAAM,WAAW,MAAM,MAAM,QAAQ;AAAA,QACnC,GAAG;AAAA,QACH,MAAM,KAAK,UAAU;AAAA,UACnB;AAAA,UACA;AAAA,QACF,CAAC;AAAA,QACD,aAAa;AAAA,QACb;AAAA,QACA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OAAO;AAAA,IAEtC,kBAAkB,iBAAiB,OAAO;AAAA,IAE1C,oBAAoB,mBAAmB,OAAO;AAAA,IAE9C,cAAc,aAAa,OAAO;AAAA,IAElC,wBAAwB,uBAAuB,OAAO;AAAA,IAEtD,4BAA4B,2BAA2B,OAAO;AAAA;AAAA;AAAA;AAAA,IAK9D,gBAAgB,eAAe,OAAO;AAAA,IAEtC,wBAAwB,uBAAuB,OAAO;AAAA;AAAA;AAAA;AAAA,IAKtD,uBAAuB,sBAAsB,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAUpD,cAAc,aAAa,OAAO;AAAA,IAElC,WAAW,UAAU,OAAO;AAAA,IAE5B,gBAAgB,eAAe,OAAO;AAAA,IAEtC,kBAAkB,iBAAiB,OAAO;AAAA,IAE1C,WAAW,UAAU,OAAO;AAAA,IAE5B,sBAAsB,qBAAqB,OAAO;AAAA,IAElD,oBAAoB,mBAAmB,OAAO;AAAA,IAE9C,cAAc,aAAa,OAAO;AAAA,IAElC,wBAAwB,uBAAuB,OAAO;AAAA,EACxD;AACF;AAEA,IAAO,+BAAQ;","names":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Exact, Scalars, InputMaybe } from '../_generated.js';
|
|
2
|
-
import { F as FetchOptions, S as SuccessfulQueryResult } from '../../_types-
|
|
2
|
+
import { F as FetchOptions, S as SuccessfulQueryResult } from '../../_types-CeswTuBG.js';
|
|
3
3
|
|
|
4
4
|
declare const activateIntegration: (context: {
|
|
5
5
|
fetchFromApi: <Data extends object, Variables extends object>(query: string, variables?: Variables, fetchOptions?: FetchOptions) => Promise<SuccessfulQueryResult<Data>>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Exact, Scalars } from '../_generated.js';
|
|
2
|
-
import { F as FetchOptions, S as SuccessfulQueryResult } from '../../_types-
|
|
2
|
+
import { F as FetchOptions, S as SuccessfulQueryResult } from '../../_types-CeswTuBG.js';
|
|
3
3
|
|
|
4
4
|
declare const authorizeIntegration: (context: {
|
|
5
5
|
fetchFromApi: <Data extends object, Variables extends object>(query: string, variables?: Variables, fetchOptions?: FetchOptions) => Promise<SuccessfulQueryResult<Data>>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Exact, Scalars } from '../_generated.js';
|
|
2
|
-
import { F as FetchOptions, S as SuccessfulQueryResult } from '../../_types-
|
|
2
|
+
import { F as FetchOptions, S as SuccessfulQueryResult } from '../../_types-CeswTuBG.js';
|
|
3
3
|
|
|
4
4
|
declare const completeSync: (context: {
|
|
5
5
|
fetchFromApi: <Data extends object, Variables extends object>(query: string, variables?: Variables, fetchOptions?: FetchOptions) => Promise<SuccessfulQueryResult<Data>>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Exact, Scalars } from '../_generated.js';
|
|
2
|
-
import { F as FetchOptions, S as SuccessfulQueryResult } from '../../_types-
|
|
2
|
+
import { F as FetchOptions, S as SuccessfulQueryResult } from '../../_types-CeswTuBG.js';
|
|
3
3
|
|
|
4
4
|
declare const createApiToken: (context: {
|
|
5
5
|
fetchFromApi: <Data extends object, Variables extends object>(query: string, variables?: Variables, fetchOptions?: FetchOptions) => Promise<SuccessfulQueryResult<Data>>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Exact, Scalars } from '../_generated.js';
|
|
2
|
-
import { F as FetchOptions, S as SuccessfulQueryResult } from '../../_types-
|
|
2
|
+
import { F as FetchOptions, S as SuccessfulQueryResult } from '../../_types-CeswTuBG.js';
|
|
3
3
|
|
|
4
4
|
declare const createDataImport: (context: {
|
|
5
5
|
fetchFromApi: <Data extends object, Variables extends object>(query: string, variables?: Variables, fetchOptions?: FetchOptions) => Promise<SuccessfulQueryResult<Data>>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Exact, Scalars, InputMaybe, LeaveCategoryInput, LeaveRequestStatus } from '../_generated.js';
|
|
2
|
-
import { F as FetchOptions, S as SuccessfulQueryResult } from '../../_types-
|
|
2
|
+
import { F as FetchOptions, S as SuccessfulQueryResult } from '../../_types-CeswTuBG.js';
|
|
3
3
|
|
|
4
4
|
declare const createLeaveRequest: (context: {
|
|
5
5
|
fetchFromApi: <Data extends object, Variables extends object>(query: string, variables?: Variables, fetchOptions?: FetchOptions) => Promise<SuccessfulQueryResult<Data>>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Exact, Scalars, PersonRole, AllocationMethod, Gender, TaxResidencyStatus, SuperFundNomination, TaxFileNumberExemption } from '../_generated.js';
|
|
2
|
-
import { F as FetchOptions, S as SuccessfulQueryResult } from '../../_types-
|
|
2
|
+
import { F as FetchOptions, S as SuccessfulQueryResult } from '../../_types-CeswTuBG.js';
|
|
3
3
|
|
|
4
4
|
declare const createPerson: (context: {
|
|
5
5
|
fetchFromApi: <Data extends object, Variables extends object>(query: string, variables?: Variables, fetchOptions?: FetchOptions) => Promise<SuccessfulQueryResult<Data>>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { F as FetchOptions, S as SuccessfulQueryResult } from '../../_types-
|
|
1
|
+
import { F as FetchOptions, S as SuccessfulQueryResult } from '../../_types-CeswTuBG.js';
|
|
2
2
|
import { ConnectionStatus } from '../_generated.js';
|
|
3
3
|
|
|
4
4
|
declare const createPersonConnection: (context: {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Exact, InputMaybe, PersonBankAccountsChangeInput, PersonDataTransferConfigInput, Scalars, PersonDateOfBirthChangeInput, PersonEmergencyContactsChangeInput, PersonFullNameChangeInput, PersonGenderChangeInput, PersonPersonalEmailChangeInput, PersonPersonalPhoneChangeInput, PersonPostalAddressChangeInput, PersonResidentialAddressChangeInput, PersonSuperFundsChangeInput, PersonTaxDetailsChangeInput, PersonTenureChangeInput } from '../_generated.js';
|
|
2
|
-
import { F as FetchOptions, S as SuccessfulQueryResult } from '../../_types-
|
|
2
|
+
import { F as FetchOptions, S as SuccessfulQueryResult } from '../../_types-CeswTuBG.js';
|
|
3
3
|
|
|
4
4
|
declare const createPersonDataImportLine: (context: {
|
|
5
5
|
fetchFromApi: <Data extends object, Variables extends object>(query: string, variables?: Variables, fetchOptions?: FetchOptions) => Promise<SuccessfulQueryResult<Data>>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Exact, Scalars } from '../_generated.js';
|
|
2
|
-
import { F as FetchOptions, S as SuccessfulQueryResult } from '../../_types-
|
|
2
|
+
import { F as FetchOptions, S as SuccessfulQueryResult } from '../../_types-CeswTuBG.js';
|
|
3
3
|
|
|
4
4
|
declare const deleteApiToken: (context: {
|
|
5
5
|
fetchFromApi: <Data extends object, Variables extends object>(query: string, variables?: Variables, fetchOptions?: FetchOptions) => Promise<SuccessfulQueryResult<Data>>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Exact, Scalars } from '../_generated.js';
|
|
2
|
-
import { F as FetchOptions, S as SuccessfulQueryResult } from '../../_types-
|
|
2
|
+
import { F as FetchOptions, S as SuccessfulQueryResult } from '../../_types-CeswTuBG.js';
|
|
3
3
|
|
|
4
4
|
declare const deletePersonConnection: (context: {
|
|
5
5
|
fetchFromApi: <Data extends object, Variables extends object>(query: string, variables?: Variables, fetchOptions?: FetchOptions) => Promise<SuccessfulQueryResult<Data>>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Exact } from '../_generated.js';
|
|
2
|
-
import { F as FetchOptions, S as SuccessfulQueryResult } from '../../_types-
|
|
2
|
+
import { F as FetchOptions, S as SuccessfulQueryResult } from '../../_types-CeswTuBG.js';
|
|
3
3
|
|
|
4
4
|
declare const getApiTokens: (context: {
|
|
5
5
|
fetchFromApi: <Data extends object, Variables extends object>(query: string, variables?: Variables, fetchOptions?: FetchOptions) => Promise<SuccessfulQueryResult<Data>>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Exact, Scalars, IntegrationStatus, AppCategory } from '../_generated.js';
|
|
2
|
-
import { F as FetchOptions, S as SuccessfulQueryResult } from '../../_types-
|
|
2
|
+
import { F as FetchOptions, S as SuccessfulQueryResult } from '../../_types-CeswTuBG.js';
|
|
3
3
|
|
|
4
4
|
declare const getIntegration: (context: {
|
|
5
5
|
fetchFromApi: <Data extends object, Variables extends object>(query: string, variables?: Variables, fetchOptions?: FetchOptions) => Promise<SuccessfulQueryResult<Data>>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Exact, Scalars, LeaveRequestStatus } from '../_generated.js';
|
|
2
|
-
import { F as FetchOptions, S as SuccessfulQueryResult } from '../../_types-
|
|
2
|
+
import { F as FetchOptions, S as SuccessfulQueryResult } from '../../_types-CeswTuBG.js';
|
|
3
3
|
|
|
4
4
|
declare const getLeaveRequests: (context: {
|
|
5
5
|
fetchFromApi: <Data extends object, Variables extends object>(query: string, variables?: Variables, fetchOptions?: FetchOptions) => Promise<SuccessfulQueryResult<Data>>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Exact, AppCategory, AppStatus } from '../_generated.js';
|
|
2
|
-
import { F as FetchOptions, S as SuccessfulQueryResult } from '../../_types-
|
|
2
|
+
import { F as FetchOptions, S as SuccessfulQueryResult } from '../../_types-CeswTuBG.js';
|
|
3
3
|
|
|
4
4
|
declare const getMyApps: (context: {
|
|
5
5
|
fetchFromApi: <Data extends object, Variables extends object>(query: string, variables?: Variables, fetchOptions?: FetchOptions) => Promise<SuccessfulQueryResult<Data>>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Exact, Scalars, AllocationMethod, Gender, TaxResidencyStatus, SuperFundNomination, TaxFileNumberExemption } from '../_generated.js';
|
|
2
|
-
import { F as FetchOptions, S as SuccessfulQueryResult } from '../../_types-
|
|
2
|
+
import { F as FetchOptions, S as SuccessfulQueryResult } from '../../_types-CeswTuBG.js';
|
|
3
3
|
|
|
4
4
|
declare const getPeople: (context: {
|
|
5
5
|
fetchFromApi: <Data extends object, Variables extends object>(query: string, variables?: Variables, fetchOptions?: FetchOptions) => Promise<SuccessfulQueryResult<Data>>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Exact, Scalars, ConnectionStatus } from '../_generated.js';
|
|
2
|
-
import { F as FetchOptions, S as SuccessfulQueryResult } from '../../_types-
|
|
2
|
+
import { F as FetchOptions, S as SuccessfulQueryResult } from '../../_types-CeswTuBG.js';
|
|
3
3
|
|
|
4
4
|
declare const getPersonConnections: (context: {
|
|
5
5
|
fetchFromApi: <Data extends object, Variables extends object>(query: string, variables?: Variables, fetchOptions?: FetchOptions) => Promise<SuccessfulQueryResult<Data>>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Exact, Scalars } from '../_generated.js';
|
|
2
|
-
import { F as FetchOptions, S as SuccessfulQueryResult } from '../../_types-
|
|
2
|
+
import { F as FetchOptions, S as SuccessfulQueryResult } from '../../_types-CeswTuBG.js';
|
|
3
3
|
|
|
4
4
|
declare const initializeIntegration: (context: {
|
|
5
5
|
fetchFromApi: <Data extends object, Variables extends object>(query: string, variables?: Variables, fetchOptions?: FetchOptions) => Promise<SuccessfulQueryResult<Data>>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Exact, Scalars, InputMaybe, LeaveCategoryInput, LeaveRequestStatus } from '../_generated.js';
|
|
2
|
-
import { F as FetchOptions, S as SuccessfulQueryResult } from '../../_types-
|
|
2
|
+
import { F as FetchOptions, S as SuccessfulQueryResult } from '../../_types-CeswTuBG.js';
|
|
3
3
|
|
|
4
4
|
declare const updateLeaveRequest: (context: {
|
|
5
5
|
fetchFromApi: <Data extends object, Variables extends object>(query: string, variables?: Variables, fetchOptions?: FetchOptions) => Promise<SuccessfulQueryResult<Data>>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Exact, InputMaybe, Scalars, AllocationMethod, Gender, TaxResidencyStatus, SuperFundNomination, TaxFileNumberExemption } from '../_generated.js';
|
|
2
|
-
import { F as FetchOptions, S as SuccessfulQueryResult } from '../../_types-
|
|
2
|
+
import { F as FetchOptions, S as SuccessfulQueryResult } from '../../_types-CeswTuBG.js';
|
|
3
3
|
|
|
4
4
|
declare const updatePerson: (context: {
|
|
5
5
|
fetchFromApi: <Data extends object, Variables extends object>(query: string, variables?: Variables, fetchOptions?: FetchOptions) => Promise<SuccessfulQueryResult<Data>>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { F as FetchOptions, S as SuccessfulQueryResult } from '../../_types-
|
|
1
|
+
import { F as FetchOptions, S as SuccessfulQueryResult } from '../../_types-CeswTuBG.js';
|
|
2
2
|
import { ConnectionStatus } from '../_generated.js';
|
|
3
3
|
|
|
4
4
|
declare const updatePersonConnection: (context: {
|
package/dist/helpers/_types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import '../_types-
|
|
1
|
+
import { ApproveLeaveRequestRequestPayload, ApproveLeaveRequestResponsePayload } from '@worknice/utils/webhooks';
|
|
2
|
+
import { TaskContext, HandlerOptions } from './_types.js';
|
|
3
|
+
import '../_types-CeswTuBG.js';
|
|
4
4
|
import '../api/_generated.js';
|
|
5
5
|
import '../api/WorkniceIntegrationLogger.js';
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import '../_types-
|
|
1
|
+
import { CancelLeaveRequestRequestPayload, CancelLeaveRequestResponsePayload } from '@worknice/utils/webhooks';
|
|
2
|
+
import { TaskContext, HandlerOptions } from './_types.js';
|
|
3
|
+
import '../_types-CeswTuBG.js';
|
|
4
4
|
import '../api/_generated.js';
|
|
5
5
|
import '../api/WorkniceIntegrationLogger.js';
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CreateIntegrationRequestPayload } from '@worknice/utils/webhooks';
|
|
2
|
-
import {
|
|
3
|
-
import '../_types-
|
|
2
|
+
import { TaskContext, HandlerOptions } from './_types.js';
|
|
3
|
+
import '../_types-CeswTuBG.js';
|
|
4
4
|
import '../api/_generated.js';
|
|
5
5
|
import '../api/WorkniceIntegrationLogger.js';
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import '../_types-
|
|
1
|
+
import { CreateLeaveRequestRequestPayload, CreateLeaveRequestResponsePayload } from '@worknice/utils/webhooks';
|
|
2
|
+
import { TaskContext, HandlerOptions } from './_types.js';
|
|
3
|
+
import '../_types-CeswTuBG.js';
|
|
4
4
|
import '../api/_generated.js';
|
|
5
5
|
import '../api/WorkniceIntegrationLogger.js';
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import '../_types-
|
|
1
|
+
import { DenyLeaveRequestRequestPayload, DenyLeaveRequestResponsePayload } from '@worknice/utils/webhooks';
|
|
2
|
+
import { TaskContext, HandlerOptions } from './_types.js';
|
|
3
|
+
import '../_types-CeswTuBG.js';
|
|
4
4
|
import '../api/_generated.js';
|
|
5
5
|
import '../api/WorkniceIntegrationLogger.js';
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { GetAuthorizationUrlRequestPayload } from '@worknice/utils/webhooks';
|
|
2
|
-
import {
|
|
3
|
-
import '../_types-
|
|
2
|
+
import { TaskContext, HandlerOptions } from './_types.js';
|
|
3
|
+
import '../_types-CeswTuBG.js';
|
|
4
4
|
import '../api/_generated.js';
|
|
5
5
|
import '../api/WorkniceIntegrationLogger.js';
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { GetConfigurationUrlRequestPayload } from '@worknice/utils/webhooks';
|
|
2
|
-
import {
|
|
3
|
-
import '../_types-
|
|
2
|
+
import { TaskContext, HandlerOptions } from './_types.js';
|
|
3
|
+
import '../_types-CeswTuBG.js';
|
|
4
4
|
import '../api/_generated.js';
|
|
5
5
|
import '../api/WorkniceIntegrationLogger.js';
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { GetLeaveBalancesRequestPayload, GetLeaveBalancesResponsePayload } from '@worknice/utils/webhooks';
|
|
2
|
-
import {
|
|
3
|
-
import '../_types-
|
|
2
|
+
import { TaskContext, HandlerOptions } from './_types.js';
|
|
3
|
+
import '../_types-CeswTuBG.js';
|
|
4
4
|
import '../api/_generated.js';
|
|
5
5
|
import '../api/WorkniceIntegrationLogger.js';
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import '../_types-
|
|
1
|
+
import { GetLeaveCategoriesRequestPayload, GetLeaveCategoriesResponsePayload } from '@worknice/utils/webhooks';
|
|
2
|
+
import { TaskContext, HandlerOptions } from './_types.js';
|
|
3
|
+
import '../_types-CeswTuBG.js';
|
|
4
4
|
import '../api/_generated.js';
|
|
5
5
|
import '../api/WorkniceIntegrationLogger.js';
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { GetLeaveRequestHoursRequestPayload, GetLeaveRequestHoursResponsePayload } from '@worknice/utils/webhooks';
|
|
2
|
-
import {
|
|
3
|
-
import '../_types-
|
|
2
|
+
import { TaskContext, HandlerOptions } from './_types.js';
|
|
3
|
+
import '../_types-CeswTuBG.js';
|
|
4
4
|
import '../api/_generated.js';
|
|
5
5
|
import '../api/WorkniceIntegrationLogger.js';
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { GetOpenUrlRequestPayload } from '@worknice/utils/webhooks';
|
|
2
|
-
import {
|
|
3
|
-
import '../_types-
|
|
2
|
+
import { TaskContext, HandlerOptions } from './_types.js';
|
|
3
|
+
import '../_types-CeswTuBG.js';
|
|
4
4
|
import '../api/_generated.js';
|
|
5
5
|
import '../api/WorkniceIntegrationLogger.js';
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IntegrationArchivedRequestPayload, IntegrationArchivedResponsePayload } from '@worknice/utils/webhooks';
|
|
2
|
-
import {
|
|
3
|
-
import '../_types-
|
|
2
|
+
import { TaskContext, HandlerOptions } from './_types.js';
|
|
3
|
+
import '../_types-CeswTuBG.js';
|
|
4
4
|
import '../api/_generated.js';
|
|
5
5
|
import '../api/WorkniceIntegrationLogger.js';
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PersonConnectedRequestPayload } from '@worknice/utils/webhooks';
|
|
2
|
-
import {
|
|
3
|
-
import '../_types-
|
|
2
|
+
import { TaskContext, HandlerOptions } from './_types.js';
|
|
3
|
+
import '../_types-CeswTuBG.js';
|
|
4
4
|
import '../api/_generated.js';
|
|
5
5
|
import '../api/WorkniceIntegrationLogger.js';
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import '../_types-
|
|
1
|
+
import { ProcessLeaveRequestRequestPayload, ProcessLeaveRequestResponsePayload } from '@worknice/utils/webhooks';
|
|
2
|
+
import { TaskContext, HandlerOptions } from './_types.js';
|
|
3
|
+
import '../_types-CeswTuBG.js';
|
|
4
4
|
import '../api/_generated.js';
|
|
5
5
|
import '../api/WorkniceIntegrationLogger.js';
|
|
6
6
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import '../_types-
|
|
1
|
+
import { TaskContext, HandlerOptions } from './_types.js';
|
|
2
|
+
import '../_types-CeswTuBG.js';
|
|
3
3
|
import '../api/_generated.js';
|
|
4
4
|
import '../api/WorkniceIntegrationLogger.js';
|
|
5
5
|
|
|
@@ -1,61 +1,78 @@
|
|
|
1
|
+
import {
|
|
2
|
+
extractCorrelationIdFromHeaders,
|
|
3
|
+
generateCorrelationId,
|
|
4
|
+
runWithCorrelationId
|
|
5
|
+
} from "@worknice/instrumentation";
|
|
1
6
|
import WorkniceIntegrationLogger from "../api/WorkniceIntegrationLogger.js";
|
|
2
7
|
const handleRequest = async (request, tasks, options) => {
|
|
8
|
+
const correlationId = extractCorrelationIdFromHeaders(request.headers) || generateCorrelationId();
|
|
3
9
|
const logger = new WorkniceIntegrationLogger({
|
|
4
10
|
debugLogType: options?.debugLogType ?? (options?.debug ? "info" : "debug"),
|
|
5
|
-
logger: options?.logger ?? console
|
|
11
|
+
logger: options?.logger ?? console,
|
|
12
|
+
correlationId
|
|
6
13
|
});
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
logger.dedent("Finished parsing request.");
|
|
17
|
-
const result = await tasks.handleRequest({
|
|
18
|
-
env,
|
|
19
|
-
logger,
|
|
20
|
-
payload,
|
|
21
|
-
request
|
|
22
|
-
});
|
|
23
|
-
logger.debug("Handling request\u2026");
|
|
24
|
-
let response;
|
|
25
|
-
if (result instanceof Response) {
|
|
26
|
-
response = result;
|
|
27
|
-
} else if (typeof result === "object") {
|
|
28
|
-
response = new Response(JSON.stringify(result), {
|
|
29
|
-
headers: {
|
|
30
|
-
"Content-Type": "application/json"
|
|
31
|
-
},
|
|
32
|
-
status: "ok" in result && result.ok === false ? 400 : 200
|
|
14
|
+
return runWithCorrelationId(correlationId, async () => {
|
|
15
|
+
try {
|
|
16
|
+
logger.info(
|
|
17
|
+
options?.processName ? `Starting process: ${options.processName}` : "Starting process"
|
|
18
|
+
);
|
|
19
|
+
logger.indent("Parsing request\u2026");
|
|
20
|
+
const { env, payload } = await tasks.parseRequest({
|
|
21
|
+
logger,
|
|
22
|
+
request
|
|
33
23
|
});
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
24
|
+
logger.dedent("Finished parsing request.");
|
|
25
|
+
const result = await tasks.handleRequest({
|
|
26
|
+
env,
|
|
27
|
+
logger,
|
|
28
|
+
payload,
|
|
29
|
+
request
|
|
37
30
|
});
|
|
38
|
-
|
|
39
|
-
response
|
|
31
|
+
logger.debug("Handling request\u2026");
|
|
32
|
+
let response;
|
|
33
|
+
if (result instanceof Response) {
|
|
34
|
+
response = result;
|
|
35
|
+
} else if (typeof result === "object") {
|
|
36
|
+
response = new Response(JSON.stringify(result), {
|
|
37
|
+
headers: {
|
|
38
|
+
"Content-Type": "application/json",
|
|
39
|
+
"X-Request-ID": correlationId
|
|
40
|
+
},
|
|
41
|
+
status: "ok" in result && result.ok === false ? 400 : 200
|
|
42
|
+
});
|
|
43
|
+
} else if (typeof result === "string") {
|
|
44
|
+
response = new Response(result, {
|
|
45
|
+
headers: {
|
|
46
|
+
"X-Request-ID": correlationId
|
|
47
|
+
},
|
|
48
|
+
status: 200
|
|
49
|
+
});
|
|
50
|
+
} else {
|
|
51
|
+
response = new Response("ok", {
|
|
52
|
+
headers: {
|
|
53
|
+
"Content-Type": "application/json",
|
|
54
|
+
"X-Request-ID": correlationId
|
|
55
|
+
},
|
|
56
|
+
status: 200
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
logger.debug("Request handling completed successfully.");
|
|
60
|
+
return response;
|
|
61
|
+
} catch (error) {
|
|
62
|
+
const message = logger.error(error);
|
|
63
|
+
return new Response(message, {
|
|
40
64
|
headers: {
|
|
41
|
-
"
|
|
65
|
+
"X-Request-ID": correlationId
|
|
42
66
|
},
|
|
43
|
-
status:
|
|
67
|
+
status: 500
|
|
44
68
|
});
|
|
69
|
+
} finally {
|
|
70
|
+
logger.info(
|
|
71
|
+
options?.processName ? `Process complete: ${options.processName}` : "Process complete"
|
|
72
|
+
);
|
|
73
|
+
await logger.flush();
|
|
45
74
|
}
|
|
46
|
-
|
|
47
|
-
return response;
|
|
48
|
-
} catch (error) {
|
|
49
|
-
const message = logger.error(error);
|
|
50
|
-
return new Response(message, {
|
|
51
|
-
status: 500
|
|
52
|
-
});
|
|
53
|
-
} finally {
|
|
54
|
-
logger.info(
|
|
55
|
-
options?.processName ? `Process complete: ${options.processName}` : "Process complete"
|
|
56
|
-
);
|
|
57
|
-
await logger.flush();
|
|
58
|
-
}
|
|
75
|
+
});
|
|
59
76
|
};
|
|
60
77
|
var handleRequest_default = handleRequest;
|
|
61
78
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/helpers/handleRequest.ts"],"sourcesContent":["import WorkniceIntegrationLogger from \"../api/WorkniceIntegrationLogger.js\";\nimport type { HandlerOptions, TaskContext } from \"./_types.js\";\n\ntype Tasks<RequestPayload, ResponsePayload, Env = null, Req extends Request = Request> = {\n handleRequest: (\n context: Pick<TaskContext<RequestPayload, Env, Req>, \"env\" | \"logger\" | \"payload\" | \"request\">,\n ) => Promise<ResponsePayload>;\n parseRequest: (\n context: Pick<TaskContext<RequestPayload, Env, Req>, \"logger\" | \"request\">,\n ) => Promise<Pick<TaskContext<RequestPayload, Env, Req>, \"env\" | \"payload\">>;\n};\n\nconst handleRequest = async <\n RequestPayload,\n ResponsePayload extends Response | object | string | undefined | void = void,\n Env = null,\n Req extends Request = Request,\n>(\n request: Req,\n tasks: Tasks<RequestPayload, ResponsePayload, Env, Req>,\n options?: HandlerOptions,\n) => {\n const logger = new WorkniceIntegrationLogger({\n debugLogType: options?.debugLogType ?? (options?.debug ? \"info\" : \"debug\"),\n logger: options?.logger ?? console,\n });\n\n try {\n
|
|
1
|
+
{"version":3,"sources":["../../src/helpers/handleRequest.ts"],"sourcesContent":["import {\n extractCorrelationIdFromHeaders,\n generateCorrelationId,\n runWithCorrelationId,\n} from \"@worknice/instrumentation\";\n\nimport WorkniceIntegrationLogger from \"../api/WorkniceIntegrationLogger.js\";\nimport type { HandlerOptions, TaskContext } from \"./_types.js\";\n\ntype Tasks<RequestPayload, ResponsePayload, Env = null, Req extends Request = Request> = {\n handleRequest: (\n context: Pick<TaskContext<RequestPayload, Env, Req>, \"env\" | \"logger\" | \"payload\" | \"request\">,\n ) => Promise<ResponsePayload>;\n parseRequest: (\n context: Pick<TaskContext<RequestPayload, Env, Req>, \"logger\" | \"request\">,\n ) => Promise<Pick<TaskContext<RequestPayload, Env, Req>, \"env\" | \"payload\">>;\n};\n\nconst handleRequest = async <\n RequestPayload,\n ResponsePayload extends Response | object | string | undefined | void = void,\n Env = null,\n Req extends Request = Request,\n>(\n request: Req,\n tasks: Tasks<RequestPayload, ResponsePayload, Env, Req>,\n options?: HandlerOptions,\n) => {\n const correlationId = extractCorrelationIdFromHeaders(request.headers) || generateCorrelationId();\n\n const logger = new WorkniceIntegrationLogger({\n debugLogType: options?.debugLogType ?? (options?.debug ? \"info\" : \"debug\"),\n logger: options?.logger ?? console,\n correlationId,\n });\n\n return runWithCorrelationId(correlationId, async () => {\n try {\n logger.info(\n options?.processName ? `Starting process: ${options.processName}` : \"Starting process\",\n );\n\n logger.indent(\"Parsing request…\");\n\n const { env, payload } = await tasks.parseRequest({\n logger,\n request,\n });\n\n logger.dedent(\"Finished parsing request.\");\n\n const result = await tasks.handleRequest({\n env,\n logger,\n payload,\n request,\n });\n\n logger.debug(\"Handling request…\");\n\n let response: Response;\n\n if (result instanceof Response) {\n response = result;\n } else if (typeof result === \"object\") {\n response = new Response(JSON.stringify(result), {\n headers: {\n \"Content-Type\": \"application/json\",\n \"X-Request-ID\": correlationId,\n },\n status: \"ok\" in result && result.ok === false ? 400 : 200,\n });\n } else if (typeof result === \"string\") {\n response = new Response(result, {\n headers: {\n \"X-Request-ID\": correlationId,\n },\n status: 200,\n });\n } else {\n response = new Response(\"ok\", {\n headers: {\n \"Content-Type\": \"application/json\",\n \"X-Request-ID\": correlationId,\n },\n status: 200,\n });\n }\n\n logger.debug(\"Request handling completed successfully.\");\n\n return response;\n } catch (error) {\n const message = logger.error(error);\n\n return new Response(message, {\n headers: {\n \"X-Request-ID\": correlationId,\n },\n status: 500,\n });\n } finally {\n logger.info(\n options?.processName ? `Process complete: ${options.processName}` : \"Process complete\",\n );\n\n await logger.flush();\n }\n });\n};\n\nexport default handleRequest;\n"],"mappings":"AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,OAAO,+BAA+B;AAYtC,MAA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aAAO,MAAM,0CAA0C;AAEvD,aAAO;AAAA,IACT,SAAS,OAAO;AACd,YAAM,UAAU,OAAO,MAAM,KAAK;AAElC,aAAO,IAAI,SAAS,SAAS;AAAA,QAC3B,SAAS;AAAA,UACP,gBAAgB;AAAA,QAClB;AAAA,QACA,QAAQ;AAAA,MACV,CAAC;AAAA,IACH,UAAE;AACA,aAAO;AAAA,QACL,SAAS,cAAc,qBAAqB,QAAQ,WAAW,KAAK;AAAA,MACtE;AAEA,YAAM,OAAO,MAAM;AAAA,IACrB;AAAA,EACF,CAAC;AACH;AAEA,IAAO,wBAAQ;","names":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import '../_types-
|
|
1
|
+
import { TaskContext, HandlerOptions } from './_types.js';
|
|
2
|
+
import '../_types-CeswTuBG.js';
|
|
3
3
|
import '../api/_generated.js';
|
|
4
4
|
import '../api/WorkniceIntegrationLogger.js';
|
|
5
5
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { getCorrelationId } from "@worknice/instrumentation";
|
|
1
2
|
import createWorkniceClient from "../api/createWorkniceClient.js";
|
|
2
3
|
import handleRequest from "./handleRequest.js";
|
|
3
4
|
const handleRequestWithWorknice = async (request, tasks, options) => handleRequest(
|
|
@@ -7,7 +8,9 @@ const handleRequestWithWorknice = async (request, tasks, options) => handleReque
|
|
|
7
8
|
logger.indent("Initialising Worknice client\u2026");
|
|
8
9
|
const apiToken = await tasks.getApiToken({ env, logger, payload, request: request2 });
|
|
9
10
|
logger.info("Retrieved Worknice API token.");
|
|
11
|
+
const correlationId = getCorrelationId();
|
|
10
12
|
const worknice = createWorkniceClient({
|
|
13
|
+
correlationId,
|
|
11
14
|
accessToken: apiToken,
|
|
12
15
|
apiUrl: options?.apiUrl
|
|
13
16
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/helpers/handleRequestWithWorknice.ts"],"sourcesContent":["import createWorkniceClient from \"../api/createWorkniceClient.js\";\nimport type { HandlerOptions, TaskContext } from \"./_types.js\";\nimport handleRequest from \"./handleRequest.js\";\n\ntype Tasks<RequestPayload, ResponsePayload, Env = null, Req extends Request = Request> = {\n getApiToken: (\n context: Pick<TaskContext<RequestPayload, Env, Req>, \"env\" | \"logger\" | \"payload\" | \"request\">,\n ) => Promise<string | undefined>;\n handleRequest: (context: TaskContext<RequestPayload, Env, Req>) => Promise<ResponsePayload>;\n} & (\n | {\n /**\n * @deprecated Use `parseRequest` instead.\n */\n getEnv: (\n context: Pick<TaskContext<RequestPayload, Env, Req>, \"logger\" | \"payload\" | \"request\">,\n ) => Promise<Env>;\n /**\n * @deprecated Use `parseRequest` instead.\n */\n parsePayload: (\n context: Pick<TaskContext<RequestPayload, Env, Req>, \"logger\" | \"request\">,\n ) => Promise<RequestPayload>;\n }\n | {\n parseRequest: (\n context: Pick<TaskContext<RequestPayload, Env, Req>, \"logger\" | \"request\">,\n ) => Promise<Pick<TaskContext<RequestPayload, Env, Req>, \"env\" | \"payload\">>;\n }\n);\n\nconst handleRequestWithWorknice = async <\n RequestPayload,\n ResponsePayload extends Response | object | string | undefined | void = void,\n Env = null,\n Req extends Request = Request,\n>(\n request: Req,\n tasks: Tasks<RequestPayload, ResponsePayload, Env, Req>,\n options?: HandlerOptions,\n) =>\n handleRequest<RequestPayload, ResponsePayload, Env, Req>(\n request,\n {\n handleRequest: async ({ env, logger, payload, request }) => {\n logger.indent(\"Initialising Worknice client…\");\n\n const apiToken = await tasks.getApiToken({ env, logger, payload, request });\n\n logger.info(\"Retrieved Worknice API token.\");\n\n const worknice = createWorkniceClient({\n accessToken: apiToken,\n apiUrl: options?.apiUrl,\n });\n\n logger.dedent(\"Finished initialising Worknice client.\");\n\n const result = await tasks.handleRequest({\n env,\n logger,\n payload,\n request,\n worknice,\n });\n\n return result;\n },\n parseRequest: async ({ logger, request }) => {\n if (\"parseRequest\" in tasks) {\n const result = await tasks.parseRequest({\n logger,\n request,\n });\n return result;\n } else {\n const payload = await tasks.parsePayload({ logger, request });\n const env = await tasks.getEnv({ logger, payload, request });\n return { env, payload };\n }\n },\n },\n options,\n );\n\nexport default handleRequestWithWorknice;\n"],"mappings":"AAAA,OAAO,0BAA0B;AAEjC,OAAO,mBAAmB;AA6B1B,MAAM,4BAA4B,OAMhC,SACA,OACA,YAEA;AAAA,EACE;AAAA,EACA;AAAA,IACE,eAAe,OAAO,EAAE,KAAK,QAAQ,SAAS,SAAAA,SAAQ,MAAM;AAC1D,aAAO,OAAO,oCAA+B;AAE7C,YAAM,WAAW,MAAM,MAAM,YAAY,EAAE,KAAK,QAAQ,SAAS,SAAAA,SAAQ,CAAC;AAE1E,aAAO,KAAK,+BAA+B;AAE3C,YAAM,WAAW,qBAAqB;AAAA,QACpC,aAAa;AAAA,QACb,QAAQ,SAAS;AAAA,MACnB,CAAC;AAED,aAAO,OAAO,wCAAwC;AAEtD,YAAM,SAAS,MAAM,MAAM,cAAc;AAAA,QACvC;AAAA,QACA;AAAA,QACA;AAAA,QACA,SAAAA;AAAA,QACA;AAAA,MACF,CAAC;AAED,aAAO;AAAA,IACT;AAAA,IACA,cAAc,OAAO,EAAE,QAAQ,SAAAA,SAAQ,MAAM;AAC3C,UAAI,kBAAkB,OAAO;AAC3B,cAAM,SAAS,MAAM,MAAM,aAAa;AAAA,UACtC;AAAA,UACA,SAAAA;AAAA,QACF,CAAC;AACD,eAAO;AAAA,MACT,OAAO;AACL,cAAM,UAAU,MAAM,MAAM,aAAa,EAAE,QAAQ,SAAAA,SAAQ,CAAC;AAC5D,cAAM,MAAM,MAAM,MAAM,OAAO,EAAE,QAAQ,SAAS,SAAAA,SAAQ,CAAC;AAC3D,eAAO,EAAE,KAAK,QAAQ;AAAA,MACxB;AAAA,IACF;AAAA,EACF;AAAA,EACA;AACF;AAEF,IAAO,oCAAQ;","names":["request"]}
|
|
1
|
+
{"version":3,"sources":["../../src/helpers/handleRequestWithWorknice.ts"],"sourcesContent":["import { getCorrelationId } from \"@worknice/instrumentation\";\n\nimport createWorkniceClient from \"../api/createWorkniceClient.js\";\nimport type { HandlerOptions, TaskContext } from \"./_types.js\";\nimport handleRequest from \"./handleRequest.js\";\n\ntype Tasks<RequestPayload, ResponsePayload, Env = null, Req extends Request = Request> = {\n getApiToken: (\n context: Pick<TaskContext<RequestPayload, Env, Req>, \"env\" | \"logger\" | \"payload\" | \"request\">,\n ) => Promise<string | undefined>;\n handleRequest: (context: TaskContext<RequestPayload, Env, Req>) => Promise<ResponsePayload>;\n} & (\n | {\n /**\n * @deprecated Use `parseRequest` instead.\n */\n getEnv: (\n context: Pick<TaskContext<RequestPayload, Env, Req>, \"logger\" | \"payload\" | \"request\">,\n ) => Promise<Env>;\n /**\n * @deprecated Use `parseRequest` instead.\n */\n parsePayload: (\n context: Pick<TaskContext<RequestPayload, Env, Req>, \"logger\" | \"request\">,\n ) => Promise<RequestPayload>;\n }\n | {\n parseRequest: (\n context: Pick<TaskContext<RequestPayload, Env, Req>, \"logger\" | \"request\">,\n ) => Promise<Pick<TaskContext<RequestPayload, Env, Req>, \"env\" | \"payload\">>;\n }\n);\n\nconst handleRequestWithWorknice = async <\n RequestPayload,\n ResponsePayload extends Response | object | string | undefined | void = void,\n Env = null,\n Req extends Request = Request,\n>(\n request: Req,\n tasks: Tasks<RequestPayload, ResponsePayload, Env, Req>,\n options?: HandlerOptions,\n) =>\n handleRequest<RequestPayload, ResponsePayload, Env, Req>(\n request,\n {\n handleRequest: async ({ env, logger, payload, request }) => {\n logger.indent(\"Initialising Worknice client…\");\n\n const apiToken = await tasks.getApiToken({ env, logger, payload, request });\n\n logger.info(\"Retrieved Worknice API token.\");\n\n const correlationId = getCorrelationId();\n const worknice = createWorkniceClient({\n correlationId,\n accessToken: apiToken,\n apiUrl: options?.apiUrl,\n });\n\n logger.dedent(\"Finished initialising Worknice client.\");\n\n const result = await tasks.handleRequest({\n env,\n logger,\n payload,\n request,\n worknice,\n });\n\n return result;\n },\n parseRequest: async ({ logger, request }) => {\n if (\"parseRequest\" in tasks) {\n const result = await tasks.parseRequest({\n logger,\n request,\n });\n return result;\n } else {\n const payload = await tasks.parsePayload({ logger, request });\n const env = await tasks.getEnv({ logger, payload, request });\n return { env, payload };\n }\n },\n },\n options,\n );\n\nexport default handleRequestWithWorknice;\n"],"mappings":"AAAA,SAAS,wBAAwB;AAEjC,OAAO,0BAA0B;AAEjC,OAAO,mBAAmB;AA6B1B,MAAM,4BAA4B,OAMhC,SACA,OACA,YAEA;AAAA,EACE;AAAA,EACA;AAAA,IACE,eAAe,OAAO,EAAE,KAAK,QAAQ,SAAS,SAAAA,SAAQ,MAAM;AAC1D,aAAO,OAAO,oCAA+B;AAE7C,YAAM,WAAW,MAAM,MAAM,YAAY,EAAE,KAAK,QAAQ,SAAS,SAAAA,SAAQ,CAAC;AAE1E,aAAO,KAAK,+BAA+B;AAE3C,YAAM,gBAAgB,iBAAiB;AACvC,YAAM,WAAW,qBAAqB;AAAA,QACpC;AAAA,QACA,aAAa;AAAA,QACb,QAAQ,SAAS;AAAA,MACnB,CAAC;AAED,aAAO,OAAO,wCAAwC;AAEtD,YAAM,SAAS,MAAM,MAAM,cAAc;AAAA,QACvC;AAAA,QACA;AAAA,QACA;AAAA,QACA,SAAAA;AAAA,QACA;AAAA,MACF,CAAC;AAED,aAAO;AAAA,IACT;AAAA,IACA,cAAc,OAAO,EAAE,QAAQ,SAAAA,SAAQ,MAAM;AAC3C,UAAI,kBAAkB,OAAO;AAC3B,cAAM,SAAS,MAAM,MAAM,aAAa;AAAA,UACtC;AAAA,UACA,SAAAA;AAAA,QACF,CAAC;AACD,eAAO;AAAA,MACT,OAAO;AACL,cAAM,UAAU,MAAM,MAAM,aAAa,EAAE,QAAQ,SAAAA,SAAQ,CAAC;AAC5D,cAAM,MAAM,MAAM,MAAM,OAAO,EAAE,QAAQ,SAAS,SAAAA,SAAQ,CAAC;AAC3D,eAAO,EAAE,KAAK,QAAQ;AAAA,MACxB;AAAA,IACF;AAAA,EACF;AAAA,EACA;AACF;AAEF,IAAO,oCAAQ;","names":["request"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { TriggerIntegrationSyncRequestPayload } from '@worknice/utils/webhooks';
|
|
2
|
-
import { W as WorkniceClient } from '../_types-
|
|
2
|
+
import { W as WorkniceClient } from '../_types-CeswTuBG.js';
|
|
3
3
|
import { PersonDataTransferLine } from '../employee-records/_types.js';
|
|
4
|
-
import {
|
|
4
|
+
import { TaskContext, HandlerOptions } from './_types.js';
|
|
5
5
|
import { ConnectionStatus, LeaveCategoryInput, LeaveRequestStatus } from '../api/_generated.js';
|
|
6
6
|
import '../api/WorkniceIntegrationLogger.js';
|
|
7
7
|
|
package/dist/helpers/index.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ export { default as handleRequestWithWorknice } from './handleRequestWithWorknic
|
|
|
17
17
|
export { default as handleTriggerIntegrationSyncWebhook } from './handleTriggerIntegrationSyncWebhook.js';
|
|
18
18
|
import '@worknice/utils/webhooks';
|
|
19
19
|
import './_types.js';
|
|
20
|
-
import '../_types-
|
|
20
|
+
import '../_types-CeswTuBG.js';
|
|
21
21
|
import '../api/_generated.js';
|
|
22
22
|
import '../api/WorkniceIntegrationLogger.js';
|
|
23
23
|
import '../employee-records/_types.js';
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@worknice/js-sdk",
|
|
3
3
|
"description": "",
|
|
4
|
-
"version": "0.13.
|
|
4
|
+
"version": "0.13.12",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"private": false,
|
|
7
7
|
"files": [
|
|
@@ -37,7 +37,8 @@
|
|
|
37
37
|
"dedent": "^0.7.0",
|
|
38
38
|
"uuid": "^11.0.5",
|
|
39
39
|
"zod": "^4.1.4",
|
|
40
|
-
"@worknice/
|
|
40
|
+
"@worknice/instrumentation": "^0.0.0",
|
|
41
|
+
"@worknice/utils": "^0.6.50"
|
|
41
42
|
},
|
|
42
43
|
"devDependencies": {
|
|
43
44
|
"@anolilab/semantic-release-pnpm": "^1.1.10",
|