@invoiceleaf/integration-sdk 1.6.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/context/IntegrationContext.d.ts +362 -24
- package/dist/context/IntegrationContext.d.ts.map +1 -1
- package/dist/context/types.d.ts +98 -25
- package/dist/context/types.d.ts.map +1 -1
- package/dist/helpers/createAttachmentFingerprint.d.ts +3 -0
- package/dist/helpers/createAttachmentFingerprint.d.ts.map +1 -1
- package/dist/helpers/createAttachmentFingerprint.js +5 -2
- package/dist/helpers/createAttachmentFingerprint.js.map +1 -1
- package/dist/helpers/defineHandler.d.ts +120 -5
- package/dist/helpers/defineHandler.d.ts.map +1 -1
- package/dist/helpers/defineHandler.js +5 -5
- package/dist/helpers/defineHandler.js.map +1 -1
- package/dist/helpers/firstFinite.d.ts +13 -0
- package/dist/helpers/firstFinite.d.ts.map +1 -0
- package/dist/helpers/firstFinite.js +20 -0
- package/dist/helpers/firstFinite.js.map +1 -0
- package/dist/helpers/httpRetry.d.ts +70 -0
- package/dist/helpers/httpRetry.d.ts.map +1 -0
- package/dist/helpers/httpRetry.js +166 -0
- package/dist/helpers/httpRetry.js.map +1 -0
- package/dist/helpers/sha256.d.ts +9 -0
- package/dist/helpers/sha256.d.ts.map +1 -0
- package/dist/helpers/sha256.js +118 -0
- package/dist/helpers/sha256.js.map +1 -0
- package/dist/helpers/toBoundedInt.d.ts +14 -0
- package/dist/helpers/toBoundedInt.d.ts.map +1 -0
- package/dist/helpers/toBoundedInt.js +26 -0
- package/dist/helpers/toBoundedInt.js.map +1 -0
- package/dist/helpers/toDateOnly.d.ts +22 -0
- package/dist/helpers/toDateOnly.d.ts.map +1 -0
- package/dist/helpers/toDateOnly.js +40 -0
- package/dist/helpers/toDateOnly.js.map +1 -0
- package/dist/helpers/toErrorMessage.d.ts +14 -0
- package/dist/helpers/toErrorMessage.d.ts.map +1 -0
- package/dist/helpers/toErrorMessage.js +19 -0
- package/dist/helpers/toErrorMessage.js.map +1 -0
- package/dist/helpers/toFiniteNumber.d.ts +12 -0
- package/dist/helpers/toFiniteNumber.d.ts.map +1 -0
- package/dist/helpers/toFiniteNumber.js +17 -0
- package/dist/helpers/toFiniteNumber.js.map +1 -0
- package/dist/helpers/trimToUndefined.d.ts +12 -0
- package/dist/helpers/trimToUndefined.d.ts.map +1 -0
- package/dist/helpers/trimToUndefined.js +18 -0
- package/dist/helpers/trimToUndefined.js.map +1 -0
- package/dist/index.d.ts +10 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -1
- package/dist/types/actions.d.ts +2 -0
- package/dist/types/actions.d.ts.map +1 -1
- package/dist/types/invocation.d.ts +1 -1
- package/dist/types/invocation.d.ts.map +1 -1
- package/dist/types/manifest.d.ts +37 -3
- package/dist/types/manifest.d.ts.map +1 -1
- package/dist/types/triggers.d.ts +3 -2
- package/dist/types/triggers.d.ts.map +1 -1
- package/dist/types/triggers.js +1 -1
- package/dist/types/triggers.js.map +1 -1
- package/package.json +16 -9
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared HTTP retry logic for integration API clients.
|
|
3
|
+
*
|
|
4
|
+
* All integration clients share identical retry semantics:
|
|
5
|
+
* - GET requests retry on 429 / 500 / 502 / 503 / 504 and network errors.
|
|
6
|
+
* - Mutating requests (POST / PUT / DELETE) only retry on 429 (rate-limit).
|
|
7
|
+
* - Exponential backoff capped at 2 000 ms, up to 3 attempts.
|
|
8
|
+
* - Per-request timeout with AbortController.
|
|
9
|
+
*/
|
|
10
|
+
/** Status codes safe to retry for idempotent (GET) requests. */
|
|
11
|
+
export const RETRYABLE_STATUSES = new Set([429, 500, 502, 503, 504]);
|
|
12
|
+
/** Status codes safe to retry for mutating (POST/PUT/DELETE) requests. */
|
|
13
|
+
export const SAFE_RETRY_STATUSES_FOR_MUTATING = new Set([429]);
|
|
14
|
+
/** Default maximum number of request attempts. */
|
|
15
|
+
export const DEFAULT_MAX_REQUEST_ATTEMPTS = 3;
|
|
16
|
+
/** Default per-request timeout in milliseconds. */
|
|
17
|
+
export const DEFAULT_REQUEST_TIMEOUT_MS = 30_000;
|
|
18
|
+
/**
|
|
19
|
+
* Returns exponential-backoff delay for the given attempt, capped at 2 000 ms.
|
|
20
|
+
*
|
|
21
|
+
* Attempt 1 → 250 ms, attempt 2 → 500 ms, attempt 3+ → 2 000 ms.
|
|
22
|
+
*/
|
|
23
|
+
export function backoffMs(attempt) {
|
|
24
|
+
return Math.min(2000, 250 * 2 ** (attempt - 1));
|
|
25
|
+
}
|
|
26
|
+
/** Promise-based sleep. */
|
|
27
|
+
export function sleep(ms) {
|
|
28
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Executes an HTTP request with retry, backoff, and timeout.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```ts
|
|
35
|
+
* const data = await requestWithRetry<MyResponse>(url, init, {
|
|
36
|
+
* method: 'POST',
|
|
37
|
+
* createError: (msg, status, body) => new MyApiError(msg, status, body),
|
|
38
|
+
* });
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
export async function requestWithRetry(url, init, options = {}) {
|
|
42
|
+
const { method = 'GET', maxAttempts = DEFAULT_MAX_REQUEST_ATTEMPTS, timeoutMs = DEFAULT_REQUEST_TIMEOUT_MS, includeBodyInError = true, createError, idempotent, } = options;
|
|
43
|
+
let lastError = null;
|
|
44
|
+
const isIdempotent = idempotent ?? method === 'GET';
|
|
45
|
+
for (let attempt = 1; attempt <= maxAttempts; attempt += 1) {
|
|
46
|
+
const controller = new AbortController();
|
|
47
|
+
const timeout = setTimeout(() => controller.abort(), timeoutMs);
|
|
48
|
+
// Combine the timeout signal with any caller-supplied signal so that
|
|
49
|
+
// either one can abort the request.
|
|
50
|
+
const signals = [controller.signal];
|
|
51
|
+
if (init.signal)
|
|
52
|
+
signals.push(init.signal);
|
|
53
|
+
const combinedSignal = signals.length > 1 ? AbortSignal.any(signals) : controller.signal;
|
|
54
|
+
try {
|
|
55
|
+
const response = await fetch(url, { ...init, signal: combinedSignal });
|
|
56
|
+
const body = await response.text();
|
|
57
|
+
if (!response.ok) {
|
|
58
|
+
const error = createError
|
|
59
|
+
? createError(`API request failed with status ${response.status}`, response.status, includeBodyInError ? body : '')
|
|
60
|
+
: Object.assign(new Error(`API request failed with status ${response.status}`), { status: response.status, responseBody: includeBodyInError ? body : '' });
|
|
61
|
+
const canRetryStatus = isIdempotent
|
|
62
|
+
? RETRYABLE_STATUSES.has(response.status)
|
|
63
|
+
: SAFE_RETRY_STATUSES_FOR_MUTATING.has(response.status);
|
|
64
|
+
if (attempt < maxAttempts && canRetryStatus) {
|
|
65
|
+
await sleep(backoffMs(attempt));
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
throw error;
|
|
69
|
+
}
|
|
70
|
+
if (body.length === 0) {
|
|
71
|
+
return {};
|
|
72
|
+
}
|
|
73
|
+
try {
|
|
74
|
+
return JSON.parse(body);
|
|
75
|
+
}
|
|
76
|
+
catch (parseError) {
|
|
77
|
+
const msg = `Failed to parse API response: ${String(parseError)}`;
|
|
78
|
+
throw createError
|
|
79
|
+
? createError(msg, response.status, body.slice(0, 500))
|
|
80
|
+
: new Error(msg);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
catch (error) {
|
|
84
|
+
lastError = error;
|
|
85
|
+
const errorStatus = error.status;
|
|
86
|
+
if (typeof errorStatus === 'number') {
|
|
87
|
+
const canRetryStatus = isIdempotent
|
|
88
|
+
? RETRYABLE_STATUSES.has(errorStatus)
|
|
89
|
+
: SAFE_RETRY_STATUSES_FOR_MUTATING.has(errorStatus);
|
|
90
|
+
if (attempt < maxAttempts && canRetryStatus) {
|
|
91
|
+
await sleep(backoffMs(attempt));
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
else if (isIdempotent && attempt < maxAttempts) {
|
|
96
|
+
// Network errors — only retry for idempotent requests.
|
|
97
|
+
await sleep(backoffMs(attempt));
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
throw error;
|
|
101
|
+
}
|
|
102
|
+
finally {
|
|
103
|
+
clearTimeout(timeout);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
throw lastError ?? new Error('Request failed after retries.');
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Like {@link requestWithRetry}, but returns the raw `Response` instead of
|
|
110
|
+
* parsing JSON. Useful for binary downloads where the caller needs to read
|
|
111
|
+
* headers or stream the body.
|
|
112
|
+
*/
|
|
113
|
+
export async function requestResponseWithRetry(url, init, options = {}) {
|
|
114
|
+
const { method = 'GET', maxAttempts = DEFAULT_MAX_REQUEST_ATTEMPTS, timeoutMs = DEFAULT_REQUEST_TIMEOUT_MS, includeBodyInError = true, createError, idempotent, } = options;
|
|
115
|
+
let lastError = null;
|
|
116
|
+
const isIdempotent = idempotent ?? method === 'GET';
|
|
117
|
+
for (let attempt = 1; attempt <= maxAttempts; attempt += 1) {
|
|
118
|
+
const controller = new AbortController();
|
|
119
|
+
const timeout = setTimeout(() => controller.abort(), timeoutMs);
|
|
120
|
+
const signals = [controller.signal];
|
|
121
|
+
if (init.signal)
|
|
122
|
+
signals.push(init.signal);
|
|
123
|
+
const combinedSignal = signals.length > 1 ? AbortSignal.any(signals) : controller.signal;
|
|
124
|
+
try {
|
|
125
|
+
const response = await fetch(url, { ...init, signal: combinedSignal });
|
|
126
|
+
if (!response.ok) {
|
|
127
|
+
const body = includeBodyInError ? await response.text() : '';
|
|
128
|
+
const error = createError
|
|
129
|
+
? createError(`API request failed with status ${response.status}`, response.status, body)
|
|
130
|
+
: Object.assign(new Error(`API request failed with status ${response.status}`), { status: response.status, responseBody: body });
|
|
131
|
+
const canRetryStatus = isIdempotent
|
|
132
|
+
? RETRYABLE_STATUSES.has(response.status)
|
|
133
|
+
: SAFE_RETRY_STATUSES_FOR_MUTATING.has(response.status);
|
|
134
|
+
if (attempt < maxAttempts && canRetryStatus) {
|
|
135
|
+
await sleep(backoffMs(attempt));
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
throw error;
|
|
139
|
+
}
|
|
140
|
+
return response;
|
|
141
|
+
}
|
|
142
|
+
catch (error) {
|
|
143
|
+
lastError = error;
|
|
144
|
+
const errorStatus = error.status;
|
|
145
|
+
if (typeof errorStatus === 'number') {
|
|
146
|
+
const canRetryStatus = isIdempotent
|
|
147
|
+
? RETRYABLE_STATUSES.has(errorStatus)
|
|
148
|
+
: SAFE_RETRY_STATUSES_FOR_MUTATING.has(errorStatus);
|
|
149
|
+
if (attempt < maxAttempts && canRetryStatus) {
|
|
150
|
+
await sleep(backoffMs(attempt));
|
|
151
|
+
continue;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
else if (isIdempotent && attempt < maxAttempts) {
|
|
155
|
+
await sleep(backoffMs(attempt));
|
|
156
|
+
continue;
|
|
157
|
+
}
|
|
158
|
+
throw error;
|
|
159
|
+
}
|
|
160
|
+
finally {
|
|
161
|
+
clearTimeout(timeout);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
throw lastError ?? new Error('Request failed after retries.');
|
|
165
|
+
}
|
|
166
|
+
//# sourceMappingURL=httpRetry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"httpRetry.js","sourceRoot":"","sources":["../../src/helpers/httpRetry.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,gEAAgE;AAChE,MAAM,CAAC,MAAM,kBAAkB,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;AAErE,0EAA0E;AAC1E,MAAM,CAAC,MAAM,gCAAgC,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;AAE/D,kD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,OAAO,GAAG,WAAW,EAAE,CAAC;gBACjD,MAAM,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC;gBAChC,SAAS;YACX,CAAC;YAED,MAAM,KAAK,CAAC;QACd,CAAC;gBAAS,CAAC;YACT,YAAY,CAAC,OAAO,CAAC,CAAC;QACxB,CAAC;IACH,CAAC;IAED,MAAM,SAAS,IAAI,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;AAChE,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure-JS SHA-256 (FIPS 180-4) over a UTF-8 string, returning lowercase hex.
|
|
3
|
+
*
|
|
4
|
+
* The SDK is bundled into plugin code that runs in a bare V8 isolate with no
|
|
5
|
+
* Node builtins, so `node:crypto` must never be imported statically anywhere
|
|
6
|
+
* in this package.
|
|
7
|
+
*/
|
|
8
|
+
export declare function sha256Hex(input: string): string;
|
|
9
|
+
//# sourceMappingURL=sha256.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sha256.d.ts","sourceRoot":"","sources":["../../src/helpers/sha256.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAgDH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CA0E/C"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure-JS SHA-256 (FIPS 180-4) over a UTF-8 string, returning lowercase hex.
|
|
3
|
+
*
|
|
4
|
+
* The SDK is bundled into plugin code that runs in a bare V8 isolate with no
|
|
5
|
+
* Node builtins, so `node:crypto` must never be imported statically anywhere
|
|
6
|
+
* in this package.
|
|
7
|
+
*/
|
|
8
|
+
const K = new Uint32Array([
|
|
9
|
+
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
|
|
10
|
+
0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
|
|
11
|
+
0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
|
|
12
|
+
0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
|
|
13
|
+
0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
|
|
14
|
+
0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
|
|
15
|
+
0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
|
|
16
|
+
0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2,
|
|
17
|
+
]);
|
|
18
|
+
function utf8Bytes(input) {
|
|
19
|
+
const bytes = [];
|
|
20
|
+
for (let i = 0; i < input.length; i += 1) {
|
|
21
|
+
let code = input.charCodeAt(i);
|
|
22
|
+
if (code < 0x80) {
|
|
23
|
+
bytes.push(code);
|
|
24
|
+
}
|
|
25
|
+
else if (code < 0x800) {
|
|
26
|
+
bytes.push(0xc0 | (code >> 6), 0x80 | (code & 0x3f));
|
|
27
|
+
}
|
|
28
|
+
else if (code >= 0xd800 && code <= 0xdbff && i + 1 < input.length) {
|
|
29
|
+
const low = input.charCodeAt(i + 1);
|
|
30
|
+
if (low >= 0xdc00 && low <= 0xdfff) {
|
|
31
|
+
code = 0x10000 + ((code - 0xd800) << 10) + (low - 0xdc00);
|
|
32
|
+
bytes.push(0xf0 | (code >> 18), 0x80 | ((code >> 12) & 0x3f), 0x80 | ((code >> 6) & 0x3f), 0x80 | (code & 0x3f));
|
|
33
|
+
i += 1;
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
bytes.push(0xef, 0xbf, 0xbd);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
else if (code >= 0xdc00 && code <= 0xdfff) {
|
|
40
|
+
bytes.push(0xef, 0xbf, 0xbd);
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
bytes.push(0xe0 | (code >> 12), 0x80 | ((code >> 6) & 0x3f), 0x80 | (code & 0x3f));
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return bytes;
|
|
47
|
+
}
|
|
48
|
+
function rotr(value, bits) {
|
|
49
|
+
return (value >>> bits) | (value << (32 - bits));
|
|
50
|
+
}
|
|
51
|
+
export function sha256Hex(input) {
|
|
52
|
+
const bytes = utf8Bytes(input);
|
|
53
|
+
const bitLength = bytes.length * 8;
|
|
54
|
+
// Padding: 0x80, zeros, then 64-bit big-endian length.
|
|
55
|
+
bytes.push(0x80);
|
|
56
|
+
while (bytes.length % 64 !== 56) {
|
|
57
|
+
bytes.push(0);
|
|
58
|
+
}
|
|
59
|
+
const high = Math.floor(bitLength / 0x100000000);
|
|
60
|
+
bytes.push((high >>> 24) & 0xff, (high >>> 16) & 0xff, (high >>> 8) & 0xff, high & 0xff);
|
|
61
|
+
bytes.push((bitLength >>> 24) & 0xff, (bitLength >>> 16) & 0xff, (bitLength >>> 8) & 0xff, bitLength & 0xff);
|
|
62
|
+
let h0 = 0x6a09e667;
|
|
63
|
+
let h1 = 0xbb67ae85;
|
|
64
|
+
let h2 = 0x3c6ef372;
|
|
65
|
+
let h3 = 0xa54ff53a;
|
|
66
|
+
let h4 = 0x510e527f;
|
|
67
|
+
let h5 = 0x9b05688c;
|
|
68
|
+
let h6 = 0x1f83d9ab;
|
|
69
|
+
let h7 = 0x5be0cd19;
|
|
70
|
+
const w = new Uint32Array(64);
|
|
71
|
+
for (let offset = 0; offset < bytes.length; offset += 64) {
|
|
72
|
+
for (let t = 0; t < 16; t += 1) {
|
|
73
|
+
const i = offset + t * 4;
|
|
74
|
+
w[t] = ((bytes[i] << 24) | (bytes[i + 1] << 16) | (bytes[i + 2] << 8) | bytes[i + 3]) >>> 0;
|
|
75
|
+
}
|
|
76
|
+
for (let t = 16; t < 64; t += 1) {
|
|
77
|
+
const s0 = rotr(w[t - 15], 7) ^ rotr(w[t - 15], 18) ^ (w[t - 15] >>> 3);
|
|
78
|
+
const s1 = rotr(w[t - 2], 17) ^ rotr(w[t - 2], 19) ^ (w[t - 2] >>> 10);
|
|
79
|
+
w[t] = (w[t - 16] + s0 + w[t - 7] + s1) >>> 0;
|
|
80
|
+
}
|
|
81
|
+
let a = h0;
|
|
82
|
+
let b = h1;
|
|
83
|
+
let c = h2;
|
|
84
|
+
let d = h3;
|
|
85
|
+
let e = h4;
|
|
86
|
+
let f = h5;
|
|
87
|
+
let g = h6;
|
|
88
|
+
let h = h7;
|
|
89
|
+
for (let t = 0; t < 64; t += 1) {
|
|
90
|
+
const S1 = rotr(e, 6) ^ rotr(e, 11) ^ rotr(e, 25);
|
|
91
|
+
const ch = (e & f) ^ (~e & g);
|
|
92
|
+
const temp1 = (h + S1 + ch + K[t] + w[t]) >>> 0;
|
|
93
|
+
const S0 = rotr(a, 2) ^ rotr(a, 13) ^ rotr(a, 22);
|
|
94
|
+
const maj = (a & b) ^ (a & c) ^ (b & c);
|
|
95
|
+
const temp2 = (S0 + maj) >>> 0;
|
|
96
|
+
h = g;
|
|
97
|
+
g = f;
|
|
98
|
+
f = e;
|
|
99
|
+
e = (d + temp1) >>> 0;
|
|
100
|
+
d = c;
|
|
101
|
+
c = b;
|
|
102
|
+
b = a;
|
|
103
|
+
a = (temp1 + temp2) >>> 0;
|
|
104
|
+
}
|
|
105
|
+
h0 = (h0 + a) >>> 0;
|
|
106
|
+
h1 = (h1 + b) >>> 0;
|
|
107
|
+
h2 = (h2 + c) >>> 0;
|
|
108
|
+
h3 = (h3 + d) >>> 0;
|
|
109
|
+
h4 = (h4 + e) >>> 0;
|
|
110
|
+
h5 = (h5 + f) >>> 0;
|
|
111
|
+
h6 = (h6 + g) >>> 0;
|
|
112
|
+
h7 = (h7 + h) >>> 0;
|
|
113
|
+
}
|
|
114
|
+
return [h0, h1, h2, h3, h4, h5, h6, h7]
|
|
115
|
+
.map((word) => word.toString(16).padStart(8, '0'))
|
|
116
|
+
.join('');
|
|
117
|
+
}
|
|
118
|
+
//# sourceMappingURL=sha256.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sha256.js","sourceRoot":"","sources":["../../src/helpers/sha256.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,CAAC,GAAG,IAAI,WAAW,CAAC;IACxB,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU;IAC9F,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU;IAC9F,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU;IAC9F,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU;IAC9F,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU;IAC9F,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU;IAC9F,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU;IAC9F,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UA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AAK,CAAC,CAAC;QACpB,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC;QACpB,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC;QACpB,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC;QACpB,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC;IACtB,CAAC;IAED,OAAO,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC;SACpC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;SACjD,IAAI,CAAC,EAAE,CAAC,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Clamps a numeric value to an integer within the given `[min, max]` range.
|
|
3
|
+
*
|
|
4
|
+
* Returns `fallback` when the input is not a finite number.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* toBoundedInt(7.9, 5, 1, 10); // => 7
|
|
9
|
+
* toBoundedInt(undefined, 5, 1, 10); // => 5
|
|
10
|
+
* toBoundedInt(100, 5, 1, 10); // => 10
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export declare function toBoundedInt(value: number | undefined, fallback: number, min: number, max: number): number;
|
|
14
|
+
//# sourceMappingURL=toBoundedInt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toBoundedInt.d.ts","sourceRoot":"","sources":["../../src/helpers/toBoundedInt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,MAAM,GAAG,SAAS,EACzB,QAAQ,EAAE,MAAM,EAChB,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,GACV,MAAM,CAYR"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Clamps a numeric value to an integer within the given `[min, max]` range.
|
|
3
|
+
*
|
|
4
|
+
* Returns `fallback` when the input is not a finite number.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* toBoundedInt(7.9, 5, 1, 10); // => 7
|
|
9
|
+
* toBoundedInt(undefined, 5, 1, 10); // => 5
|
|
10
|
+
* toBoundedInt(100, 5, 1, 10); // => 10
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export function toBoundedInt(value, fallback, min, max) {
|
|
14
|
+
if (!Number.isFinite(value)) {
|
|
15
|
+
return fallback;
|
|
16
|
+
}
|
|
17
|
+
const rounded = Math.floor(value);
|
|
18
|
+
if (rounded < min) {
|
|
19
|
+
return min;
|
|
20
|
+
}
|
|
21
|
+
if (rounded > max) {
|
|
22
|
+
return max;
|
|
23
|
+
}
|
|
24
|
+
return rounded;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=toBoundedInt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toBoundedInt.js","sourceRoot":"","sources":["../../src/helpers/toBoundedInt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,YAAY,CAC1B,KAAyB,EACzB,QAAgB,EAChB,GAAW,EACX,GAAW;IAEX,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QAC5B,OAAO,QAAQ,CAAC;IAClB,CAAC;IACD,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,KAAe,CAAC,CAAC;IAC5C,IAAI,OAAO,GAAG,GAAG,EAAE,CAAC;QAClB,OAAO,GAAG,CAAC;IACb,CAAC;IACD,IAAI,OAAO,GAAG,GAAG,EAAE,CAAC;QAClB,OAAO,GAAG,CAAC;IACb,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts a date string to `YYYY-MM-DD` format, or returns `undefined` if invalid.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```ts
|
|
6
|
+
* toDateOnly('2024-03-15T10:30:00Z'); // => '2024-03-15'
|
|
7
|
+
* toDateOnly('not-a-date'); // => undefined
|
|
8
|
+
* toDateOnly(undefined); // => undefined
|
|
9
|
+
* ```
|
|
10
|
+
*/
|
|
11
|
+
export declare function toDateOnly(value: string | undefined): string | undefined;
|
|
12
|
+
/**
|
|
13
|
+
* Converts a Unix timestamp (milliseconds) to `YYYY-MM-DD` format, or returns `undefined` if invalid.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* toDateOnlyFromTimestamp(1710489600000); // => '2024-03-15'
|
|
18
|
+
* toDateOnlyFromTimestamp(undefined); // => undefined
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export declare function toDateOnlyFromTimestamp(value: number | undefined): string | undefined;
|
|
22
|
+
//# sourceMappingURL=toDateOnly.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toDateOnly.d.ts","sourceRoot":"","sources":["../../src/helpers/toDateOnly.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CASxE;AAED;;;;;;;;GAQG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CASrF"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts a date string to `YYYY-MM-DD` format, or returns `undefined` if invalid.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```ts
|
|
6
|
+
* toDateOnly('2024-03-15T10:30:00Z'); // => '2024-03-15'
|
|
7
|
+
* toDateOnly('not-a-date'); // => undefined
|
|
8
|
+
* toDateOnly(undefined); // => undefined
|
|
9
|
+
* ```
|
|
10
|
+
*/
|
|
11
|
+
export function toDateOnly(value) {
|
|
12
|
+
if (!value) {
|
|
13
|
+
return undefined;
|
|
14
|
+
}
|
|
15
|
+
const date = new Date(value);
|
|
16
|
+
if (Number.isNaN(date.getTime())) {
|
|
17
|
+
return undefined;
|
|
18
|
+
}
|
|
19
|
+
return date.toISOString().slice(0, 10);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Converts a Unix timestamp (milliseconds) to `YYYY-MM-DD` format, or returns `undefined` if invalid.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```ts
|
|
26
|
+
* toDateOnlyFromTimestamp(1710489600000); // => '2024-03-15'
|
|
27
|
+
* toDateOnlyFromTimestamp(undefined); // => undefined
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export function toDateOnlyFromTimestamp(value) {
|
|
31
|
+
if (!Number.isFinite(value)) {
|
|
32
|
+
return undefined;
|
|
33
|
+
}
|
|
34
|
+
const date = new Date(value);
|
|
35
|
+
if (Number.isNaN(date.getTime())) {
|
|
36
|
+
return undefined;
|
|
37
|
+
}
|
|
38
|
+
return date.toISOString().slice(0, 10);
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=toDateOnly.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toDateOnly.js","sourceRoot":"","sources":["../../src/helpers/toDateOnly.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,MAAM,UAAU,UAAU,CAAC,KAAyB;IAClD,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC;IAC7B,IAAI,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC;QACjC,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AACzC,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,uBAAuB,CAAC,KAAyB;IAC/D,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QAC5B,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,KAAe,CAAC,CAAC;IACvC,IAAI,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC;QACjC,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AACzC,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts an unknown error value into a human-readable string.
|
|
3
|
+
*
|
|
4
|
+
* For `Error` instances, returns `.message`. For anything else, falls back to `String(error)`.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* toErrorMessage(new Error('boom')); // => 'boom'
|
|
9
|
+
* toErrorMessage('string error'); // => 'string error'
|
|
10
|
+
* toErrorMessage(42); // => '42'
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export declare function toErrorMessage(error: unknown): string;
|
|
14
|
+
//# sourceMappingURL=toErrorMessage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toErrorMessage.d.ts","sourceRoot":"","sources":["../../src/helpers/toErrorMessage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAKrD"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts an unknown error value into a human-readable string.
|
|
3
|
+
*
|
|
4
|
+
* For `Error` instances, returns `.message`. For anything else, falls back to `String(error)`.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* toErrorMessage(new Error('boom')); // => 'boom'
|
|
9
|
+
* toErrorMessage('string error'); // => 'string error'
|
|
10
|
+
* toErrorMessage(42); // => '42'
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export function toErrorMessage(error) {
|
|
14
|
+
if (error instanceof Error) {
|
|
15
|
+
return error.message;
|
|
16
|
+
}
|
|
17
|
+
return String(error);
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=toErrorMessage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toErrorMessage.js","sourceRoot":"","sources":["../../src/helpers/toErrorMessage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,cAAc,CAAC,KAAc;IAC3C,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;QAC3B,OAAO,KAAK,CAAC,OAAO,CAAC;IACvB,CAAC;IACD,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the value if it is a finite number, otherwise returns the fallback.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```ts
|
|
6
|
+
* toFiniteNumber(42, 0); // => 42
|
|
7
|
+
* toFiniteNumber(undefined, 0); // => 0
|
|
8
|
+
* toFiniteNumber(NaN, 0); // => 0
|
|
9
|
+
* ```
|
|
10
|
+
*/
|
|
11
|
+
export declare function toFiniteNumber(value: number | undefined, fallback: number): number;
|
|
12
|
+
//# sourceMappingURL=toFiniteNumber.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toFiniteNumber.d.ts","sourceRoot":"","sources":["../../src/helpers/toFiniteNumber.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAKlF"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the value if it is a finite number, otherwise returns the fallback.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```ts
|
|
6
|
+
* toFiniteNumber(42, 0); // => 42
|
|
7
|
+
* toFiniteNumber(undefined, 0); // => 0
|
|
8
|
+
* toFiniteNumber(NaN, 0); // => 0
|
|
9
|
+
* ```
|
|
10
|
+
*/
|
|
11
|
+
export function toFiniteNumber(value, fallback) {
|
|
12
|
+
if (Number.isFinite(value)) {
|
|
13
|
+
return value;
|
|
14
|
+
}
|
|
15
|
+
return fallback;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=toFiniteNumber.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toFiniteNumber.js","sourceRoot":"","sources":["../../src/helpers/toFiniteNumber.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,MAAM,UAAU,cAAc,CAAC,KAAyB,EAAE,QAAgB;IACxE,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QAC3B,OAAO,KAAe,CAAC;IACzB,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Trims whitespace from a string and returns `undefined` if the result is empty.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```ts
|
|
6
|
+
* trimToUndefined(' hello '); // => 'hello'
|
|
7
|
+
* trimToUndefined(' '); // => undefined
|
|
8
|
+
* trimToUndefined(undefined); // => undefined
|
|
9
|
+
* ```
|
|
10
|
+
*/
|
|
11
|
+
export declare function trimToUndefined(value: string | undefined): string | undefined;
|
|
12
|
+
//# sourceMappingURL=trimToUndefined.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trimToUndefined.d.ts","sourceRoot":"","sources":["../../src/helpers/trimToUndefined.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAM7E"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Trims whitespace from a string and returns `undefined` if the result is empty.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```ts
|
|
6
|
+
* trimToUndefined(' hello '); // => 'hello'
|
|
7
|
+
* trimToUndefined(' '); // => undefined
|
|
8
|
+
* trimToUndefined(undefined); // => undefined
|
|
9
|
+
* ```
|
|
10
|
+
*/
|
|
11
|
+
export function trimToUndefined(value) {
|
|
12
|
+
if (!value) {
|
|
13
|
+
return undefined;
|
|
14
|
+
}
|
|
15
|
+
const trimmed = value.trim();
|
|
16
|
+
return trimmed.length > 0 ? trimmed : undefined;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=trimToUndefined.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trimToUndefined.js","sourceRoot":"","sources":["../../src/helpers/trimToUndefined.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,MAAM,UAAU,eAAe,CAAC,KAAyB;IACvD,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;IAC7B,OAAO,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC;AAClD,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -28,9 +28,18 @@
|
|
|
28
28
|
*/
|
|
29
29
|
export * from './types/index.js';
|
|
30
30
|
export * from './context/index.js';
|
|
31
|
+
export type { EmailClient, EmailAttachmentInput, SendSmtpEmailInput, SendSmtpEmailResult, SmtpImapConnectionTestInput, SmtpImapConnectionTestResult, ImapPdfAttachment, CrawlImapPdfAttachmentsInput, CrawlImapPdfAttachmentsResult, CredentialsClient, CredentialConnectionInfo, FilingClient, FilingValidateInput, FilingValidateResult, FilingSubmitInput, FilingSubmitResult, FilingRecord, MappingsClient, MappingRecord, MappingGetInput, MappingFindByExternalInput, MappingUpsertInput, StateClient, PaymentsClient, PaymentListParams, PaymentRecord, PaymentListResult, PaymentAllocationInput, PaymentCreateInput, PaymentCreateResult, DataClient, DocumentImportInput, DocumentImportResult, StructuredDocumentCreateInput, StructuredLineItemInput, StructuredTaxItemInput, CompanyCreateInput, CompanyCreateResult, DocumentFileContent, DocumentIntegrationMetaPatchInput, Logger, } from './context/IntegrationContext.js';
|
|
31
32
|
export { defineIntegration } from './helpers/defineIntegration.js';
|
|
32
33
|
export { defineHandler } from './helpers/defineHandler.js';
|
|
33
34
|
export { createAttachmentFingerprint } from './helpers/createAttachmentFingerprint.js';
|
|
35
|
+
export { firstFinite } from './helpers/firstFinite.js';
|
|
36
|
+
export { toBoundedInt } from './helpers/toBoundedInt.js';
|
|
37
|
+
export { trimToUndefined } from './helpers/trimToUndefined.js';
|
|
38
|
+
export { toErrorMessage } from './helpers/toErrorMessage.js';
|
|
39
|
+
export { toFiniteNumber } from './helpers/toFiniteNumber.js';
|
|
40
|
+
export { toDateOnly, toDateOnlyFromTimestamp } from './helpers/toDateOnly.js';
|
|
41
|
+
export { requestWithRetry, requestResponseWithRetry, backoffMs, sleep, RETRYABLE_STATUSES, SAFE_RETRY_STATUSES_FOR_MUTATING, DEFAULT_MAX_REQUEST_ATTEMPTS, DEFAULT_REQUEST_TIMEOUT_MS, } from './helpers/httpRetry.js';
|
|
42
|
+
export type { RequestWithRetryOptions } from './helpers/httpRetry.js';
|
|
34
43
|
export type { AttachmentFingerprintInput } from './helpers/createAttachmentFingerprint.js';
|
|
35
|
-
export type { IntegrationHandler, HandlerFunction, DocumentCreatedInput, DocumentUpdatedInput, DocumentProcessedInput, DocumentDeletedInput, CompanyCreatedInput, ExportCompletedInput, ReminderTriggeredInput, WebhookInput, ScheduleInput, UserActionInput, } from './helpers/defineHandler.js';
|
|
44
|
+
export type { HandlerResult, IntegrationHandler, HandlerFunction, DocumentCreatedInput, DocumentUpdatedInput, DocumentProcessedInput, DocumentDeletedInput, DocumentEventInput, CompanyCreatedInput, CompanyUpdatedInput, CompanyDeletedInput, TagCreatedInput, TagUpdatedInput, TagDeletedInput, CategoryCreatedInput, CategoryUpdatedInput, CategoryDeletedInput, ExportCompletedInput, ReminderTriggeredInput, SpaceMemberAddedInput, SpaceMemberRemovedInput, WebhookInput, ScheduleInput, UserActionInput, } from './helpers/defineHandler.js';
|
|
36
45
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAGH,cAAc,kBAAkB,CAAC;AAGjC,cAAc,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAGH,cAAc,kBAAkB,CAAC;AAGjC,cAAc,oBAAoB,CAAC;AACnC,YAAY,EAEV,WAAW,EACX,oBAAoB,EACpB,kBAAkB,EAClB,mBAAmB,EACnB,2BAA2B,EAC3B,4BAA4B,EAC5B,iBAAiB,EAC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,YAAY,EACV,aAAa,EACb,kBAAkB,EAClB,eAAe,EACf,oBAAoB,EACpB,oBAAoB,EACpB,sBAAsB,EACtB,oBAAoB,EACpB,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,eAAe,EACf,eAAe,EACf,eAAe,EACf,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EACpB,sBAAsB,EACtB,qBAAqB,EACrB,uBAAuB,EACvB,YAAY,EACZ,aAAa,EACb,eAAe,GAChB,MAAM,4BAA4B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -34,4 +34,11 @@ export * from './context/index.js';
|
|
|
34
34
|
export { defineIntegration } from './helpers/defineIntegration.js';
|
|
35
35
|
export { defineHandler } from './helpers/defineHandler.js';
|
|
36
36
|
export { createAttachmentFingerprint } from './helpers/createAttachmentFingerprint.js';
|
|
37
|
+
export { firstFinite } from './helpers/firstFinite.js';
|
|
38
|
+
export { toBoundedInt } from './helpers/toBoundedInt.js';
|
|
39
|
+
export { trimToUndefined } from './helpers/trimToUndefined.js';
|
|
40
|
+
export { toErrorMessage } from './helpers/toErrorMessage.js';
|
|
41
|
+
export { toFiniteNumber } from './helpers/toFiniteNumber.js';
|
|
42
|
+
export { toDateOnly, toDateOnlyFromTimestamp } from './helpers/toDateOnly.js';
|
|
43
|
+
export { requestWithRetry, requestResponseWithRetry, backoffMs, sleep, RETRYABLE_STATUSES, SAFE_RETRY_STATUSES_FOR_MUTATING, DEFAULT_MAX_REQUEST_ATTEMPTS, DEFAULT_REQUEST_TIMEOUT_MS, } from './helpers/httpRetry.js';
|
|
37
44
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,QAAQ;AACR,cAAc,kBAAkB,CAAC;AAEjC,UAAU;AACV,cAAc,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,QAAQ;AACR,cAAc,kBAAkB,CAAC;AAEjC,UAAU;AACV,cAAc,oBAAoB,CAAC;AAqDnC,UAAU;AACV,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,2BAA2B,EAAE,MAAM,0CAA0C,CAAC;AACvF,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAC9E,OAAO,EACL,gBAAgB,EAChB,wBAAwB,EACxB,SAAS,EACT,KAAK,EACL,kBAAkB,EAClB,gCAAgC,EAChC,4BAA4B,EAC5B,0BAA0B,GAC3B,MAAM,wBAAwB,CAAC"}
|
package/dist/types/actions.d.ts
CHANGED
|
@@ -38,6 +38,8 @@ export interface ExportDefinition {
|
|
|
38
38
|
extension?: string;
|
|
39
39
|
/** MIME type */
|
|
40
40
|
mimeType?: string;
|
|
41
|
+
/** Input schema for a per-export parameter form */
|
|
42
|
+
inputSchema?: JsonSchema;
|
|
41
43
|
}
|
|
42
44
|
export type ExportFormat = 'csv' | 'xml' | 'json' | 'pdf' | 'xlsx' | 'custom';
|
|
43
45
|
//# sourceMappingURL=actions.d.ts.map
|