@hexclave/shared 1.0.45 → 1.0.46
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/{admin-interface-B-UjGQ0i.d.ts → admin-interface-DQcggLpw.d.ts} +11 -11
- package/dist/{admin-interface-B-UjGQ0i.d.ts.map → admin-interface-DQcggLpw.d.ts.map} +1 -1
- package/dist/{admin-metrics-1yiWGq9z.d.ts → admin-metrics-bsOkw4YQ.d.ts} +15 -15
- package/dist/{admin-metrics-1yiWGq9z.d.ts.map → admin-metrics-bsOkw4YQ.d.ts.map} +1 -1
- package/dist/{client-interface-DjVtlQix.d.ts → client-interface-BQz4jNAC.d.ts} +10 -10
- package/dist/{client-interface-DjVtlQix.d.ts.map → client-interface-BQz4jNAC.d.ts.map} +1 -1
- package/dist/config/schema.d.ts +1 -1
- package/dist/config-authoring.d.ts +1 -1
- package/dist/{current-user-BCkMYzHx.d.ts → current-user-BBoN3hsn.d.ts} +17 -17
- package/dist/{current-user-BCkMYzHx.d.ts.map → current-user-BBoN3hsn.d.ts.map} +1 -1
- package/dist/dates-BRAvSk6L.d.ts +40 -0
- package/dist/{dates-B6ne9iOR.d.ts.map → dates-BRAvSk6L.d.ts.map} +1 -1
- package/dist/{email-outbox-BRZiK0ZG.d.ts → email-outbox-CYmVerum.d.ts} +225 -225
- package/dist/{email-outbox-BRZiK0ZG.d.ts.map → email-outbox-CYmVerum.d.ts.map} +1 -1
- package/dist/esm/config/schema.d.ts +116 -116
- package/dist/esm/interface/admin-metrics.d.ts +14 -14
- package/dist/esm/interface/conversations.d.ts +37 -37
- package/dist/esm/interface/crud/current-user.d.ts +16 -16
- package/dist/esm/interface/crud/email-outbox.d.ts +224 -224
- package/dist/esm/interface/crud/invoices.d.ts +2 -2
- package/dist/esm/interface/crud/products.d.ts +21 -21
- package/dist/esm/interface/crud/project-api-keys.d.ts +4 -4
- package/dist/esm/interface/crud/projects.d.ts +59 -59
- package/dist/esm/interface/crud/team-member-profiles.d.ts +32 -32
- package/dist/esm/interface/crud/transactions.d.ts +17 -17
- package/dist/esm/interface/crud/transactions.d.ts.map +1 -1
- package/dist/esm/interface/crud/users.d.ts +22 -22
- package/dist/esm/interface/plan-usage.d.ts +1 -1
- package/dist/esm/interface/webhooks.d.ts +4 -4
- package/dist/esm/known-errors.d.ts +3 -3
- package/dist/esm/schema-fields.d.ts +12 -12
- package/dist/esm/schema-fields.d.ts.map +1 -1
- package/dist/esm/schema-fields.js +2 -2
- package/dist/esm/schema-fields.js.map +1 -1
- package/dist/esm/sessions.d.ts +9 -9
- package/dist/esm/utils/currencies.d.ts +16 -1
- package/dist/esm/utils/currencies.d.ts.map +1 -1
- package/dist/esm/utils/currencies.js +24 -1
- package/dist/esm/utils/currencies.js.map +1 -1
- package/dist/esm/utils/dates.d.ts +18 -1
- package/dist/esm/utils/dates.d.ts.map +1 -1
- package/dist/esm/utils/dates.js +36 -15
- package/dist/esm/utils/dates.js.map +1 -1
- package/dist/helpers/password.d.ts +1 -1
- package/dist/helpers/production-mode.d.ts +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/interface/admin-interface.d.ts +2 -2
- package/dist/interface/admin-metrics.d.ts +1 -1
- package/dist/interface/client-interface.d.ts +1 -1
- package/dist/interface/conversations.d.ts +37 -37
- package/dist/interface/crud/current-user.d.ts +1 -1
- package/dist/interface/crud/email-outbox.d.ts +1 -1
- package/dist/interface/crud/invoices.d.ts +1 -1
- package/dist/interface/crud/products.d.ts +1 -1
- package/dist/interface/crud/project-api-keys.d.ts +1 -1
- package/dist/interface/crud/projects.d.ts +1 -1
- package/dist/interface/crud/team-member-profiles.d.ts +1 -1
- package/dist/interface/crud/transactions.d.ts +1 -1
- package/dist/interface/crud/users.d.ts +1 -1
- package/dist/interface/plan-usage.d.ts +1 -1
- package/dist/interface/server-interface.d.ts +1 -1
- package/dist/interface/webhooks.d.ts +1 -1
- package/dist/{invoices-BGLLnTlR.d.ts → invoices-CHo9YKbI.d.ts} +3 -3
- package/dist/{invoices-BGLLnTlR.d.ts.map → invoices-CHo9YKbI.d.ts.map} +1 -1
- package/dist/{known-errors-g7JC8z58.d.ts → known-errors-Bm4a61wL.d.ts} +4 -4
- package/dist/{known-errors-g7JC8z58.d.ts.map → known-errors-Bm4a61wL.d.ts.map} +1 -1
- package/dist/known-errors.d.ts +1 -1
- package/dist/{plan-usage-BigvGIcT.d.ts → plan-usage-ChUZqQWw.d.ts} +2 -2
- package/dist/{plan-usage-BigvGIcT.d.ts.map → plan-usage-ChUZqQWw.d.ts.map} +1 -1
- package/dist/{products-D_fcxfR0.d.ts → products-D4o8A2W0.d.ts} +23 -23
- package/dist/{products-D_fcxfR0.d.ts.map → products-D4o8A2W0.d.ts.map} +1 -1
- package/dist/{project-api-keys-OQqmKtMS.d.ts → project-api-keys--7V5X_UW.d.ts} +5 -5
- package/dist/{project-api-keys-OQqmKtMS.d.ts.map → project-api-keys--7V5X_UW.d.ts.map} +1 -1
- package/dist/{projects-C42SVFvm.d.ts → projects-CFTNXRfG.d.ts} +60 -60
- package/dist/{projects-C42SVFvm.d.ts.map → projects-CFTNXRfG.d.ts.map} +1 -1
- package/dist/{schema-Bgy-GC70.d.ts → schema-Daq0b_sf.d.ts} +118 -118
- package/dist/{schema-Bgy-GC70.d.ts.map → schema-Daq0b_sf.d.ts.map} +1 -1
- package/dist/{schema-fields-BljhsWsa.d.ts → schema-fields-DZtDQEEO.d.ts} +14 -14
- package/dist/schema-fields-DZtDQEEO.d.ts.map +1 -0
- package/dist/schema-fields.d.ts +1 -1
- package/dist/schema-fields.js +2 -2
- package/dist/schema-fields.js.map +1 -1
- package/dist/{server-interface-C1W1tZ_y.d.ts → server-interface-BjY-eS4Q.d.ts} +8 -8
- package/dist/{server-interface-C1W1tZ_y.d.ts.map → server-interface-BjY-eS4Q.d.ts.map} +1 -1
- package/dist/{sessions-C0nM8bE_.d.ts → sessions-CI-0TBQb.d.ts} +11 -11
- package/dist/{sessions-C0nM8bE_.d.ts.map → sessions-CI-0TBQb.d.ts.map} +1 -1
- package/dist/sessions.d.ts +1 -1
- package/dist/{team-member-profiles-CgYXR-Rx.d.ts → team-member-profiles-BoDEqx-0.d.ts} +33 -33
- package/dist/{team-member-profiles-CgYXR-Rx.d.ts.map → team-member-profiles-BoDEqx-0.d.ts.map} +1 -1
- package/dist/{transactions-BomBBiph.d.ts → transactions-CHNUJ42J.d.ts} +19 -19
- package/dist/transactions-CHNUJ42J.d.ts.map +1 -0
- package/dist/{users-7MKfEyyq.d.ts → users-DHNRwoSz.d.ts} +24 -24
- package/dist/{users-7MKfEyyq.d.ts.map → users-DHNRwoSz.d.ts.map} +1 -1
- package/dist/utils/currencies.d.ts +16 -1
- package/dist/utils/currencies.d.ts.map +1 -1
- package/dist/utils/currencies.js +24 -0
- package/dist/utils/currencies.js.map +1 -1
- package/dist/utils/dates.d.ts +2 -2
- package/dist/utils/dates.js +36 -14
- package/dist/utils/dates.js.map +1 -1
- package/dist/{webhooks-C5gG85Ce.d.ts → webhooks-8Ts1Clcb.d.ts} +5 -5
- package/dist/{webhooks-C5gG85Ce.d.ts.map → webhooks-8Ts1Clcb.d.ts.map} +1 -1
- package/package.json +1 -1
- package/src/schema-fields.ts +13 -2
- package/src/utils/currencies.tsx +69 -0
- package/src/utils/dates.tsx +104 -15
- package/dist/dates-B6ne9iOR.d.ts +0 -23
- package/dist/schema-fields-BljhsWsa.d.ts.map +0 -1
- package/dist/transactions-BomBBiph.d.ts.map +0 -1
|
@@ -18,6 +18,23 @@ declare function subtractInterval(date: Date, interval: Interval): Date;
|
|
|
18
18
|
declare function addInterval(date: Date, interval: Interval): Date;
|
|
19
19
|
declare const FAR_FUTURE_DATE: Date;
|
|
20
20
|
declare function getIntervalsElapsed(anchor: Date, to: Date, repeat: DayInterval): number;
|
|
21
|
+
/**
|
|
22
|
+
* The UTC millis of the `occurrence`-th (1-based) repeat of `interval` after `anchorMillis`.
|
|
23
|
+
*
|
|
24
|
+
* Each boundary is computed from the *original* anchor (never by stepping off the previous, possibly
|
|
25
|
+
* clamped, boundary) so the anchor's day-of-month is preserved across resets: a Jan 31 anchor yields
|
|
26
|
+
* Feb 28, Mar 31, Apr 30, ... (matching Stripe's billing-cycle behavior) rather than drifting to
|
|
27
|
+
* Feb 28, Mar 28, ... . Month/year overflow (e.g. Jan 31 -> Feb) is clamped to the target month's
|
|
28
|
+
* last day. Day/week are exact multiples (no calendar involved, so no drift possible).
|
|
29
|
+
*
|
|
30
|
+
* Everything is done in UTC (unlike `addInterval`, which uses local-time Date accessors) so the
|
|
31
|
+
* result is deterministic regardless of the server's timezone — this is relied upon by bulldozer
|
|
32
|
+
* folds, which must be reproducible across machines.
|
|
33
|
+
*
|
|
34
|
+
* `occurrence` 0 returns the anchor itself; `getIntervalsElapsed` counts these same boundaries, so
|
|
35
|
+
* the two are always consistent for a given DayInterval.
|
|
36
|
+
*/
|
|
37
|
+
declare function nthDayIntervalMillis(anchorMillis: number, interval: DayInterval, occurrence: number): number;
|
|
21
38
|
//#endregion
|
|
22
|
-
export { DayInterval, FAR_FUTURE_DATE, Interval, addInterval, fromNow, fromNowDetailed, getInputDatetimeLocalString, getIntervalsElapsed, isWeekend, subtractInterval };
|
|
39
|
+
export { DayInterval, FAR_FUTURE_DATE, Interval, addInterval, fromNow, fromNowDetailed, getInputDatetimeLocalString, getIntervalsElapsed, isWeekend, nthDayIntervalMillis, subtractInterval };
|
|
23
40
|
//# sourceMappingURL=dates.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dates.d.ts","names":[],"sources":["../../../src/utils/dates.tsx"],"mappings":";iBAIgB,SAAA,CAAU,IAAU,EAAJ,IAAI;AAAA,iBAuBpB,OAAA,CAAQ,IAAU,EAAJ,IAAI;AAAA,iBAiClB,eAAA,CAAgB,IAAA,EAAM,IAAI;EACxC,MAAA;EAzD8B;AAAI;AAuBpC;EAsCE,kBAAA;AAAA;;AAtCgC;AAiClC;iBAkDgB,2BAAA,CAA4B,IAAU,EAAJ,IAAI;AAAA,KAkC1C,QAAA;AAAA,KACA,WAAA;AAAA,iBA+CI,gBAAA,CAAiB,IAAA,EAAM,IAAA,EAAM,QAAA,EAAU,QAAA,GAAW,IAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"dates.d.ts","names":[],"sources":["../../../src/utils/dates.tsx"],"mappings":";iBAIgB,SAAA,CAAU,IAAU,EAAJ,IAAI;AAAA,iBAuBpB,OAAA,CAAQ,IAAU,EAAJ,IAAI;AAAA,iBAiClB,eAAA,CAAgB,IAAA,EAAM,IAAI;EACxC,MAAA;EAzD8B;AAAI;AAuBpC;EAsCE,kBAAA;AAAA;;AAtCgC;AAiClC;iBAkDgB,2BAAA,CAA4B,IAAU,EAAJ,IAAI;AAAA,KAkC1C,QAAA;AAAA,KACA,WAAA;AAAA,iBA+CI,gBAAA,CAAiB,IAAA,EAAM,IAAA,EAAM,QAAA,EAAU,QAAA,GAAW,IAAA;AAAA,iBASlD,WAAA,CAAY,IAAA,EAAM,IAAA,EAAM,QAAA,EAAU,QAAA,GAAW,IAAA;AAAA,cAIhD,eAAA,EAAe,IAA6B;AAAA,iBAgBzC,mBAAA,CAAoB,MAAA,EAAQ,IAAA,EAAM,EAAA,EAAI,IAAA,EAAM,MAAA,EAAQ,WAAA;;AA5JhD;AA6CpB;;;;AAAsD;AAkCtD;;;;AAAoB;AACpB;;;;iBA6HgB,oBAAA,CAAqB,YAAA,UAAsB,QAAA,EAAU,WAAW,EAAE,UAAA"}
|
package/dist/esm/utils/dates.js
CHANGED
|
@@ -99,26 +99,47 @@ function getMsPerDayIntervalUnit(unit) {
|
|
|
99
99
|
}
|
|
100
100
|
function getIntervalsElapsed(anchor, to, repeat) {
|
|
101
101
|
const [amount, unit] = repeat;
|
|
102
|
-
|
|
102
|
+
const toMillis = to.getTime();
|
|
103
|
+
if (toMillis <= anchor.getTime()) return 0;
|
|
103
104
|
if (unit === "day" || unit === "week") {
|
|
104
105
|
const msPerUnit = getMsPerDayIntervalUnit(unit);
|
|
105
|
-
const diffMs =
|
|
106
|
+
const diffMs = toMillis - anchor.getTime();
|
|
106
107
|
return Math.floor(diffMs / (msPerUnit * amount));
|
|
107
108
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
109
|
+
let count = 0;
|
|
110
|
+
while (nthDayIntervalMillis(anchor.getTime(), repeat, count + 1) <= toMillis) count += 1;
|
|
111
|
+
return count;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* The UTC millis of the `occurrence`-th (1-based) repeat of `interval` after `anchorMillis`.
|
|
115
|
+
*
|
|
116
|
+
* Each boundary is computed from the *original* anchor (never by stepping off the previous, possibly
|
|
117
|
+
* clamped, boundary) so the anchor's day-of-month is preserved across resets: a Jan 31 anchor yields
|
|
118
|
+
* Feb 28, Mar 31, Apr 30, ... (matching Stripe's billing-cycle behavior) rather than drifting to
|
|
119
|
+
* Feb 28, Mar 28, ... . Month/year overflow (e.g. Jan 31 -> Feb) is clamped to the target month's
|
|
120
|
+
* last day. Day/week are exact multiples (no calendar involved, so no drift possible).
|
|
121
|
+
*
|
|
122
|
+
* Everything is done in UTC (unlike `addInterval`, which uses local-time Date accessors) so the
|
|
123
|
+
* result is deterministic regardless of the server's timezone — this is relied upon by bulldozer
|
|
124
|
+
* folds, which must be reproducible across machines.
|
|
125
|
+
*
|
|
126
|
+
* `occurrence` 0 returns the anchor itself; `getIntervalsElapsed` counts these same boundaries, so
|
|
127
|
+
* the two are always consistent for a given DayInterval.
|
|
128
|
+
*/
|
|
129
|
+
function nthDayIntervalMillis(anchorMillis, interval, occurrence) {
|
|
130
|
+
const [count, unit] = interval;
|
|
131
|
+
const totalUnits = count * occurrence;
|
|
132
|
+
if (unit === "day" || unit === "week") return anchorMillis + totalUnits * getMsPerDayIntervalUnit(unit);
|
|
133
|
+
const anchor = new Date(anchorMillis);
|
|
134
|
+
const monthsToAdd = unit === "year" ? totalUnits * 12 : totalUnits;
|
|
135
|
+
const absoluteMonth = anchor.getUTCFullYear() * 12 + anchor.getUTCMonth() + monthsToAdd;
|
|
136
|
+
const targetYear = Math.floor(absoluteMonth / 12);
|
|
137
|
+
const targetMonth = absoluteMonth - targetYear * 12;
|
|
138
|
+
const daysInTargetMonth = new Date(Date.UTC(targetYear, targetMonth + 1, 0)).getUTCDate();
|
|
139
|
+
const clampedDay = Math.min(anchor.getUTCDate(), daysInTargetMonth);
|
|
140
|
+
return Date.UTC(targetYear, targetMonth, clampedDay, anchor.getUTCHours(), anchor.getUTCMinutes(), anchor.getUTCSeconds(), anchor.getUTCMilliseconds());
|
|
120
141
|
}
|
|
121
142
|
//#endregion
|
|
122
|
-
export { FAR_FUTURE_DATE, addInterval, fromNow, fromNowDetailed, getInputDatetimeLocalString, getIntervalsElapsed, isWeekend, subtractInterval };
|
|
143
|
+
export { FAR_FUTURE_DATE, addInterval, fromNow, fromNowDetailed, getInputDatetimeLocalString, getIntervalsElapsed, isWeekend, nthDayIntervalMillis, subtractInterval };
|
|
123
144
|
|
|
124
145
|
//# sourceMappingURL=dates.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dates.js","names":[],"sources":["../../../src/utils/dates.tsx"],"sourcesContent":["import { intervalSchema } from \"../schema-fields\";\nimport { HexclaveAssertionError } from \"./errors\";\nimport { remainder } from \"./math\";\n\nexport function isWeekend(date: Date): boolean {\n return date.getDay() === 0 || date.getDay() === 6;\n}\n\nimport.meta.vitest?.test(\"isWeekend\", ({ expect }) => {\n // Sunday (day 0)\n expect(isWeekend(new Date(2023, 0, 1))).toBe(true);\n // Saturday (day 6)\n expect(isWeekend(new Date(2023, 0, 7))).toBe(true);\n // Monday (day 1)\n expect(isWeekend(new Date(2023, 0, 2))).toBe(false);\n // Friday (day 5)\n expect(isWeekend(new Date(2023, 0, 6))).toBe(false);\n});\n\nconst agoUnits = [\n [60, 'second'],\n [60, 'minute'],\n [24, 'hour'],\n [7, 'day'],\n [5, 'week'],\n] as const;\n\nexport function fromNow(date: Date): string {\n return fromNowDetailed(date).result;\n}\n\nimport.meta.vitest?.test(\"fromNow\", ({ expect }) => {\n // Set a fixed date for testing\n const fixedDate = new Date(\"2023-01-15T12:00:00.000Z\");\n\n // Use Vitest's fake timers\n import.meta.vitest?.vi.useFakeTimers();\n import.meta.vitest?.vi.setSystemTime(fixedDate);\n\n // Test past times\n expect(fromNow(new Date(\"2023-01-15T11:59:50.000Z\"))).toBe(\"just now\");\n expect(fromNow(new Date(\"2023-01-15T11:59:00.000Z\"))).toBe(\"1 minute ago\");\n expect(fromNow(new Date(\"2023-01-15T11:00:00.000Z\"))).toBe(\"1 hour ago\");\n expect(fromNow(new Date(\"2023-01-14T12:00:00.000Z\"))).toBe(\"1 day ago\");\n expect(fromNow(new Date(\"2023-01-08T12:00:00.000Z\"))).toBe(\"1 week ago\");\n\n // Test future times\n expect(fromNow(new Date(\"2023-01-15T12:00:10.000Z\"))).toBe(\"just now\");\n expect(fromNow(new Date(\"2023-01-15T12:01:00.000Z\"))).toBe(\"in 1 minute\");\n expect(fromNow(new Date(\"2023-01-15T13:00:00.000Z\"))).toBe(\"in 1 hour\");\n expect(fromNow(new Date(\"2023-01-16T12:00:00.000Z\"))).toBe(\"in 1 day\");\n expect(fromNow(new Date(\"2023-01-22T12:00:00.000Z\"))).toBe(\"in 1 week\");\n\n // Test very old dates (should use date format)\n expect(fromNow(new Date(\"2022-01-15T12:00:00.000Z\"))).toMatch(/Jan 15, 2022/);\n\n // Restore real timers\n import.meta.vitest?.vi.useRealTimers();\n});\n\nexport function fromNowDetailed(date: Date): {\n result: string,\n /**\n * May be Infinity if the result will never change.\n */\n secondsUntilChange: number,\n} {\n if (!(date instanceof Date)) {\n throw new Error(`fromNow only accepts Date objects (received: ${date})`);\n }\n\n const now = new Date();\n const elapsed = now.getTime() - date.getTime();\n\n let remainingInUnit = Math.abs(elapsed) / 1000;\n if (remainingInUnit < 15) {\n return {\n result: 'just now',\n secondsUntilChange: 15 - remainingInUnit,\n };\n }\n let unitInSeconds = 1;\n for (const [nextUnitSize, unitName] of agoUnits) {\n const rounded = Math.round(remainingInUnit);\n if (rounded < nextUnitSize) {\n if (elapsed < 0) {\n return {\n result: `in ${rounded} ${unitName}${rounded === 1 ? '' : 's'}`,\n secondsUntilChange: remainder((remainingInUnit - rounded + 0.5) * unitInSeconds, unitInSeconds),\n };\n } else {\n return {\n result: `${rounded} ${unitName}${rounded === 1 ? '' : 's'} ago`,\n secondsUntilChange: remainder((rounded - remainingInUnit - 0.5) * unitInSeconds, unitInSeconds),\n };\n }\n }\n unitInSeconds *= nextUnitSize;\n remainingInUnit /= nextUnitSize;\n }\n\n return {\n result: date.toLocaleDateString('en-US', { year: 'numeric', month: 'short', day: 'numeric' }),\n secondsUntilChange: Infinity,\n };\n}\n\n/**\n * Returns a string representation of the given date in the format expected by the `datetime-local` input type.\n */\nexport function getInputDatetimeLocalString(date: Date): string {\n date = new Date(date);\n date.setMinutes(date.getMinutes() - date.getTimezoneOffset());\n return date.toISOString().slice(0, 19);\n}\n\nimport.meta.vitest?.test(\"getInputDatetimeLocalString\", ({ expect }) => {\n // Use Vitest's fake timers to ensure consistent timezone behavior\n import.meta.vitest?.vi.useFakeTimers();\n\n // Test with a specific date\n const mockDate = new Date(\"2023-01-15T12:30:45.000Z\");\n const result = getInputDatetimeLocalString(mockDate);\n\n // The result should be in the format YYYY-MM-DDTHH:MM:SS\n expect(result).toMatch(/^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}$/);\n\n // Test with different dates\n const dates = [\n new Date(\"2023-01-01T00:00:00.000Z\"),\n new Date(\"2023-06-15T23:59:59.000Z\"),\n new Date(\"2023-12-31T12:34:56.000Z\"),\n ];\n\n for (const date of dates) {\n const result = getInputDatetimeLocalString(date);\n expect(result).toMatch(/^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}$/);\n }\n\n // Restore real timers\n import.meta.vitest?.vi.useRealTimers();\n});\n\n\nexport type Interval = [number, 'millisecond' | 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'year'];\nexport type DayInterval = [number, 'day' | 'week' | 'month' | 'year'];\n\nfunction applyInterval(date: Date, times: number, interval: Interval): Date {\n if (!intervalSchema.isValidSync(interval)) {\n throw new HexclaveAssertionError(`Invalid interval`, { interval });\n }\n const [amount, unit] = interval;\n switch (unit) {\n case 'millisecond': {\n date.setMilliseconds(date.getMilliseconds() + amount * times);\n break;\n }\n case 'second': {\n date.setSeconds(date.getSeconds() + amount * times);\n break;\n }\n case 'minute': {\n date.setMinutes(date.getMinutes() + amount * times);\n break;\n }\n case 'hour': {\n date.setHours(date.getHours() + amount * times);\n break;\n }\n case 'day': {\n date.setDate(date.getDate() + amount * times);\n break;\n }\n case 'week': {\n date.setDate(date.getDate() + amount * times * 7);\n break;\n }\n case 'month': {\n date.setMonth(date.getMonth() + amount * times);\n break;\n }\n case 'year': {\n date.setFullYear(date.getFullYear() + amount * times);\n break;\n }\n default: {\n throw new HexclaveAssertionError(`Invalid interval despite schema validation`, { interval });\n }\n }\n return date;\n}\n\nexport function subtractInterval(date: Date, interval: Interval): Date {\n return applyInterval(date, -1, interval);\n}\n\nexport function addInterval(date: Date, interval: Interval): Date {\n return applyInterval(date, 1, interval);\n}\n\nexport const FAR_FUTURE_DATE = new Date(8640000000000000); // 13 Sep 275760 00:00:00 UTC\n\nfunction getMsPerDayIntervalUnit(unit: 'day' | 'week'): number {\n if (unit === 'day') {\n return 24 * 60 * 60 * 1000;\n }\n return 7 * 24 * 60 * 60 * 1000;\n}\n\n\nexport function getIntervalsElapsed(anchor: Date, to: Date, repeat: DayInterval): number {\n const [amount, unit] = repeat;\n if (to <= anchor) return 0;\n if (unit === 'day' || unit === 'week') {\n const msPerUnit = getMsPerDayIntervalUnit(unit);\n const diffMs = to.getTime() - anchor.getTime();\n return Math.floor(diffMs / (msPerUnit * amount));\n }\n if ([\"month\", \"year\"].includes(unit)) {\n let count = 0;\n let current = new Date(anchor);\n for (; ;) {\n const next = addInterval(new Date(current), [amount, unit]);\n if (next > to) break;\n current = next;\n count += 1;\n }\n return count;\n }\n return 0;\n}\n\nimport.meta.vitest?.test(\"getIntervalsElapsed\", ({ expect }) => {\n const anchor = new Date('2025-01-01T00:00:00.000Z');\n const to = new Date('2025-01-15T00:00:00.000Z');\n expect(getIntervalsElapsed(anchor, to, [1, 'week'])).toBe(2);\n expect(getIntervalsElapsed(anchor, to, [3, 'day'])).toBe(4);\n\n const mAnchor = new Date('2023-01-31T00:00:00.000Z');\n const mTo = new Date('2023-03-01T00:00:00.000Z');\n expect(getIntervalsElapsed(mAnchor, mTo, [1, 'month'])).toBe(0);\n\n const yAnchor = new Date('2020-01-01T00:00:00.000Z');\n const yTo = new Date('2022-06-01T00:00:00.000Z');\n expect(getIntervalsElapsed(yAnchor, yTo, [1, 'year'])).toBe(2);\n});\n"],"mappings":";;;;AAIA,SAAgB,UAAU,MAAqB;CAC7C,OAAO,KAAK,OAAO,MAAM,KAAK,KAAK,OAAO,MAAM;AAClD;AAaA,MAAM,WAAW;CACf,CAAC,IAAI,QAAQ;CACb,CAAC,IAAI,QAAQ;CACb,CAAC,IAAI,MAAM;CACX,CAAC,GAAG,KAAK;CACT,CAAC,GAAG,MAAM;AACZ;AAEA,SAAgB,QAAQ,MAAoB;CAC1C,OAAO,gBAAgB,IAAI,CAAC,CAAC;AAC/B;AA+BA,SAAgB,gBAAgB,MAM9B;CACA,IAAI,EAAE,gBAAgB,OACpB,MAAM,IAAI,MAAM,gDAAgD,KAAK,EAAE;CAIzE,MAAM,2BAAU,IADA,KACE,EAAA,CAAE,QAAQ,IAAI,KAAK,QAAQ;CAE7C,IAAI,kBAAkB,KAAK,IAAI,OAAO,IAAI;CAC1C,IAAI,kBAAkB,IACpB,OAAO;EACL,QAAQ;EACR,oBAAoB,KAAK;CAC3B;CAEF,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Schema } from \"../schema-fields\";\nimport { HexclaveAssertionError } from \"./errors\";\nimport { remainder } from \"./math\";\n\nexport function isWeekend(date: Date): boolean {\n return date.getDay() === 0 || date.getDay() === 6;\n}\n\nimport.meta.vitest?.test(\"isWeekend\", ({ expect }) => {\n // Sunday (day 0)\n expect(isWeekend(new Date(2023, 0, 1))).toBe(true);\n // Saturday (day 6)\n expect(isWeekend(new Date(2023, 0, 7))).toBe(true);\n // Monday (day 1)\n expect(isWeekend(new Date(2023, 0, 2))).toBe(false);\n // Friday (day 5)\n expect(isWeekend(new Date(2023, 0, 6))).toBe(false);\n});\n\nconst agoUnits = [\n [60, 'second'],\n [60, 'minute'],\n [24, 'hour'],\n [7, 'day'],\n [5, 'week'],\n] as const;\n\nexport function fromNow(date: Date): string {\n return fromNowDetailed(date).result;\n}\n\nimport.meta.vitest?.test(\"fromNow\", ({ expect }) => {\n // Set a fixed date for testing\n const fixedDate = new Date(\"2023-01-15T12:00:00.000Z\");\n\n // Use Vitest's fake timers\n import.meta.vitest?.vi.useFakeTimers();\n import.meta.vitest?.vi.setSystemTime(fixedDate);\n\n // Test past times\n expect(fromNow(new Date(\"2023-01-15T11:59:50.000Z\"))).toBe(\"just now\");\n expect(fromNow(new Date(\"2023-01-15T11:59:00.000Z\"))).toBe(\"1 minute ago\");\n expect(fromNow(new Date(\"2023-01-15T11:00:00.000Z\"))).toBe(\"1 hour ago\");\n expect(fromNow(new Date(\"2023-01-14T12:00:00.000Z\"))).toBe(\"1 day ago\");\n expect(fromNow(new Date(\"2023-01-08T12:00:00.000Z\"))).toBe(\"1 week ago\");\n\n // Test future times\n expect(fromNow(new Date(\"2023-01-15T12:00:10.000Z\"))).toBe(\"just now\");\n expect(fromNow(new Date(\"2023-01-15T12:01:00.000Z\"))).toBe(\"in 1 minute\");\n expect(fromNow(new Date(\"2023-01-15T13:00:00.000Z\"))).toBe(\"in 1 hour\");\n expect(fromNow(new Date(\"2023-01-16T12:00:00.000Z\"))).toBe(\"in 1 day\");\n expect(fromNow(new Date(\"2023-01-22T12:00:00.000Z\"))).toBe(\"in 1 week\");\n\n // Test very old dates (should use date format)\n expect(fromNow(new Date(\"2022-01-15T12:00:00.000Z\"))).toMatch(/Jan 15, 2022/);\n\n // Restore real timers\n import.meta.vitest?.vi.useRealTimers();\n});\n\nexport function fromNowDetailed(date: Date): {\n result: string,\n /**\n * May be Infinity if the result will never change.\n */\n secondsUntilChange: number,\n} {\n if (!(date instanceof Date)) {\n throw new Error(`fromNow only accepts Date objects (received: ${date})`);\n }\n\n const now = new Date();\n const elapsed = now.getTime() - date.getTime();\n\n let remainingInUnit = Math.abs(elapsed) / 1000;\n if (remainingInUnit < 15) {\n return {\n result: 'just now',\n secondsUntilChange: 15 - remainingInUnit,\n };\n }\n let unitInSeconds = 1;\n for (const [nextUnitSize, unitName] of agoUnits) {\n const rounded = Math.round(remainingInUnit);\n if (rounded < nextUnitSize) {\n if (elapsed < 0) {\n return {\n result: `in ${rounded} ${unitName}${rounded === 1 ? '' : 's'}`,\n secondsUntilChange: remainder((remainingInUnit - rounded + 0.5) * unitInSeconds, unitInSeconds),\n };\n } else {\n return {\n result: `${rounded} ${unitName}${rounded === 1 ? '' : 's'} ago`,\n secondsUntilChange: remainder((rounded - remainingInUnit - 0.5) * unitInSeconds, unitInSeconds),\n };\n }\n }\n unitInSeconds *= nextUnitSize;\n remainingInUnit /= nextUnitSize;\n }\n\n return {\n result: date.toLocaleDateString('en-US', { year: 'numeric', month: 'short', day: 'numeric' }),\n secondsUntilChange: Infinity,\n };\n}\n\n/**\n * Returns a string representation of the given date in the format expected by the `datetime-local` input type.\n */\nexport function getInputDatetimeLocalString(date: Date): string {\n date = new Date(date);\n date.setMinutes(date.getMinutes() - date.getTimezoneOffset());\n return date.toISOString().slice(0, 19);\n}\n\nimport.meta.vitest?.test(\"getInputDatetimeLocalString\", ({ expect }) => {\n // Use Vitest's fake timers to ensure consistent timezone behavior\n import.meta.vitest?.vi.useFakeTimers();\n\n // Test with a specific date\n const mockDate = new Date(\"2023-01-15T12:30:45.000Z\");\n const result = getInputDatetimeLocalString(mockDate);\n\n // The result should be in the format YYYY-MM-DDTHH:MM:SS\n expect(result).toMatch(/^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}$/);\n\n // Test with different dates\n const dates = [\n new Date(\"2023-01-01T00:00:00.000Z\"),\n new Date(\"2023-06-15T23:59:59.000Z\"),\n new Date(\"2023-12-31T12:34:56.000Z\"),\n ];\n\n for (const date of dates) {\n const result = getInputDatetimeLocalString(date);\n expect(result).toMatch(/^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}$/);\n }\n\n // Restore real timers\n import.meta.vitest?.vi.useRealTimers();\n});\n\n\nexport type Interval = [number, 'millisecond' | 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'year'];\nexport type DayInterval = [number, 'day' | 'week' | 'month' | 'year'];\n\nfunction applyInterval(date: Date, times: number, interval: Interval): Date {\n if (!intervalSchema.isValidSync(interval)) {\n throw new HexclaveAssertionError(`Invalid interval`, { interval });\n }\n const [amount, unit] = interval;\n switch (unit) {\n case 'millisecond': {\n date.setMilliseconds(date.getMilliseconds() + amount * times);\n break;\n }\n case 'second': {\n date.setSeconds(date.getSeconds() + amount * times);\n break;\n }\n case 'minute': {\n date.setMinutes(date.getMinutes() + amount * times);\n break;\n }\n case 'hour': {\n date.setHours(date.getHours() + amount * times);\n break;\n }\n case 'day': {\n date.setDate(date.getDate() + amount * times);\n break;\n }\n case 'week': {\n date.setDate(date.getDate() + amount * times * 7);\n break;\n }\n case 'month': {\n date.setMonth(date.getMonth() + amount * times);\n break;\n }\n case 'year': {\n date.setFullYear(date.getFullYear() + amount * times);\n break;\n }\n default: {\n throw new HexclaveAssertionError(`Invalid interval despite schema validation`, { interval });\n }\n }\n return date;\n}\n\nexport function subtractInterval(date: Date, interval: Interval): Date {\n return applyInterval(date, -1, interval);\n}\n\n// One-shot local-time interval arithmetic that OVERFLOWS (Jan 31 + 1 month -> Mar 3, via\n// Date#setMonth) rather than clamping. Use this for single-step period math where JS/Stripe overflow\n// semantics are what we want (e.g. computing a subscription's currentPeriodEnd). For recurring\n// grant/reset BOUNDARIES, use `nthDayIntervalMillis` / `getIntervalsElapsed` instead — they clamp to\n// month-end and compute in UTC from a fixed anchor, and mixing the two would drift.\nexport function addInterval(date: Date, interval: Interval): Date {\n return applyInterval(date, 1, interval);\n}\n\nexport const FAR_FUTURE_DATE = new Date(8640000000000000); // 13 Sep 275760 00:00:00 UTC\n\nfunction getMsPerDayIntervalUnit(unit: 'day' | 'week'): number {\n if (unit === 'day') {\n return 24 * 60 * 60 * 1000;\n }\n return 7 * 24 * 60 * 60 * 1000;\n}\n\n\n// The number of full `repeat` intervals elapsed from `anchor` up to (and including) `to`, i.e. the\n// largest n >= 0 with the n-th boundary <= to. Boundaries are the SAME ones `nthDayIntervalMillis`\n// computes (anchor-relative, UTC, month-end clamped), so counting and boundary-computation never\n// disagree — a Jan 31 monthly anchor has elapsed one interval by Feb 28, matching the reset the\n// bulldozer item-repeat fold actually emits. (This is why it must NOT be built on `addInterval`,\n// which is local-time and overflows instead of clamping.)\nexport function getIntervalsElapsed(anchor: Date, to: Date, repeat: DayInterval): number {\n const [amount, unit] = repeat;\n const toMillis = to.getTime();\n if (toMillis <= anchor.getTime()) return 0;\n if (unit === 'day' || unit === 'week') {\n const msPerUnit = getMsPerDayIntervalUnit(unit);\n const diffMs = toMillis - anchor.getTime();\n return Math.floor(diffMs / (msPerUnit * amount));\n }\n // month/year: walk anchor-relative boundaries. The count is small in practice (bounded by the\n // number of billing periods since the anchor), so a linear walk is fine.\n let count = 0;\n while (nthDayIntervalMillis(anchor.getTime(), repeat, count + 1) <= toMillis) count += 1;\n return count;\n}\n\nimport.meta.vitest?.test(\"getIntervalsElapsed\", ({ expect }) => {\n const anchor = new Date('2025-01-01T00:00:00.000Z');\n const to = new Date('2025-01-15T00:00:00.000Z');\n expect(getIntervalsElapsed(anchor, to, [1, 'week'])).toBe(2);\n expect(getIntervalsElapsed(anchor, to, [3, 'day'])).toBe(4);\n\n // Jan 31 monthly anchor: the first boundary is clamped to Feb 28, which is <= Mar 1, so one\n // interval has elapsed (anchor-relative clamped math, consistent with nthDayIntervalMillis).\n const mAnchor = new Date('2023-01-31T00:00:00.000Z');\n const mTo = new Date('2023-03-01T00:00:00.000Z');\n expect(getIntervalsElapsed(mAnchor, mTo, [1, 'month'])).toBe(1);\n\n const yAnchor = new Date('2020-01-01T00:00:00.000Z');\n const yTo = new Date('2022-06-01T00:00:00.000Z');\n expect(getIntervalsElapsed(yAnchor, yTo, [1, 'year'])).toBe(2);\n});\n\n/**\n * The UTC millis of the `occurrence`-th (1-based) repeat of `interval` after `anchorMillis`.\n *\n * Each boundary is computed from the *original* anchor (never by stepping off the previous, possibly\n * clamped, boundary) so the anchor's day-of-month is preserved across resets: a Jan 31 anchor yields\n * Feb 28, Mar 31, Apr 30, ... (matching Stripe's billing-cycle behavior) rather than drifting to\n * Feb 28, Mar 28, ... . Month/year overflow (e.g. Jan 31 -> Feb) is clamped to the target month's\n * last day. Day/week are exact multiples (no calendar involved, so no drift possible).\n *\n * Everything is done in UTC (unlike `addInterval`, which uses local-time Date accessors) so the\n * result is deterministic regardless of the server's timezone — this is relied upon by bulldozer\n * folds, which must be reproducible across machines.\n *\n * `occurrence` 0 returns the anchor itself; `getIntervalsElapsed` counts these same boundaries, so\n * the two are always consistent for a given DayInterval.\n */\nexport function nthDayIntervalMillis(anchorMillis: number, interval: DayInterval, occurrence: number): number {\n const [count, unit] = interval;\n const totalUnits = count * occurrence;\n if (unit === 'day' || unit === 'week') {\n return anchorMillis + totalUnits * getMsPerDayIntervalUnit(unit);\n }\n const anchor = new Date(anchorMillis);\n const monthsToAdd = unit === 'year' ? totalUnits * 12 : totalUnits;\n const absoluteMonth = anchor.getUTCFullYear() * 12 + anchor.getUTCMonth() + monthsToAdd;\n const targetYear = Math.floor(absoluteMonth / 12);\n const targetMonth = absoluteMonth - targetYear * 12;\n // Day 0 of the following month is the last day of the target month, so this gives its length.\n const daysInTargetMonth = new Date(Date.UTC(targetYear, targetMonth + 1, 0)).getUTCDate();\n const clampedDay = Math.min(anchor.getUTCDate(), daysInTargetMonth);\n return Date.UTC(\n targetYear,\n targetMonth,\n clampedDay,\n anchor.getUTCHours(),\n anchor.getUTCMinutes(),\n anchor.getUTCSeconds(),\n anchor.getUTCMilliseconds(),\n );\n}\n\nimport.meta.vitest?.test(\"nthDayIntervalMillis\", ({ expect }) => {\n const at = (iso: string) => new Date(iso).getTime();\n const iso = (millis: number) => new Date(millis).toISOString();\n\n // day / week are exact multiples (no drift), and honor the count.\n const dayAnchor = at('2025-01-01T08:30:00.000Z');\n expect(iso(nthDayIntervalMillis(dayAnchor, [1, 'day'], 1))).toBe('2025-01-02T08:30:00.000Z');\n expect(iso(nthDayIntervalMillis(dayAnchor, [3, 'day'], 4))).toBe('2025-01-13T08:30:00.000Z');\n expect(iso(nthDayIntervalMillis(dayAnchor, [2, 'week'], 3))).toBe('2025-02-12T08:30:00.000Z'); // 6 weeks = 42 days after Jan 1\n\n // Jan 31 monthly: clamp in short months, restore to the anchor day in long ones.\n const jan31 = at('2025-01-31T00:00:00.000Z');\n expect(iso(nthDayIntervalMillis(jan31, [1, 'month'], 1))).toBe('2025-02-28T00:00:00.000Z');\n expect(iso(nthDayIntervalMillis(jan31, [1, 'month'], 2))).toBe('2025-03-31T00:00:00.000Z');\n expect(iso(nthDayIntervalMillis(jan31, [1, 'month'], 3))).toBe('2025-04-30T00:00:00.000Z');\n\n // Anchor-day preservation: a Feb 28 anchor stays on day 28 (never jumps to Mar 31), unlike the\n // Jan 31 anchor above which restores to Mar 31. This is the evidence we compute from the anchor.\n const feb28 = at('2025-02-28T00:00:00.000Z');\n expect(iso(nthDayIntervalMillis(feb28, [1, 'month'], 1))).toBe('2025-03-28T00:00:00.000Z');\n\n // Leap-year Feb: Feb 29 anchor clamps to Feb 28 in a non-leap year and restores in the next leap year.\n const feb29 = at('2024-02-29T00:00:00.000Z');\n expect(iso(nthDayIntervalMillis(feb29, [1, 'year'], 1))).toBe('2025-02-28T00:00:00.000Z');\n expect(iso(nthDayIntervalMillis(feb29, [1, 'year'], 4))).toBe('2028-02-29T00:00:00.000Z');\n // Jan 31 monthly landing in a leap February clamps to Feb 29, not Feb 28.\n const jan31Leap = at('2024-01-31T00:00:00.000Z');\n expect(iso(nthDayIntervalMillis(jan31Leap, [1, 'month'], 1))).toBe('2024-02-29T00:00:00.000Z');\n\n // End-of-December rollover: absolute-month math carries the year.\n const dec31 = at('2025-12-31T00:00:00.000Z');\n expect(iso(nthDayIntervalMillis(dec31, [1, 'month'], 1))).toBe('2026-01-31T00:00:00.000Z');\n expect(iso(nthDayIntervalMillis(dec31, [1, 'month'], 2))).toBe('2026-02-28T00:00:00.000Z');\n expect(iso(nthDayIntervalMillis(dec31, [1, 'month'], 3))).toBe('2026-03-31T00:00:00.000Z');\n expect(iso(nthDayIntervalMillis(dec31, [1, 'year'], 1))).toBe('2026-12-31T00:00:00.000Z');\n\n // Time-of-day is preserved through month clamping.\n const withTime = at('2025-01-31T13:45:59.123Z');\n expect(iso(nthDayIntervalMillis(withTime, [1, 'month'], 1))).toBe('2025-02-28T13:45:59.123Z');\n});\n"],"mappings":";;;;AAIA,SAAgB,UAAU,MAAqB;CAC7C,OAAO,KAAK,OAAO,MAAM,KAAK,KAAK,OAAO,MAAM;AAClD;AAaA,MAAM,WAAW;CACf,CAAC,IAAI,QAAQ;CACb,CAAC,IAAI,QAAQ;CACb,CAAC,IAAI,MAAM;CACX,CAAC,GAAG,KAAK;CACT,CAAC,GAAG,MAAM;AACZ;AAEA,SAAgB,QAAQ,MAAoB;CAC1C,OAAO,gBAAgB,IAAI,CAAC,CAAC;AAC/B;AA+BA,SAAgB,gBAAgB,MAM9B;CACA,IAAI,EAAE,gBAAgB,OACpB,MAAM,IAAI,MAAM,gDAAgD,KAAK,EAAE;CAIzE,MAAM,2BAAU,IADA,KACE,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YAA4B;CAC5G,MAAM,CAAC,OAAO,QAAQ;CACtB,MAAM,aAAa,QAAQ;CAC3B,IAAI,SAAS,SAAS,SAAS,QAC7B,OAAO,eAAe,aAAa,wBAAwB,IAAI;CAEjE,MAAM,SAAS,IAAI,KAAK,YAAY;CACpC,MAAM,cAAc,SAAS,SAAS,aAAa,KAAK;CACxD,MAAM,gBAAgB,OAAO,eAAe,IAAI,KAAK,OAAO,YAAY,IAAI;CAC5E,MAAM,aAAa,KAAK,MAAM,gBAAgB,EAAE;CAChD,MAAM,cAAc,gBAAgB,aAAa;CAEjD,MAAM,oBAAoB,IAAI,KAAK,KAAK,IAAI,YAAY,cAAc,GAAG,CAAC,CAAC,CAAC,CAAC,WAAW;CACxF,MAAM,aAAa,KAAK,IAAI,OAAO,WAAW,GAAG,iBAAiB;CAClE,OAAO,KAAK,IACV,YACA,aACA,YACA,OAAO,YAAY,GACnB,OAAO,cAAc,GACrB,OAAO,cAAc,GACrB,OAAO,mBAAmB,CAC5B;AACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as KnownErrors } from "../known-errors-
|
|
1
|
+
import { a as KnownErrors } from "../known-errors-Bm4a61wL.js";
|
|
2
2
|
//#region src/helpers/password.d.ts
|
|
3
3
|
declare function getPasswordError(password: string): KnownErrors["PasswordRequirementsNotMet"] | undefined;
|
|
4
4
|
//#endregion
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as KnownErrors, n as KnownError } from "./known-errors-
|
|
2
|
-
import { n as HexclaveClientInterface } from "./client-interface-
|
|
3
|
-
import { t as HexclaveServerInterface } from "./server-interface-
|
|
4
|
-
import { r as HexclaveAdminInterface } from "./admin-interface-
|
|
1
|
+
import { a as KnownErrors, n as KnownError } from "./known-errors-Bm4a61wL.js";
|
|
2
|
+
import { n as HexclaveClientInterface } from "./client-interface-BQz4jNAC.js";
|
|
3
|
+
import { t as HexclaveServerInterface } from "./server-interface-BjY-eS4Q.js";
|
|
4
|
+
import { r as HexclaveAdminInterface } from "./admin-interface-DQcggLpw.js";
|
|
5
5
|
export { HexclaveAdminInterface, HexclaveClientInterface, HexclaveServerInterface, KnownError, KnownErrors };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { n as PlanUsageResponse } from "../plan-usage-
|
|
2
|
-
import { a as InternalApiKeyCreateCrudResponse, i as InternalApiKeyCreateCrudRequest, n as ChatContent, r as HexclaveAdminInterface, t as AdminAuthApplicationOptions } from "../admin-interface-
|
|
1
|
+
import { n as PlanUsageResponse } from "../plan-usage-ChUZqQWw.js";
|
|
2
|
+
import { a as InternalApiKeyCreateCrudResponse, i as InternalApiKeyCreateCrudRequest, n as ChatContent, r as HexclaveAdminInterface, t as AdminAuthApplicationOptions } from "../admin-interface-DQcggLpw.js";
|
|
3
3
|
export { AdminAuthApplicationOptions, ChatContent, HexclaveAdminInterface, InternalApiKeyCreateCrudRequest, InternalApiKeyCreateCrudResponse, type PlanUsageResponse };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { A as MetricsNamedCount, B as MetricsTopCountry, C as MetricsDataPoint, D as MetricsEmailOverviewSchema, E as MetricsEmailOverview, F as MetricsRecentEmailSchema, G as MetricsTopRegionSchema, H as MetricsTopReferrer, I as MetricsRecentUser, J as UserActivityResponse, K as MetricsUserCounts, L as MetricsRecentUserSchema, M as MetricsPaymentsOverview, N as MetricsPaymentsOverviewSchema, O as MetricsLoginMethodEntry, P as MetricsRecentEmail, R as MetricsResponse, S as MetricsDailyRevenuePointSchema, T as MetricsDataPointsSchema, U as MetricsTopReferrerSchema, V as MetricsTopCountrySchema, W as MetricsTopRegion, Y as UserActivityResponseBodySchema, _ as MetricsAuthOverview, a as AnalyticsClickmapKind, b as MetricsDailyEmailStatusBreakdownSchema, c as AnalyticsClickmapResponse, d as AnalyticsClickmapTokenResponseBodySchema, f as MetricsActiveUsersByCountrySchema, g as MetricsAnalyticsOverviewSchema, h as MetricsAnalyticsOverview, i as AnalyticsClickmapDeviceSchema, j as MetricsNamedCountSchema, k as MetricsLoginMethodEntrySchema, l as AnalyticsClickmapResponseBodySchema, m as MetricsActivitySplitSchema, n as AnalyticsClickmapCellSchema, o as AnalyticsClickmapKindSchema, p as MetricsActivitySplit, q as MetricsUserCountsSchema, r as AnalyticsClickmapDevice, s as AnalyticsClickmapOptions, t as AnalyticsClickmapCell, u as AnalyticsClickmapTokenResponse, v as MetricsAuthOverviewSchema, w as MetricsDataPointSchema, x as MetricsDailyRevenuePoint, y as MetricsDailyEmailStatusBreakdown, z as MetricsResponseBodySchema } from "../admin-metrics-
|
|
1
|
+
import { A as MetricsNamedCount, B as MetricsTopCountry, C as MetricsDataPoint, D as MetricsEmailOverviewSchema, E as MetricsEmailOverview, F as MetricsRecentEmailSchema, G as MetricsTopRegionSchema, H as MetricsTopReferrer, I as MetricsRecentUser, J as UserActivityResponse, K as MetricsUserCounts, L as MetricsRecentUserSchema, M as MetricsPaymentsOverview, N as MetricsPaymentsOverviewSchema, O as MetricsLoginMethodEntry, P as MetricsRecentEmail, R as MetricsResponse, S as MetricsDailyRevenuePointSchema, T as MetricsDataPointsSchema, U as MetricsTopReferrerSchema, V as MetricsTopCountrySchema, W as MetricsTopRegion, Y as UserActivityResponseBodySchema, _ as MetricsAuthOverview, a as AnalyticsClickmapKind, b as MetricsDailyEmailStatusBreakdownSchema, c as AnalyticsClickmapResponse, d as AnalyticsClickmapTokenResponseBodySchema, f as MetricsActiveUsersByCountrySchema, g as MetricsAnalyticsOverviewSchema, h as MetricsAnalyticsOverview, i as AnalyticsClickmapDeviceSchema, j as MetricsNamedCountSchema, k as MetricsLoginMethodEntrySchema, l as AnalyticsClickmapResponseBodySchema, m as MetricsActivitySplitSchema, n as AnalyticsClickmapCellSchema, o as AnalyticsClickmapKindSchema, p as MetricsActivitySplit, q as MetricsUserCountsSchema, r as AnalyticsClickmapDevice, s as AnalyticsClickmapOptions, t as AnalyticsClickmapCell, u as AnalyticsClickmapTokenResponse, v as MetricsAuthOverviewSchema, w as MetricsDataPointSchema, x as MetricsDailyRevenuePoint, y as MetricsDailyEmailStatusBreakdown, z as MetricsResponseBodySchema } from "../admin-metrics-bsOkw4YQ.js";
|
|
2
2
|
export { AnalyticsClickmapCell, AnalyticsClickmapCellSchema, AnalyticsClickmapDevice, AnalyticsClickmapDeviceSchema, AnalyticsClickmapKind, AnalyticsClickmapKindSchema, AnalyticsClickmapOptions, AnalyticsClickmapResponse, AnalyticsClickmapResponseBodySchema, AnalyticsClickmapTokenResponse, AnalyticsClickmapTokenResponseBodySchema, MetricsActiveUsersByCountrySchema, MetricsActivitySplit, MetricsActivitySplitSchema, MetricsAnalyticsOverview, MetricsAnalyticsOverviewSchema, MetricsAuthOverview, MetricsAuthOverviewSchema, MetricsDailyEmailStatusBreakdown, MetricsDailyEmailStatusBreakdownSchema, MetricsDailyRevenuePoint, MetricsDailyRevenuePointSchema, MetricsDataPoint, MetricsDataPointSchema, MetricsDataPointsSchema, MetricsEmailOverview, MetricsEmailOverviewSchema, MetricsLoginMethodEntry, MetricsLoginMethodEntrySchema, MetricsNamedCount, MetricsNamedCountSchema, MetricsPaymentsOverview, MetricsPaymentsOverviewSchema, MetricsRecentEmail, MetricsRecentEmailSchema, MetricsRecentUser, MetricsRecentUserSchema, MetricsResponse, MetricsResponseBodySchema, MetricsTopCountry, MetricsTopCountrySchema, MetricsTopReferrer, MetricsTopReferrerSchema, MetricsTopRegion, MetricsTopRegionSchema, MetricsUserCounts, MetricsUserCountsSchema, UserActivityResponse, UserActivityResponseBodySchema };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as RequestLogEntry, n as HexclaveClientInterface, r as RequestListener, t as ClientInterfaceOptions } from "../client-interface-
|
|
1
|
+
import { i as RequestLogEntry, n as HexclaveClientInterface, r as RequestListener, t as ClientInterfaceOptions } from "../client-interface-BQz4jNAC.js";
|
|
2
2
|
export { ClientInterfaceOptions, HexclaveClientInterface, RequestListener, RequestLogEntry };
|
|
@@ -49,16 +49,16 @@ declare const conversationSummarySchema: yup$1.ObjectSchema<{
|
|
|
49
49
|
userPrimaryEmail: string | null;
|
|
50
50
|
userProfileImageUrl: string | null;
|
|
51
51
|
subject: string;
|
|
52
|
-
status: "
|
|
52
|
+
status: "open" | "pending" | "closed";
|
|
53
53
|
priority: "low" | "normal" | "high" | "urgent";
|
|
54
54
|
source: "email" | "manual" | "chat" | "api";
|
|
55
55
|
lastMessageType: "message" | "internal-note" | "status-change";
|
|
56
56
|
preview: string | null;
|
|
57
57
|
lastActivityAt: string;
|
|
58
58
|
metadata: {
|
|
59
|
-
tags: string[];
|
|
60
59
|
assignedToUserId: string | null;
|
|
61
60
|
assignedToDisplayName: string | null;
|
|
61
|
+
tags: string[];
|
|
62
62
|
firstResponseDueAt: string | null;
|
|
63
63
|
firstResponseAt: string | null;
|
|
64
64
|
nextResponseDueAt: string | null;
|
|
@@ -129,7 +129,7 @@ declare const conversationMessageSchema: yup$1.ObjectSchema<{
|
|
|
129
129
|
userId: string | null;
|
|
130
130
|
teamId: string | null;
|
|
131
131
|
subject: string;
|
|
132
|
-
status: "
|
|
132
|
+
status: "open" | "pending" | "closed";
|
|
133
133
|
priority: "low" | "normal" | "high" | "urgent";
|
|
134
134
|
source: "email" | "manual" | "chat" | "api";
|
|
135
135
|
messageType: "message" | "internal-note" | "status-change";
|
|
@@ -139,8 +139,8 @@ declare const conversationMessageSchema: yup$1.ObjectSchema<{
|
|
|
139
139
|
createdAt: string;
|
|
140
140
|
sender: {
|
|
141
141
|
type: "user" | "agent" | "system";
|
|
142
|
-
id: string | null;
|
|
143
142
|
displayName: string | null;
|
|
143
|
+
id: string | null;
|
|
144
144
|
primaryEmail: string | null;
|
|
145
145
|
};
|
|
146
146
|
}, yup$1.AnyObject, {
|
|
@@ -173,29 +173,29 @@ declare const conversationListResponseSchema: yup$1.ObjectSchema<{
|
|
|
173
173
|
lastOutboundAt?: string | null | undefined;
|
|
174
174
|
closedAt?: string | null | undefined;
|
|
175
175
|
recordMetadata?: {} | null | undefined;
|
|
176
|
-
|
|
177
|
-
metadata: {
|
|
178
|
-
tags: string[];
|
|
179
|
-
assignedToUserId: string | null;
|
|
180
|
-
assignedToDisplayName: string | null;
|
|
181
|
-
firstResponseDueAt: string | null;
|
|
182
|
-
firstResponseAt: string | null;
|
|
183
|
-
nextResponseDueAt: string | null;
|
|
184
|
-
lastCustomerReplyAt: string | null;
|
|
185
|
-
lastAgentReplyAt: string | null;
|
|
186
|
-
};
|
|
187
|
-
status: "pending" | "open" | "closed";
|
|
188
|
-
subject: string;
|
|
176
|
+
status: "open" | "pending" | "closed";
|
|
189
177
|
priority: "low" | "normal" | "high" | "urgent";
|
|
178
|
+
subject: string;
|
|
190
179
|
conversationId: string;
|
|
191
180
|
userId: string | null;
|
|
192
181
|
teamId: string | null;
|
|
193
182
|
userDisplayName: string | null;
|
|
194
183
|
userPrimaryEmail: string | null;
|
|
195
184
|
userProfileImageUrl: string | null;
|
|
185
|
+
source: "email" | "manual" | "chat" | "api";
|
|
196
186
|
lastMessageType: "message" | "internal-note" | "status-change";
|
|
197
187
|
preview: string | null;
|
|
198
188
|
lastActivityAt: string;
|
|
189
|
+
metadata: {
|
|
190
|
+
assignedToUserId: string | null;
|
|
191
|
+
assignedToDisplayName: string | null;
|
|
192
|
+
tags: string[];
|
|
193
|
+
firstResponseDueAt: string | null;
|
|
194
|
+
firstResponseAt: string | null;
|
|
195
|
+
nextResponseDueAt: string | null;
|
|
196
|
+
lastCustomerReplyAt: string | null;
|
|
197
|
+
lastAgentReplyAt: string | null;
|
|
198
|
+
};
|
|
199
199
|
}[];
|
|
200
200
|
hasMore: boolean;
|
|
201
201
|
}, yup$1.AnyObject, {
|
|
@@ -211,54 +211,54 @@ declare const conversationDetailResponseSchema: yup$1.ObjectSchema<{
|
|
|
211
211
|
lastOutboundAt?: string | null | undefined;
|
|
212
212
|
closedAt?: string | null | undefined;
|
|
213
213
|
recordMetadata?: {} | null | undefined;
|
|
214
|
-
|
|
215
|
-
metadata: {
|
|
216
|
-
tags: string[];
|
|
217
|
-
assignedToUserId: string | null;
|
|
218
|
-
assignedToDisplayName: string | null;
|
|
219
|
-
firstResponseDueAt: string | null;
|
|
220
|
-
firstResponseAt: string | null;
|
|
221
|
-
nextResponseDueAt: string | null;
|
|
222
|
-
lastCustomerReplyAt: string | null;
|
|
223
|
-
lastAgentReplyAt: string | null;
|
|
224
|
-
};
|
|
225
|
-
status: "pending" | "open" | "closed";
|
|
226
|
-
subject: string;
|
|
214
|
+
status: "open" | "pending" | "closed";
|
|
227
215
|
priority: "low" | "normal" | "high" | "urgent";
|
|
216
|
+
subject: string;
|
|
228
217
|
conversationId: string;
|
|
229
218
|
userId: string | null;
|
|
230
219
|
teamId: string | null;
|
|
231
220
|
userDisplayName: string | null;
|
|
232
221
|
userPrimaryEmail: string | null;
|
|
233
222
|
userProfileImageUrl: string | null;
|
|
223
|
+
source: "email" | "manual" | "chat" | "api";
|
|
234
224
|
lastMessageType: "message" | "internal-note" | "status-change";
|
|
235
225
|
preview: string | null;
|
|
236
226
|
lastActivityAt: string;
|
|
227
|
+
metadata: {
|
|
228
|
+
assignedToUserId: string | null;
|
|
229
|
+
assignedToDisplayName: string | null;
|
|
230
|
+
tags: string[];
|
|
231
|
+
firstResponseDueAt: string | null;
|
|
232
|
+
firstResponseAt: string | null;
|
|
233
|
+
nextResponseDueAt: string | null;
|
|
234
|
+
lastCustomerReplyAt: string | null;
|
|
235
|
+
lastAgentReplyAt: string | null;
|
|
236
|
+
};
|
|
237
237
|
};
|
|
238
238
|
messages: {
|
|
239
|
-
|
|
240
|
-
source: "email" | "manual" | "chat" | "api";
|
|
241
|
-
metadata: {} | null;
|
|
239
|
+
status: "open" | "pending" | "closed";
|
|
242
240
|
id: string;
|
|
243
|
-
status: "pending" | "open" | "closed";
|
|
244
|
-
subject: string;
|
|
245
241
|
priority: "low" | "normal" | "high" | "urgent";
|
|
242
|
+
subject: string;
|
|
246
243
|
conversationId: string;
|
|
247
244
|
userId: string | null;
|
|
248
245
|
teamId: string | null;
|
|
246
|
+
source: "email" | "manual" | "chat" | "api";
|
|
247
|
+
metadata: {} | null;
|
|
249
248
|
createdAt: string;
|
|
250
249
|
messageType: "message" | "internal-note" | "status-change";
|
|
250
|
+
body: string | null;
|
|
251
251
|
attachments: {}[];
|
|
252
252
|
sender: {
|
|
253
253
|
type: "user" | "agent" | "system";
|
|
254
|
-
id: string | null;
|
|
255
254
|
displayName: string | null;
|
|
255
|
+
id: string | null;
|
|
256
256
|
primaryEmail: string | null;
|
|
257
257
|
};
|
|
258
258
|
}[];
|
|
259
259
|
entryPoints: {
|
|
260
|
-
metadata: {} | null;
|
|
261
260
|
id: string;
|
|
261
|
+
metadata: {} | null;
|
|
262
262
|
createdAt: string;
|
|
263
263
|
updatedAt: string;
|
|
264
264
|
channelType: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as currentUserCrud, t as CurrentUserCrud } from "../../current-user-
|
|
1
|
+
import { n as currentUserCrud, t as CurrentUserCrud } from "../../current-user-BBoN3hsn.js";
|
|
2
2
|
export { CurrentUserCrud, currentUserCrud };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as emailOutboxUpdateSchema, n as emailOutboxCrud, r as emailOutboxReadSchema, t as EmailOutboxCrud } from "../../email-outbox-
|
|
1
|
+
import { i as emailOutboxUpdateSchema, n as emailOutboxCrud, r as emailOutboxReadSchema, t as EmailOutboxCrud } from "../../email-outbox-CYmVerum.js";
|
|
2
2
|
export { EmailOutboxCrud, emailOutboxCrud, emailOutboxReadSchema, emailOutboxUpdateSchema };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as customerInvoicesListResponseSchema, i as customerInvoiceReadSchema, n as CustomerInvoicesListResponse, r as ListCustomerInvoicesOptions, t as CustomerInvoiceRead } from "../../invoices-
|
|
1
|
+
import { a as customerInvoicesListResponseSchema, i as customerInvoiceReadSchema, n as CustomerInvoicesListResponse, r as ListCustomerInvoicesOptions, t as CustomerInvoiceRead } from "../../invoices-CHo9YKbI.js";
|
|
2
2
|
export { CustomerInvoiceRead, CustomerInvoicesListResponse, ListCustomerInvoicesOptions, customerInvoiceReadSchema, customerInvoicesListResponseSchema };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as customerProductsListResponseSchema, i as customerProductReadSchema, n as CustomerProductsListResponse, r as ListCustomerProductsOptions, t as CustomerProductRead } from "../../products-
|
|
1
|
+
import { a as customerProductsListResponseSchema, i as customerProductReadSchema, n as CustomerProductsListResponse, r as ListCustomerProductsOptions, t as CustomerProductRead } from "../../products-D4o8A2W0.js";
|
|
2
2
|
export { CustomerProductRead, CustomerProductsListResponse, ListCustomerProductsOptions, customerProductReadSchema, customerProductsListResponseSchema };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as teamApiKeysCrud, c as userApiKeysCrud, i as teamApiKeysCreateOutputSchema, n as UserApiKeysCrud, o as userApiKeysCreateInputSchema, r as teamApiKeysCreateInputSchema, s as userApiKeysCreateOutputSchema, t as TeamApiKeysCrud } from "../../project-api-keys
|
|
1
|
+
import { a as teamApiKeysCrud, c as userApiKeysCrud, i as teamApiKeysCreateOutputSchema, n as UserApiKeysCrud, o as userApiKeysCreateInputSchema, r as teamApiKeysCreateInputSchema, s as userApiKeysCreateOutputSchema, t as TeamApiKeysCrud } from "../../project-api-keys--7V5X_UW.js";
|
|
2
2
|
export { TeamApiKeysCrud, UserApiKeysCrud, teamApiKeysCreateInputSchema, teamApiKeysCreateOutputSchema, teamApiKeysCrud, userApiKeysCreateInputSchema, userApiKeysCreateOutputSchema, userApiKeysCrud };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as clientProjectsCrud, c as projectsCrud, d as projectsCrudAdminReadSchema, f as projectsCrudAdminUpdateSchema, i as adminUserProjectsCrud, l as projectsCrudAdminCreateSchema, n as ClientProjectsCrud, o as emailConfigSchema, p as projectsCrudClientReadSchema, r as ProjectsCrud, s as emailConfigWithoutPasswordSchema, t as AdminUserProjectsCrud, u as projectsCrudAdminDeleteSchema } from "../../projects-
|
|
1
|
+
import { a as clientProjectsCrud, c as projectsCrud, d as projectsCrudAdminReadSchema, f as projectsCrudAdminUpdateSchema, i as adminUserProjectsCrud, l as projectsCrudAdminCreateSchema, n as ClientProjectsCrud, o as emailConfigSchema, p as projectsCrudClientReadSchema, r as ProjectsCrud, s as emailConfigWithoutPasswordSchema, t as AdminUserProjectsCrud, u as projectsCrudAdminDeleteSchema } from "../../projects-CFTNXRfG.js";
|
|
2
2
|
export { AdminUserProjectsCrud, ClientProjectsCrud, ProjectsCrud, adminUserProjectsCrud, clientProjectsCrud, emailConfigSchema, emailConfigWithoutPasswordSchema, projectsCrud, projectsCrudAdminCreateSchema, projectsCrudAdminDeleteSchema, projectsCrudAdminReadSchema, projectsCrudAdminUpdateSchema, projectsCrudClientReadSchema };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as teamMemberProfilesCrudServerReadSchema, i as teamMemberProfilesCrudClientUpdateSchema, n as teamMemberProfilesCrud, r as teamMemberProfilesCrudClientReadSchema, t as TeamMemberProfilesCrud } from "../../team-member-profiles-
|
|
1
|
+
import { a as teamMemberProfilesCrudServerReadSchema, i as teamMemberProfilesCrudClientUpdateSchema, n as teamMemberProfilesCrud, r as teamMemberProfilesCrudClientReadSchema, t as TeamMemberProfilesCrud } from "../../team-member-profiles-BoDEqx-0.js";
|
|
2
2
|
export { TeamMemberProfilesCrud, teamMemberProfilesCrud, teamMemberProfilesCrudClientReadSchema, teamMemberProfilesCrudClientUpdateSchema, teamMemberProfilesCrudServerReadSchema };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as transactionEntrySchema, i as TransactionType, n as Transaction, o as transactionSchema, r as TransactionEntry, t as TRANSACTION_TYPES } from "../../transactions-
|
|
1
|
+
import { a as transactionEntrySchema, i as TransactionType, n as Transaction, o as transactionSchema, r as TransactionEntry, t as TRANSACTION_TYPES } from "../../transactions-CHNUJ42J.js";
|
|
2
2
|
export { TRANSACTION_TYPES, Transaction, TransactionEntry, TransactionType, transactionEntrySchema, transactionSchema };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as userCreatedWebhookEvent, c as usersCrud, d as usersCrudServerReadSchema, f as usersCrudServerUpdateSchema, i as signUpRiskScoresSchema, l as usersCrudServerCreateSchema, n as UsersCrud, o as userDeletedWebhookEvent, r as riskScoreFieldSchema, s as userUpdatedWebhookEvent, t as SignUpRiskScoresCrud, u as usersCrudServerDeleteSchema } from "../../users-
|
|
1
|
+
import { a as userCreatedWebhookEvent, c as usersCrud, d as usersCrudServerReadSchema, f as usersCrudServerUpdateSchema, i as signUpRiskScoresSchema, l as usersCrudServerCreateSchema, n as UsersCrud, o as userDeletedWebhookEvent, r as riskScoreFieldSchema, s as userUpdatedWebhookEvent, t as SignUpRiskScoresCrud, u as usersCrudServerDeleteSchema } from "../../users-DHNRwoSz.js";
|
|
2
2
|
export { SignUpRiskScoresCrud, UsersCrud, riskScoreFieldSchema, signUpRiskScoresSchema, userCreatedWebhookEvent, userDeletedWebhookEvent, userUpdatedWebhookEvent, usersCrud, usersCrudServerCreateSchema, usersCrudServerDeleteSchema, usersCrudServerReadSchema, usersCrudServerUpdateSchema };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as planUsageResponseSchema, i as planUsageKindSchema, n as PlanUsageResponse, o as planUsageRowSchema, r as PlanUsageRow, t as PlanUsageKind } from "../plan-usage-
|
|
1
|
+
import { a as planUsageResponseSchema, i as planUsageKindSchema, n as PlanUsageResponse, o as planUsageRowSchema, r as PlanUsageRow, t as PlanUsageKind } from "../plan-usage-ChUZqQWw.js";
|
|
2
2
|
export { PlanUsageKind, PlanUsageResponse, PlanUsageRow, planUsageKindSchema, planUsageResponseSchema, planUsageRowSchema };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as ServerAuthApplicationOptions, t as HexclaveServerInterface } from "../server-interface-
|
|
1
|
+
import { n as ServerAuthApplicationOptions, t as HexclaveServerInterface } from "../server-interface-BjY-eS4Q.js";
|
|
2
2
|
export { HexclaveServerInterface, ServerAuthApplicationOptions };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as webhookEvents, t as WebhookEvent } from "../webhooks-
|
|
1
|
+
import { n as webhookEvents, t as WebhookEvent } from "../webhooks-8Ts1Clcb.js";
|
|
2
2
|
export { WebhookEvent, webhookEvents };
|
|
@@ -3,7 +3,7 @@ import * as yup$1 from "yup";
|
|
|
3
3
|
//#region src/interface/crud/invoices.d.ts
|
|
4
4
|
declare const customerInvoiceReadSchema: yup$1.ObjectSchema<{
|
|
5
5
|
created_at_millis: number;
|
|
6
|
-
status: "
|
|
6
|
+
status: "open" | "draft" | "paid" | "uncollectible" | "void" | null;
|
|
7
7
|
amount_total: number;
|
|
8
8
|
hosted_invoice_url: string | null;
|
|
9
9
|
}, yup$1.AnyObject, {
|
|
@@ -15,8 +15,8 @@ declare const customerInvoiceReadSchema: yup$1.ObjectSchema<{
|
|
|
15
15
|
type CustomerInvoiceRead = yup$1.InferType<typeof customerInvoiceReadSchema>;
|
|
16
16
|
declare const customerInvoicesListResponseSchema: yup$1.ObjectSchema<{
|
|
17
17
|
items: {
|
|
18
|
+
status: "open" | "draft" | "paid" | "uncollectible" | "void" | null;
|
|
18
19
|
created_at_millis: number;
|
|
19
|
-
status: "draft" | "open" | "paid" | "uncollectible" | "void" | null;
|
|
20
20
|
amount_total: number;
|
|
21
21
|
hosted_invoice_url: string | null;
|
|
22
22
|
}[];
|
|
@@ -40,4 +40,4 @@ type ListCustomerInvoicesOptions = {
|
|
|
40
40
|
};
|
|
41
41
|
//#endregion
|
|
42
42
|
export { customerInvoicesListResponseSchema as a, customerInvoiceReadSchema as i, CustomerInvoicesListResponse as n, ListCustomerInvoicesOptions as r, CustomerInvoiceRead as t };
|
|
43
|
-
//# sourceMappingURL=invoices-
|
|
43
|
+
//# sourceMappingURL=invoices-CHo9YKbI.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"invoices-
|
|
1
|
+
{"version":3,"file":"invoices-CHo9YKbI.d.ts","names":[],"sources":["../src/interface/crud/invoices.ts"],"mappings":";;;cAWa,yBAAA,EAAyB,KAAA,CAAA,YAAA;;;;;GAK1B,KAAA,CAAA,SAAA;;;;;;KAEA,mBAAA,GAAsB,KAAA,CAAI,SAAS,QAAQ,yBAAA;AAAA,cAE1C,kCAAA,EAAkC,KAAA,CAAA,YAAA;;;;;;;;;;;GAMnC,KAAA,CAAA,SAAA;;;;;;;KAEA,4BAAA,GAA+B,KAAA,CAAI,SAAS,QAAQ,kCAAA;AAAA,KAEpD,2BAAA;EACV,aAAA;EACA,WAAA;EACA,MAAA;EACA,KAAA;AAAA"}
|
|
@@ -512,7 +512,7 @@ declare const KnownErrors: {
|
|
|
512
512
|
ItemNotFound: KnownErrorConstructor<KnownError & KnownErrorBrand<"ITEM_NOT_FOUND">, [itemId: string]> & {
|
|
513
513
|
errorCode: "ITEM_NOT_FOUND";
|
|
514
514
|
};
|
|
515
|
-
ItemCustomerTypeDoesNotMatch: KnownErrorConstructor<KnownError & KnownErrorBrand<"ITEM_CUSTOMER_TYPE_DOES_NOT_MATCH">, [itemId: string, customerId: string, itemCustomerType: "
|
|
515
|
+
ItemCustomerTypeDoesNotMatch: KnownErrorConstructor<KnownError & KnownErrorBrand<"ITEM_CUSTOMER_TYPE_DOES_NOT_MATCH">, [itemId: string, customerId: string, itemCustomerType: "team" | "user" | "custom" | undefined, actualCustomerType: "team" | "user" | "custom"]> & {
|
|
516
516
|
errorCode: "ITEM_CUSTOMER_TYPE_DOES_NOT_MATCH";
|
|
517
517
|
};
|
|
518
518
|
CustomerDoesNotExist: KnownErrorConstructor<KnownError & KnownErrorBrand<"CUSTOMER_DOES_NOT_EXIST">, [customerId: string]> & {
|
|
@@ -521,7 +521,7 @@ declare const KnownErrors: {
|
|
|
521
521
|
ProductDoesNotExist: KnownErrorConstructor<KnownError & KnownErrorBrand<"PRODUCT_DOES_NOT_EXIST">, [productId: string, context: "item_exists" | "server_only" | null]> & {
|
|
522
522
|
errorCode: "PRODUCT_DOES_NOT_EXIST";
|
|
523
523
|
};
|
|
524
|
-
ProductCustomerTypeDoesNotMatch: KnownErrorConstructor<KnownError & KnownErrorBrand<"PRODUCT_CUSTOMER_TYPE_DOES_NOT_MATCH">, [productId: string | undefined, customerId: string, productCustomerType: "
|
|
524
|
+
ProductCustomerTypeDoesNotMatch: KnownErrorConstructor<KnownError & KnownErrorBrand<"PRODUCT_CUSTOMER_TYPE_DOES_NOT_MATCH">, [productId: string | undefined, customerId: string, productCustomerType: "team" | "user" | "custom" | undefined, actualCustomerType: "team" | "user" | "custom"]> & {
|
|
525
525
|
errorCode: "PRODUCT_CUSTOMER_TYPE_DOES_NOT_MATCH";
|
|
526
526
|
};
|
|
527
527
|
ProductAlreadyGranted: KnownErrorConstructor<KnownError & KnownErrorBrand<"PRODUCT_ALREADY_GRANTED">, [productId: string, customerId: string]> & {
|
|
@@ -548,7 +548,7 @@ declare const KnownErrors: {
|
|
|
548
548
|
StripeAccountInfoNotFound: KnownErrorConstructor<KnownError & KnownErrorBrand<"STRIPE_ACCOUNT_INFO_NOT_FOUND">, []> & {
|
|
549
549
|
errorCode: "STRIPE_ACCOUNT_INFO_NOT_FOUND";
|
|
550
550
|
};
|
|
551
|
-
DefaultPaymentMethodRequired: KnownErrorConstructor<KnownError & KnownErrorBrand<"DEFAULT_PAYMENT_METHOD_REQUIRED">, [customerType: "
|
|
551
|
+
DefaultPaymentMethodRequired: KnownErrorConstructor<KnownError & KnownErrorBrand<"DEFAULT_PAYMENT_METHOD_REQUIRED">, [customerType: "team" | "user", customerId: string]> & {
|
|
552
552
|
errorCode: "DEFAULT_PAYMENT_METHOD_REQUIRED";
|
|
553
553
|
};
|
|
554
554
|
NewPurchasesBlocked: KnownErrorConstructor<KnownError & KnownErrorBrand<"NEW_PURCHASES_BLOCKED">, []> & {
|
|
@@ -572,4 +572,4 @@ declare const KnownErrors: {
|
|
|
572
572
|
};
|
|
573
573
|
//#endregion
|
|
574
574
|
export { KnownErrors as a, KnownErrorJson as i, KnownError as n, KnownErrorConstructor as r, AbstractKnownErrorConstructor as t };
|
|
575
|
-
//# sourceMappingURL=known-errors-
|
|
575
|
+
//# sourceMappingURL=known-errors-Bm4a61wL.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"known-errors-
|
|
1
|
+
{"version":3,"file":"known-errors-Bm4a61wL.d.ts","names":[],"sources":["../src/known-errors.tsx"],"mappings":";;;;KAKY,cAAA;EACV,IAAA;EACA,OAAA;EACA,OAAA,GAAU,IAAI;AAAA;AAAA,KAGJ,6BAAA,yCACU,IAAA,EAAM,IAAA,KAAS,UAAA;EAEjC,uBAAA,GAA0B,IAAA,EAAM,cAAA,KAAmB,IAAA;AAAA;AAAA,KAG3C,qBAAA,uBAA4C,UAAA;EAAA,QAC/C,IAAA,EAAM,IAAA,GAAO,aAAA;IAAkB,eAAA,EAAiB,IAAA;EAAA;EACvD,SAAA;EACA,uBAAA,GAA0B,IAAA,EAAM,cAAA,KAAmB,IAAA;EACnD,UAAA,GAAa,KAAA,cAAmB,KAAA,IAAS,aAAA;IAAkB,eAAA,EAAiB,IAAA;EAAA;AAAA;AAAA,uBAGxD,UAAA,SAAmB,WAAA;EAAA,SAKrB,UAAA;EAAA,SACA,oBAAA;EAAA,SACA,OAAA,GAAU,IAAA;EAAA,iBANX,sBAAA;EACV,IAAA;cAGW,UAAA,UACA,oBAAA,UACA,OAAA,GAAU,IAAA;EAAA,OAQd,YAAA,CAAa,KAAA,YAAiB,KAAA,IAAS,UAAA;EAKrC,OAAA,IAAW,UAAA;EAIX,UAAA,IAAc,MAAA;EASd,iBAAA,IAAqB,IAAA;EAAA,IAQjC,SAAA;EAAA,OAIU,uBAAA,CAAwB,IAAA,EAAM,cAAA,GAAiB,qBAAA,QAA6B,UAAA;EAAA,OAQ5E,QAAA,CAAS,IAAA,EAAM,cAAA,GAAiB,UAAA;AAAA;AAAA,cAe1C,sCAAA;;;;KAID,eAAA;EA5E6B;;;;;EAAA,CAkF/B,sCAAsC,WAC/B,SAAA;AAAA;AAAA,KA2uDE,WAAA,wBACS,WAAA,GAAc,YAAA,QAAoB,WAAA,CAAY,CAAA;AAAA,cAGtD,WAAA"}
|
package/dist/known-errors.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as KnownErrors, i as KnownErrorJson, n as KnownError, r as KnownErrorConstructor, t as AbstractKnownErrorConstructor } from "./known-errors-
|
|
1
|
+
import { a as KnownErrors, i as KnownErrorJson, n as KnownError, r as KnownErrorConstructor, t as AbstractKnownErrorConstructor } from "./known-errors-Bm4a61wL.js";
|
|
2
2
|
export { AbstractKnownErrorConstructor, KnownError, KnownErrorConstructor, KnownErrorJson, KnownErrors };
|
|
@@ -30,8 +30,8 @@ declare const planUsageResponseSchema: yup$1.ObjectSchema<{
|
|
|
30
30
|
period_end_millis: number;
|
|
31
31
|
next_plan_id: "team" | "growth" | null;
|
|
32
32
|
rows: {
|
|
33
|
-
display_name: string;
|
|
34
33
|
item_id: "dashboard_admins" | "auth_users" | "emails_per_month" | "analytics_timeout_seconds" | "analytics_events" | "session_replays" | "onboarding_call";
|
|
34
|
+
display_name: string;
|
|
35
35
|
kind: "current" | "metered" | "capability";
|
|
36
36
|
used: number | null;
|
|
37
37
|
limit: number | null;
|
|
@@ -54,4 +54,4 @@ type PlanUsageRow = yup$1.InferType<typeof planUsageRowSchema>;
|
|
|
54
54
|
type PlanUsageResponse = yup$1.InferType<typeof planUsageResponseSchema>;
|
|
55
55
|
//#endregion
|
|
56
56
|
export { planUsageResponseSchema as a, planUsageKindSchema as i, PlanUsageResponse as n, planUsageRowSchema as o, PlanUsageRow as r, PlanUsageKind as t };
|
|
57
|
-
//# sourceMappingURL=plan-usage-
|
|
57
|
+
//# sourceMappingURL=plan-usage-ChUZqQWw.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plan-usage-
|
|
1
|
+
{"version":3,"file":"plan-usage-ChUZqQWw.d.ts","names":[],"sources":["../src/interface/plan-usage.ts"],"mappings":";;;cAOa,mBAAA,EAAmB,KAAA,CAAA,YAAA,uCAAA,KAAA,CAAA,SAAA;AAAA,cAEnB,kBAAA,EAAkB,KAAA,CAAA,YAAA;;;;;;;;;GASnB,KAAA,CAAA,SAAA;;;;;;;;;;cAEC,uBAAA,EAAuB,KAAA,CAAA,YAAA;;;;;;;;;;;;;;;;;;GASxB,KAAA,CAAA,SAAA;;;;;;;;;;KAEA,aAAA,GAAgB,KAAA,CAAI,SAAS,QAAQ,mBAAA;AAAA,KACrC,YAAA,GAAe,KAAA,CAAI,SAAS,QAAQ,kBAAA;AAAA,KACpC,iBAAA,GAAoB,KAAA,CAAI,SAAS,QAAQ,uBAAA"}
|