@kevludwig/lexware-office 0.1.1 → 0.1.3
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/contacts.d.ts +7 -1
- package/dist/contacts.js +9 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/reminders.d.ts +9 -1
- package/dist/reminders.js +10 -1
- package/package.json +1 -1
package/dist/contacts.d.ts
CHANGED
|
@@ -19,7 +19,13 @@ export interface Contact {
|
|
|
19
19
|
export declare function getContact(client: LexwareClient, id: string, signal?: AbortSignal): Promise<Contact>;
|
|
20
20
|
/** The contact with this customer number, or null. */
|
|
21
21
|
export declare function findContactByNumber(client: LexwareClient, customerNumber: number, signal?: AbortSignal): Promise<Contact | null>;
|
|
22
|
-
/**
|
|
22
|
+
/** Lexware searches names from three characters on; shorter ones it refuses with a 400. */
|
|
23
|
+
export declare const MIN_NAME_SEARCH_LENGTH = 3;
|
|
24
|
+
/**
|
|
25
|
+
* Contacts whose name matches — fuzzy, up to `size` (default 10). A name
|
|
26
|
+
* shorter than MIN_NAME_SEARCH_LENGTH finds nothing (no request): callers
|
|
27
|
+
* that must not mistake that for "no match" check the length themselves.
|
|
28
|
+
*/
|
|
23
29
|
export declare function findContactsByName(client: LexwareClient, name: string, options?: {
|
|
24
30
|
customer?: boolean;
|
|
25
31
|
vendor?: boolean;
|
package/dist/contacts.js
CHANGED
|
@@ -28,8 +28,16 @@ export async function findContactByNumber(client, customerNumber, signal) {
|
|
|
28
28
|
const raw = page.content?.[0];
|
|
29
29
|
return raw ? toContact(raw) : null;
|
|
30
30
|
}
|
|
31
|
-
/**
|
|
31
|
+
/** Lexware searches names from three characters on; shorter ones it refuses with a 400. */
|
|
32
|
+
export const MIN_NAME_SEARCH_LENGTH = 3;
|
|
33
|
+
/**
|
|
34
|
+
* Contacts whose name matches — fuzzy, up to `size` (default 10). A name
|
|
35
|
+
* shorter than MIN_NAME_SEARCH_LENGTH finds nothing (no request): callers
|
|
36
|
+
* that must not mistake that for "no match" check the length themselves.
|
|
37
|
+
*/
|
|
32
38
|
export async function findContactsByName(client, name, options = {}) {
|
|
39
|
+
if (name.trim().length < MIN_NAME_SEARCH_LENGTH)
|
|
40
|
+
return [];
|
|
33
41
|
const page = await client.request(`/contacts${query({ name, customer: options.customer, vendor: options.vendor, size: options.size ?? 10 })}`, { signal: options.signal });
|
|
34
42
|
return (page.content ?? []).map(toContact);
|
|
35
43
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export { DEFAULT_APP_URL, DEFAULT_BASE_URL, LexwareApiError, createLexwareClient, describeError, query, type FileUpload, type LexwareClient, type LexwareClientOptions, } from "./client.ts";
|
|
2
|
-
export { contactEmail, createCustomer, findContactByNumber, findContactsByName, getContact, resolveContactByName, type Contact, type CreatedCustomer, type NewCustomer, } from "./contacts.ts";
|
|
2
|
+
export { contactEmail, createCustomer, findContactByNumber, findContactsByName, MIN_NAME_SEARCH_LENGTH, getContact, resolveContactByName, type Contact, type CreatedCustomer, type NewCustomer, } from "./contacts.ts";
|
|
3
3
|
export { addDays, berlinDay, daysSince } from "./dates.ts";
|
|
4
4
|
export { downloadInvoicePdf, findOverdueInvoice, findOverdueInvoices, type OverdueInvoice, } from "./receivables.ts";
|
|
5
|
-
export { DEFAULT_REMINDER_POLICY, daysPastReminderDue, earliestReminderDate, isDueImmediately, isOpenForReminder, reminderDueDate, reminderLedger, selectDueReminders, type DueReminder, type ReminderHold, type ReminderLedger, type ReminderPolicy, type ReminderRecord, type ReminderSelection, type ReminderStatus, sendReminder, type ReminderTarget, type SendReminderOutcome, } from "./reminders.ts";
|
|
5
|
+
export { DEFAULT_REMINDER_POLICY, daysPastReminderDue, earliestReminderDate, isDueImmediately, isOpenForReminder, reminderDueDate, reminderLedger, selectDueReminders, type DueReminder, type ReminderHold, type ReminderLedger, type ReminderPolicy, type ReminderRecord, type ReminderSelection, type ReminderStatus, mailContentSha256, sendReminder, type ReminderTarget, type SendReminderOutcome, } from "./reminders.ts";
|
|
6
6
|
export { MailNotSentError, defaultReminderMail, reminderSubject, type ReminderMail, type ReminderMailData, type ReminderSender, type RenderReminderMail, type SendReminderMail, } from "./reminder-mail.ts";
|
|
7
7
|
export { keySegment, memoryStore, type JsonStore } from "./store.ts";
|
|
8
8
|
export { DUPLICATE_TOTAL_TOLERANCE, ITEMS_TOTAL_TOLERANCE, netTotal, round2, taxFromGross, taxFromNet, type PricedLine, } from "./money.ts";
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export { DEFAULT_APP_URL, DEFAULT_BASE_URL, LexwareApiError, createLexwareClient, describeError, query, } from "./client.js";
|
|
2
|
-
export { contactEmail, createCustomer, findContactByNumber, findContactsByName, getContact, resolveContactByName, } from "./contacts.js";
|
|
2
|
+
export { contactEmail, createCustomer, findContactByNumber, findContactsByName, MIN_NAME_SEARCH_LENGTH, getContact, resolveContactByName, } from "./contacts.js";
|
|
3
3
|
export { addDays, berlinDay, daysSince } from "./dates.js";
|
|
4
4
|
export { downloadInvoicePdf, findOverdueInvoice, findOverdueInvoices, } from "./receivables.js";
|
|
5
|
-
export { DEFAULT_REMINDER_POLICY, daysPastReminderDue, earliestReminderDate, isDueImmediately, isOpenForReminder, reminderDueDate, reminderLedger, selectDueReminders, sendReminder, } from "./reminders.js";
|
|
5
|
+
export { DEFAULT_REMINDER_POLICY, daysPastReminderDue, earliestReminderDate, isDueImmediately, isOpenForReminder, reminderDueDate, reminderLedger, selectDueReminders, mailContentSha256, sendReminder, } from "./reminders.js";
|
|
6
6
|
export { MailNotSentError, defaultReminderMail, reminderSubject, } from "./reminder-mail.js";
|
|
7
7
|
export { keySegment, memoryStore } from "./store.js";
|
|
8
8
|
export { DUPLICATE_TOTAL_TOLERANCE, ITEMS_TOTAL_TOLERANCE, netTotal, round2, taxFromGross, taxFromNet, } from "./money.js";
|
package/dist/reminders.d.ts
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import type { LexwareClient } from "./client.ts";
|
|
17
17
|
import { type OverdueInvoice } from "./receivables.ts";
|
|
18
|
-
import { type RenderReminderMail, type SendReminderMail } from "./reminder-mail.ts";
|
|
18
|
+
import { type RenderReminderMail, type ReminderMail, type SendReminderMail } from "./reminder-mail.ts";
|
|
19
19
|
import { type JsonStore } from "./store.ts";
|
|
20
20
|
export interface ReminderPolicy {
|
|
21
21
|
/** Days past the reminder due date before a first reminder. Default: 3. */
|
|
@@ -134,6 +134,8 @@ export type SendReminderOutcome = {
|
|
|
134
134
|
sent: true;
|
|
135
135
|
openAmount: number;
|
|
136
136
|
attachment: string;
|
|
137
|
+
/** sha256 of subject, text and HTML as sent: proves what went out without keeping the mail. */
|
|
138
|
+
contentSha256: string;
|
|
137
139
|
} | {
|
|
138
140
|
sent: false;
|
|
139
141
|
reason: "paid" | "taken";
|
|
@@ -153,4 +155,10 @@ export declare function sendReminder(client: LexwareClient, ledger: ReminderLedg
|
|
|
153
155
|
sessionId?: string;
|
|
154
156
|
signal?: AbortSignal;
|
|
155
157
|
}): Promise<SendReminderOutcome>;
|
|
158
|
+
/**
|
|
159
|
+
* The fingerprint of a mail's content: subject, plain text and HTML, joined
|
|
160
|
+
* with a separator that cannot occur in them. The same mail always gives the
|
|
161
|
+
* same hash; a protocol can keep it instead of the mail.
|
|
162
|
+
*/
|
|
163
|
+
export declare function mailContentSha256(mail: Pick<ReminderMail, "subject" | "html" | "text">): string;
|
|
156
164
|
export {};
|
package/dist/reminders.js
CHANGED
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
import { contactEmail } from "./contacts.js";
|
|
17
17
|
import { addDays, daysSince } from "./dates.js";
|
|
18
18
|
import { downloadInvoicePdf, findOverdueInvoice, findOverdueInvoices } from "./receivables.js";
|
|
19
|
+
import { createHash } from "node:crypto";
|
|
19
20
|
import { MailNotSentError } from "./reminder-mail.js";
|
|
20
21
|
import { keySegment } from "./store.js";
|
|
21
22
|
export const DEFAULT_REMINDER_POLICY = {
|
|
@@ -171,5 +172,13 @@ export async function sendReminder(client, ledger, target, options) {
|
|
|
171
172
|
...(options.sessionId ? { sessionId: options.sessionId } : {}),
|
|
172
173
|
})
|
|
173
174
|
.catch(() => { });
|
|
174
|
-
return { sent: true, openAmount: still.openAmount, attachment: mail.attachments[0].filename };
|
|
175
|
+
return { sent: true, openAmount: still.openAmount, attachment: mail.attachments[0].filename, contentSha256: mailContentSha256(mail) };
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* The fingerprint of a mail's content: subject, plain text and HTML, joined
|
|
179
|
+
* with a separator that cannot occur in them. The same mail always gives the
|
|
180
|
+
* same hash; a protocol can keep it instead of the mail.
|
|
181
|
+
*/
|
|
182
|
+
export function mailContentSha256(mail) {
|
|
183
|
+
return createHash("sha256").update([mail.subject, mail.text ?? "", mail.html].join("\u0000")).digest("hex");
|
|
175
184
|
}
|
package/package.json
CHANGED