@invoiceleaf/integration-sdk 1.2.0 → 1.6.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/README.md CHANGED
@@ -264,6 +264,35 @@ Usage in handler:
264
264
  const apiKey = await context.credentials.getApiKey('openai');
265
265
  ```
266
266
 
267
+ ## Context APIs for Sync Integrations
268
+
269
+ Use these primitives for Gmail/SMTP and accounting sync integrations:
270
+
271
+ ```typescript
272
+ // Durable checkpoints
273
+ await context.state.set('sync:lastSuccessfulAt', new Date().toISOString());
274
+ const checkpoint = await context.state.get<string>('sync:lastSuccessfulAt');
275
+
276
+ // Provider diagnostics (non-secret)
277
+ const connection = await context.credentials.getConnectionInfo('quickbooks');
278
+
279
+ // External ID mappings
280
+ await context.mappings.upsert({
281
+ system: 'quickbooks',
282
+ entity: 'invoice',
283
+ localId: 'doc_123',
284
+ externalId: 'qbo_987',
285
+ });
286
+
287
+ // Document sync metadata
288
+ await context.data.patchDocumentIntegrationMeta({
289
+ documentId: 'doc_123',
290
+ system: 'quickbooks',
291
+ status: 'synced',
292
+ externalId: 'qbo_987',
293
+ });
294
+ ```
295
+
267
296
  ## Custom UI Pages
268
297
 
269
298
  Define custom dashboard pages:
@@ -352,6 +381,8 @@ const syncEnabled = context.config.syncEnabled as boolean;
352
381
  | `config` | `Record<string, unknown>` | User configuration |
353
382
  | `data` | `DataClient` | Data access client |
354
383
  | `credentials` | `CredentialsClient` | Credential client |
384
+ | `state` | `StateClient` | Installation-scoped state client |
385
+ | `email` | `EmailClient` | SMTP/IMAP operations |
355
386
  | `logger` | `Logger` | Structured logger |
356
387
 
357
388
  ### DataClient
@@ -366,6 +397,7 @@ const syncEnabled = context.config.syncEnabled as boolean;
366
397
  | `listTags()` | List all tags |
367
398
  | `createExport(params)` | Create export job |
368
399
  | `getExport(id)` | Get export status |
400
+ | `importDocument(input)` | Import file as document |
369
401
 
370
402
  ### CredentialsClient
371
403
 
@@ -375,6 +407,22 @@ const syncEnabled = context.config.syncEnabled as boolean;
375
407
  | `getApiKey(provider)` | Get API key |
376
408
  | `refreshToken(provider)` | Force token refresh |
377
409
 
410
+ ### StateClient
411
+
412
+ | Method | Description |
413
+ |--------|-------------|
414
+ | `get(key)` | Read installation-scoped state |
415
+ | `set(key, value, opts?)` | Persist installation-scoped state |
416
+ | `delete(key)` | Remove installation-scoped state |
417
+
418
+ ### EmailClient
419
+
420
+ | Method | Description |
421
+ |--------|-------------|
422
+ | `sendSmtpEmail(input)` | Send outbound SMTP email |
423
+ | `testSmtpImapConnection(input)` | Verify SMTP + IMAP connection |
424
+ | `crawlImapPdfAttachments(input)` | Fetch PDF attachments from IMAP |
425
+
378
426
  ### Logger
379
427
 
380
428
  | Method | Description |
@@ -37,6 +37,12 @@ export interface IntegrationContext<TConfig = Record<string, unknown>> {
37
37
  readonly data: DataClient;
38
38
  /** Credential access client */
39
39
  readonly credentials: CredentialsClient;
40
+ /** External system mapping client */
41
+ readonly mappings: MappingsClient;
42
+ /** Installation-scoped state storage client */
43
+ readonly state: StateClient;
44
+ /** Email transport and mailbox operations */
45
+ readonly email: EmailClient;
40
46
  /** Structured logger */
41
47
  readonly logger: Logger;
42
48
  }
@@ -53,6 +59,10 @@ export interface DataClient {
53
59
  * Get a document by ID.
54
60
  */
55
61
  getDocument(id: string): Promise<Document>;
62
+ /**
63
+ * Get original file content for a document.
64
+ */
65
+ getDocumentFile(id: string): Promise<DocumentFileContent>;
56
66
  /**
57
67
  * List companies.
58
68
  */
@@ -85,6 +95,136 @@ export interface DataClient {
85
95
  * Get export status by ID.
86
96
  */
87
97
  getExport(id: string): Promise<Export>;
98
+ /**
99
+ * Import a file as a new document.
100
+ */
101
+ importDocument(input: DocumentImportInput): Promise<DocumentImportResult>;
102
+ /**
103
+ * Patch integration sync metadata for a document.
104
+ */
105
+ patchDocumentIntegrationMeta(input: DocumentIntegrationMetaPatchInput): Promise<void>;
106
+ }
107
+ export interface DocumentImportInput {
108
+ fileName: string;
109
+ contentType: string;
110
+ contentBase64: string;
111
+ source: string;
112
+ description?: string;
113
+ externalRef?: string;
114
+ metadata?: Record<string, unknown>;
115
+ }
116
+ export interface DocumentImportResult {
117
+ documentId: string;
118
+ duplicate: boolean;
119
+ }
120
+ export interface DocumentFileContent {
121
+ documentId: string;
122
+ fileName?: string;
123
+ contentType?: string;
124
+ contentBase64: string;
125
+ sizeBytes?: number;
126
+ }
127
+ export interface DocumentIntegrationMetaPatchInput {
128
+ documentId: string;
129
+ system: string;
130
+ externalId?: string;
131
+ status?: string;
132
+ lastSyncedAt?: string;
133
+ errorSummary?: string;
134
+ metadata?: Record<string, unknown>;
135
+ }
136
+ export interface StateClient {
137
+ /**
138
+ * Read installation-scoped state value by key.
139
+ */
140
+ get<T = unknown>(key: string): Promise<T | null>;
141
+ /**
142
+ * Persist installation-scoped state value.
143
+ */
144
+ set<T = unknown>(key: string, value: T, opts?: {
145
+ ttlSeconds?: number;
146
+ }): Promise<void>;
147
+ /**
148
+ * Delete installation-scoped state value by key.
149
+ */
150
+ delete(key: string): Promise<void>;
151
+ }
152
+ export interface EmailAttachmentInput {
153
+ fileName: string;
154
+ contentType?: string;
155
+ contentBase64: string;
156
+ }
157
+ export interface SendSmtpEmailInput {
158
+ smtpHost: string;
159
+ smtpPort: number;
160
+ smtpSecure?: boolean;
161
+ smtpUsername: string;
162
+ smtpPassword: string;
163
+ fromAddress: string;
164
+ to: string[];
165
+ cc?: string[];
166
+ bcc?: string[];
167
+ replyTo?: string;
168
+ subject: string;
169
+ text?: string;
170
+ html?: string;
171
+ attachments?: EmailAttachmentInput[];
172
+ }
173
+ export interface SendSmtpEmailResult {
174
+ messageId: string;
175
+ accepted?: string[];
176
+ rejected?: string[];
177
+ response?: string;
178
+ }
179
+ export interface SmtpImapConnectionTestInput {
180
+ smtpHost: string;
181
+ smtpPort: number;
182
+ smtpSecure?: boolean;
183
+ smtpUsername: string;
184
+ smtpPassword: string;
185
+ imapHost: string;
186
+ imapPort: number;
187
+ imapSecure?: boolean;
188
+ imapUsername: string;
189
+ imapPassword: string;
190
+ imapFolder?: string;
191
+ }
192
+ export interface SmtpImapConnectionTestResult {
193
+ smtp: boolean;
194
+ imap: boolean;
195
+ }
196
+ export interface ImapPdfAttachment {
197
+ uid: number;
198
+ fileName: string;
199
+ contentType: string;
200
+ contentBase64: string;
201
+ checksum: string;
202
+ subject?: string;
203
+ from?: string;
204
+ date?: string;
205
+ }
206
+ export interface CrawlImapPdfAttachmentsInput {
207
+ imapHost: string;
208
+ imapPort: number;
209
+ imapSecure?: boolean;
210
+ imapUsername: string;
211
+ imapPassword: string;
212
+ imapFolder?: string;
213
+ searchFilter?: string;
214
+ maxMessagesPerRun?: number;
215
+ maxAttachmentsPerMessage?: number;
216
+ markAsSeen?: boolean;
217
+ moveToFolder?: string;
218
+ }
219
+ export interface CrawlImapPdfAttachmentsResult {
220
+ messages: number;
221
+ attachments: number;
222
+ items: ImapPdfAttachment[];
223
+ }
224
+ export interface EmailClient {
225
+ sendSmtpEmail(input: SendSmtpEmailInput): Promise<SendSmtpEmailResult>;
226
+ testSmtpImapConnection(input: SmtpImapConnectionTestInput): Promise<SmtpImapConnectionTestResult>;
227
+ crawlImapPdfAttachments(input: CrawlImapPdfAttachmentsInput): Promise<CrawlImapPdfAttachmentsResult>;
88
228
  }
89
229
  /**
90
230
  * Client for accessing external service credentials.
@@ -103,6 +243,46 @@ export interface CredentialsClient {
103
243
  * Force refresh OAuth2 token.
104
244
  */
105
245
  refreshToken(provider: string): Promise<string>;
246
+ /**
247
+ * Get non-secret connection metadata for a provider.
248
+ */
249
+ getConnectionInfo(provider: string): Promise<CredentialConnectionInfo>;
250
+ }
251
+ export interface CredentialConnectionInfo {
252
+ connected: boolean;
253
+ provider: string;
254
+ credentialType?: 'oauth2' | 'api_key';
255
+ accountEmail?: string;
256
+ accountId?: string;
257
+ accountName?: string;
258
+ scopes?: string[];
259
+ expiresAt?: string;
260
+ valid?: boolean;
261
+ errorMessage?: string;
262
+ }
263
+ export interface MappingRecord {
264
+ system: string;
265
+ entity: string;
266
+ localId: string;
267
+ externalId: string;
268
+ metadata?: Record<string, unknown>;
269
+ }
270
+ export interface MappingGetInput {
271
+ system: string;
272
+ entity: string;
273
+ localId: string;
274
+ }
275
+ export interface MappingFindByExternalInput {
276
+ system: string;
277
+ entity: string;
278
+ externalId: string;
279
+ }
280
+ export interface MappingUpsertInput extends MappingRecord {
281
+ }
282
+ export interface MappingsClient {
283
+ get(input: MappingGetInput): Promise<MappingRecord | null>;
284
+ findByExternal(input: MappingFindByExternalInput): Promise<MappingRecord | null>;
285
+ upsert(input: MappingUpsertInput): Promise<void>;
106
286
  }
107
287
  /**
108
288
  * Structured logger for execution.
@@ -1 +1 @@
1
- {"version":3,"file":"IntegrationContext.d.ts","sourceRoot":"","sources":["../../src/context/IntegrationContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,QAAQ,EACR,OAAO,EACP,QAAQ,EACR,GAAG,EACH,MAAM,EACN,kBAAkB,EAClB,UAAU,EACV,UAAU,EACX,MAAM,YAAY,CAAC;AAEpB;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,WAAW,kBAAkB,CAAC,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IACnE,uBAAuB;IACvB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAEzB,oDAAoD;IACpD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAExB,sBAAsB;IACtB,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAEhC,kCAAkC;IAClC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IAEzB,yBAAyB;IACzB,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAE1B,+BAA+B;IAC/B,QAAQ,CAAC,WAAW,EAAE,iBAAiB,CAAC;IAExC,wBAAwB;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED;;;GAGG;AACH,MAAM,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AAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,0BAA0B;IACzC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,kBAAmB,SAAQ,aAAa;CAAG;AAE5D,MAAM,WAAW,cAAc;IAC7B,GAAG,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC,CAAC;IAC3D,cAAc,CAAC,KAAK,EAAE,0BAA0B,GAAG,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC,CAAC;IACjF,MAAM,CAAC,KAAK,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAClD;AAED;;GAEG;AACH,MAAM,WAAW,MAAM;IACrB,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAC7C,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAC5C,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAC5C,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;CAC9C;AAGD,YAAY,EACV,QAAQ,EACR,OAAO,EACP,QAAQ,EACR,GAAG,EACH,MAAM,EACN,kBAAkB,EAClB,UAAU,EACV,UAAU,GACX,MAAM,YAAY,CAAC"}
@@ -0,0 +1,11 @@
1
+ export interface AttachmentFingerprintInput {
2
+ uid: number | string;
3
+ fileName: string;
4
+ size?: number;
5
+ sha256?: string;
6
+ }
7
+ /**
8
+ * Builds a deterministic fingerprint used for dedupe/checkpoint keys.
9
+ */
10
+ export declare function createAttachmentFingerprint(input: AttachmentFingerprintInput): string;
11
+ //# sourceMappingURL=createAttachmentFingerprint.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createAttachmentFingerprint.d.ts","sourceRoot":"","sources":["../../src/helpers/createAttachmentFingerprint.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,0BAA0B;IACzC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,0BAA0B,GAAG,MAAM,CASrF"}
@@ -0,0 +1,14 @@
1
+ import { createHash } from 'crypto';
2
+ /**
3
+ * Builds a deterministic fingerprint used for dedupe/checkpoint keys.
4
+ */
5
+ export function createAttachmentFingerprint(input) {
6
+ const material = [
7
+ String(input.uid),
8
+ input.fileName,
9
+ input.size != null ? String(input.size) : '',
10
+ input.sha256 || '',
11
+ ].join(':');
12
+ return createHash('sha256').update(material).digest('hex');
13
+ }
14
+ //# sourceMappingURL=createAttachmentFingerprint.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createAttachmentFingerprint.js","sourceRoot":"","sources":["../../src/helpers/createAttachmentFingerprint.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AASpC;;GAEG;AACH,MAAM,UAAU,2BAA2B,CAAC,KAAiC;IAC3E,MAAM,QAAQ,GAAG;QACf,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC;QACjB,KAAK,CAAC,QAAQ;QACd,KAAK,CAAC,IAAI,IAAI,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE;QAC5C,KAAK,CAAC,MAAM,IAAI,EAAE;KACnB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAEZ,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC7D,CAAC"}
package/dist/index.d.ts CHANGED
@@ -30,5 +30,7 @@ export * from './types/index.js';
30
30
  export * from './context/index.js';
31
31
  export { defineIntegration } from './helpers/defineIntegration.js';
32
32
  export { defineHandler } from './helpers/defineHandler.js';
33
+ export { createAttachmentFingerprint } from './helpers/createAttachmentFingerprint.js';
34
+ export type { AttachmentFingerprintInput } from './helpers/createAttachmentFingerprint.js';
33
35
  export type { IntegrationHandler, HandlerFunction, DocumentCreatedInput, DocumentUpdatedInput, DocumentProcessedInput, DocumentDeletedInput, CompanyCreatedInput, ExportCompletedInput, ReminderTriggeredInput, WebhookInput, ScheduleInput, UserActionInput, } from './helpers/defineHandler.js';
34
36
  //# sourceMappingURL=index.d.ts.map
@@ -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;AAGnC,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,YAAY,EACV,kBAAkB,EAClB,eAAe,EACf,oBAAoB,EACpB,oBAAoB,EACpB,sBAAsB,EACtB,oBAAoB,EACpB,mBAAmB,EACnB,oBAAoB,EACpB,sBAAsB,EACtB,YAAY,EACZ,aAAa,EACb,eAAe,GAChB,MAAM,4BAA4B,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;AAGnC,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,2BAA2B,EAAE,MAAM,0CAA0C,CAAC;AACvF,YAAY,EAAE,0BAA0B,EAAE,MAAM,0CAA0C,CAAC;AAC3F,YAAY,EACV,kBAAkB,EAClB,eAAe,EACf,oBAAoB,EACpB,oBAAoB,EACpB,sBAAsB,EACtB,oBAAoB,EACpB,mBAAmB,EACnB,oBAAoB,EACpB,sBAAsB,EACtB,YAAY,EACZ,aAAa,EACb,eAAe,GAChB,MAAM,4BAA4B,CAAC"}
package/dist/index.js CHANGED
@@ -33,4 +33,5 @@ export * from './context/index.js';
33
33
  // Helpers
34
34
  export { defineIntegration } from './helpers/defineIntegration.js';
35
35
  export { defineHandler } from './helpers/defineHandler.js';
36
+ export { createAttachmentFingerprint } from './helpers/createAttachmentFingerprint.js';
36
37
  //# 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;AAEnC,UAAU;AACV,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,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;AAEnC,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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@invoiceleaf/integration-sdk",
3
- "version": "1.2.0",
3
+ "version": "1.6.0",
4
4
  "description": "SDK for building InvoiceLeaf integrations",
5
5
  "keywords": [
6
6
  "invoiceleaf",