@almadar/integrations 2.24.0 → 2.26.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.
@@ -1,5 +1,5 @@
1
- import { ServiceParamsValue, ServiceParams } from '@almadar/core';
2
- import { d as IntegrationParamValue, e as IntegrationParams } from './BaseIntegration-MA-b4fh8.js';
1
+ import { ServiceParamsValue, ServiceParams, EntityRow } from '@almadar/core';
2
+ import { f as IntegrationParamValue, g as IntegrationParams } from './BaseIntegration-C_5q54DM.js';
3
3
 
4
4
  /** Scalar value admissible as a SQL bind parameter. */
5
5
  type DatabaseQueryParamValue = string | number | boolean | Date | null;
@@ -79,8 +79,9 @@ type GitHubActions = {
79
79
  params: {
80
80
  title: string;
81
81
  body: string;
82
- head: string;
83
- base: string;
82
+ baseBranch: string;
83
+ headBranch: string;
84
+ draft?: boolean;
84
85
  };
85
86
  result: {
86
87
  number: number;
@@ -322,6 +323,7 @@ type TwilioActions = {
322
323
  params: {
323
324
  to: string;
324
325
  body: string;
326
+ from?: string;
325
327
  };
326
328
  result: {
327
329
  sid: string;
@@ -346,6 +348,11 @@ type EmailActions = {
346
348
  subject: string;
347
349
  body: string;
348
350
  from?: string;
351
+ /** HTML content; when present `body` becomes the plain-text alternative. */
352
+ htmlBody?: string;
353
+ replyTo?: string;
354
+ /** Provider template reference (SendGrid dynamic templates; Resend rejects it loudly). */
355
+ templateId?: string;
349
356
  };
350
357
  result: {
351
358
  id: string;
@@ -368,6 +375,336 @@ type WebhookActions = {
368
375
  };
369
376
  };
370
377
  };
378
+ type PushActions = {
379
+ send: {
380
+ params: {
381
+ subscription: {
382
+ endpoint: string;
383
+ keys: {
384
+ p256dh: string;
385
+ auth: string;
386
+ };
387
+ };
388
+ title: string;
389
+ body: string;
390
+ url?: string;
391
+ icon?: string;
392
+ };
393
+ result: {
394
+ statusCode: number;
395
+ ok: boolean;
396
+ expired: boolean;
397
+ };
398
+ };
399
+ };
400
+ type CalendarActions = {
401
+ listEvents: {
402
+ params: {
403
+ calendarId?: string;
404
+ timeMin?: string;
405
+ timeMax?: string;
406
+ syncToken?: string;
407
+ maxResults?: number;
408
+ };
409
+ result: {
410
+ events: Array<{
411
+ id: string;
412
+ summary: string;
413
+ description: string;
414
+ location: string;
415
+ start: string;
416
+ end: string;
417
+ status: string;
418
+ updated: string;
419
+ }>;
420
+ nextSyncToken: string | null;
421
+ };
422
+ };
423
+ createEvent: {
424
+ params: {
425
+ calendarId?: string;
426
+ summary: string;
427
+ description?: string;
428
+ location?: string;
429
+ start: string;
430
+ end?: string;
431
+ durationMinutes?: number;
432
+ };
433
+ result: {
434
+ id: string;
435
+ status: string;
436
+ htmlLink: string;
437
+ };
438
+ };
439
+ updateEvent: {
440
+ params: {
441
+ calendarId?: string;
442
+ eventId: string;
443
+ summary?: string;
444
+ description?: string;
445
+ location?: string;
446
+ start?: string;
447
+ end?: string;
448
+ };
449
+ result: {
450
+ id: string;
451
+ status: string;
452
+ };
453
+ };
454
+ deleteEvent: {
455
+ params: {
456
+ calendarId?: string;
457
+ eventId: string;
458
+ };
459
+ result: {
460
+ id: string;
461
+ deleted: boolean;
462
+ };
463
+ };
464
+ freeBusy: {
465
+ params: {
466
+ calendarId?: string;
467
+ timeMin: string;
468
+ timeMax: string;
469
+ };
470
+ result: {
471
+ busy: Array<{
472
+ start: string;
473
+ end: string;
474
+ }>;
475
+ };
476
+ };
477
+ watch: {
478
+ params: {
479
+ calendarId?: string;
480
+ channelId: string;
481
+ address: string;
482
+ ttlSeconds?: number;
483
+ };
484
+ result: {
485
+ channelId: string;
486
+ resourceId: string;
487
+ expiration: string;
488
+ };
489
+ };
490
+ stopWatch: {
491
+ params: {
492
+ channelId: string;
493
+ resourceId: string;
494
+ };
495
+ result: {
496
+ stopped: boolean;
497
+ };
498
+ };
499
+ };
500
+ type DriveActions = {
501
+ listFiles: {
502
+ params: {
503
+ folderId?: string;
504
+ query?: string;
505
+ maxResults?: number;
506
+ };
507
+ result: {
508
+ files: Array<{
509
+ id: string;
510
+ name: string;
511
+ mimeType: string;
512
+ size: number;
513
+ modifiedTime: string;
514
+ webViewLink: string;
515
+ }>;
516
+ };
517
+ };
518
+ getFile: {
519
+ params: {
520
+ fileId: string;
521
+ };
522
+ result: {
523
+ id: string;
524
+ name: string;
525
+ mimeType: string;
526
+ content: string;
527
+ size: number;
528
+ };
529
+ };
530
+ uploadFile: {
531
+ params: {
532
+ name: string;
533
+ content: string;
534
+ mimeType?: string;
535
+ folderId?: string;
536
+ };
537
+ result: {
538
+ id: string;
539
+ name: string;
540
+ webViewLink: string;
541
+ };
542
+ };
543
+ createFolder: {
544
+ params: {
545
+ name: string;
546
+ parentId?: string;
547
+ };
548
+ result: {
549
+ id: string;
550
+ name: string;
551
+ };
552
+ };
553
+ shareFile: {
554
+ params: {
555
+ fileId: string;
556
+ email: string;
557
+ role?: 'reader' | 'writer' | 'commenter';
558
+ };
559
+ result: {
560
+ shared: boolean;
561
+ permissionId: string;
562
+ };
563
+ };
564
+ };
565
+ type MetaAdsActions = {
566
+ getSpend: {
567
+ params: {
568
+ accountId?: string;
569
+ since: string;
570
+ until: string;
571
+ clientTag?: string;
572
+ };
573
+ result: {
574
+ spend: number;
575
+ currency: string;
576
+ impressions: number;
577
+ clicks: number;
578
+ };
579
+ };
580
+ listCampaigns: {
581
+ params: {
582
+ accountId?: string;
583
+ status?: string;
584
+ };
585
+ result: {
586
+ campaigns: Array<{
587
+ id: string;
588
+ name: string;
589
+ status: string;
590
+ dailyBudget: number;
591
+ }>;
592
+ };
593
+ };
594
+ };
595
+ type AccountingActions = {
596
+ exportInvoices: {
597
+ params: {
598
+ invoices: Array<{
599
+ id: string;
600
+ number: string;
601
+ customer: string;
602
+ issuedAt: string;
603
+ dueAt: string;
604
+ currency: string;
605
+ net: number;
606
+ tax: number;
607
+ gross: number;
608
+ status: string;
609
+ }>;
610
+ format?: 'csv';
611
+ };
612
+ result: {
613
+ content: string;
614
+ filename: string;
615
+ count: number;
616
+ };
617
+ };
618
+ exportJournal: {
619
+ params: {
620
+ entries: Array<{
621
+ date: string;
622
+ account: string;
623
+ description: string;
624
+ debit: number;
625
+ credit: number;
626
+ reference: string;
627
+ }>;
628
+ format?: 'csv';
629
+ };
630
+ result: {
631
+ content: string;
632
+ filename: string;
633
+ count: number;
634
+ };
635
+ };
636
+ };
637
+ type BankingActions = {
638
+ createRequisition: {
639
+ params: {
640
+ institutionId: string;
641
+ redirectUrl: string;
642
+ reference?: string;
643
+ };
644
+ result: {
645
+ requisitionId: string;
646
+ link: string;
647
+ };
648
+ };
649
+ listAccounts: {
650
+ params: {
651
+ requisitionId: string;
652
+ };
653
+ result: {
654
+ accounts: string[];
655
+ };
656
+ };
657
+ listTransactions: {
658
+ params: {
659
+ accountId: string;
660
+ dateFrom?: string;
661
+ dateTo?: string;
662
+ };
663
+ result: {
664
+ transactions: Array<{
665
+ id: string;
666
+ amount: number;
667
+ currency: string;
668
+ date: string;
669
+ description: string;
670
+ counterparty: string;
671
+ }>;
672
+ };
673
+ };
674
+ };
675
+ type EsignActions = {
676
+ sendEnvelope: {
677
+ params: {
678
+ recipientEmail: string;
679
+ recipientName: string;
680
+ documentName: string;
681
+ documentContent: string;
682
+ emailSubject?: string;
683
+ };
684
+ result: {
685
+ envelopeId: string;
686
+ status: string;
687
+ };
688
+ };
689
+ getEnvelopeStatus: {
690
+ params: {
691
+ envelopeId: string;
692
+ };
693
+ result: {
694
+ status: string;
695
+ completedAt: string;
696
+ };
697
+ };
698
+ downloadDocument: {
699
+ params: {
700
+ envelopeId: string;
701
+ };
702
+ result: {
703
+ content: string;
704
+ documentName: string;
705
+ };
706
+ };
707
+ };
371
708
  type DockerActions = {
372
709
  build: {
373
710
  params: {
@@ -490,7 +827,12 @@ type StorageActions = {
490
827
  key?: string;
491
828
  content?: string;
492
829
  contentType?: string;
493
- file?: IntegrationParams;
830
+ file?: {
831
+ name: string;
832
+ size: number;
833
+ type: string;
834
+ content?: string;
835
+ };
494
836
  acl?: 'public' | 'private';
495
837
  maxSize?: number;
496
838
  metadata?: IntegrationParams;
@@ -500,6 +842,8 @@ type StorageActions = {
500
842
  bucket: string;
501
843
  size: number;
502
844
  etag: string;
845
+ id: string;
846
+ url: string;
503
847
  };
504
848
  };
505
849
  download: {
@@ -519,6 +863,7 @@ type StorageActions = {
519
863
  bucket: string;
520
864
  prefix?: string;
521
865
  maxKeys?: number;
866
+ continuationToken?: string;
522
867
  };
523
868
  result: {
524
869
  keys: Array<{
@@ -527,6 +872,7 @@ type StorageActions = {
527
872
  lastModified: number;
528
873
  }>;
529
874
  truncated: boolean;
875
+ nextToken?: string;
530
876
  };
531
877
  };
532
878
  delete: {
@@ -763,6 +1109,68 @@ type OAuthActions = {
763
1109
  };
764
1110
  };
765
1111
  };
1112
+ type CredentialsActions = {
1113
+ list: {
1114
+ params: {
1115
+ service?: string;
1116
+ };
1117
+ result: {
1118
+ enabled: boolean;
1119
+ entries: Array<{
1120
+ service: string;
1121
+ envVar: string;
1122
+ required: boolean;
1123
+ description: string;
1124
+ configured: boolean;
1125
+ source: 'store' | 'env' | 'none';
1126
+ last4: string;
1127
+ }>;
1128
+ };
1129
+ };
1130
+ set: {
1131
+ params: {
1132
+ service: string;
1133
+ envVar: string;
1134
+ value: string;
1135
+ };
1136
+ result: {
1137
+ saved: boolean;
1138
+ service: string;
1139
+ envVar: string;
1140
+ last4: string;
1141
+ };
1142
+ };
1143
+ remove: {
1144
+ params: {
1145
+ service: string;
1146
+ envVar: string;
1147
+ };
1148
+ result: {
1149
+ removed: boolean;
1150
+ };
1151
+ };
1152
+ test: {
1153
+ params: {
1154
+ service: string;
1155
+ };
1156
+ result: {
1157
+ service: string;
1158
+ configured: boolean;
1159
+ missing: string[];
1160
+ probed: boolean;
1161
+ ok: boolean;
1162
+ message: string;
1163
+ };
1164
+ };
1165
+ rotate: {
1166
+ params: Record<string, never>;
1167
+ result: {
1168
+ rotated: number;
1169
+ alreadyCurrent: number;
1170
+ unreadable: number;
1171
+ };
1172
+ };
1173
+ };
766
1174
  type OtelActions = {
767
1175
  startSpan: {
768
1176
  params: {
@@ -989,11 +1397,19 @@ type IntegrationContracts = {
989
1397
  twilio: TwilioActions;
990
1398
  email: EmailActions;
991
1399
  webhook: WebhookActions;
1400
+ push: PushActions;
1401
+ calendar: CalendarActions;
1402
+ drive: DriveActions;
1403
+ metaAds: MetaAdsActions;
1404
+ accounting: AccountingActions;
1405
+ banking: BankingActions;
1406
+ esign: EsignActions;
992
1407
  docker: DockerActions;
993
1408
  storage: StorageActions;
994
1409
  queue: QueueActions;
995
1410
  redis: RedisActions;
996
1411
  oauth: OAuthActions;
1412
+ credentials: CredentialsActions;
997
1413
  otel: OtelActions;
998
1414
  cli: CLIActions;
999
1415
  deepagent: DeepAgentActions;
@@ -1014,5 +1430,124 @@ type IntegrationName = keyof IntegrationContracts;
1014
1430
  * ```
1015
1431
  */
1016
1432
  type IntegrationActionName<K extends IntegrationName> = keyof IntegrationContracts[K] & string;
1433
+ /**
1434
+ * Declared side-effect-free "Test connection" probes, executed by the
1435
+ * `credentials.test` action through the normal factory path. Only services
1436
+ * with a genuinely cheap, read-only, env-defaulted action carry one; the
1437
+ * rest report credential presence + constructor validation.
1438
+ */
1439
+ /**
1440
+ * One inbound-hook mount a service's provider needs in a deployed app:
1441
+ * `POST /api/hooks/:provider` verified by the provider's own token/signature,
1442
+ * dispatching `event` onto the app bus. A hook is a PROVIDER property — the
1443
+ * service invocation is the `.lolo` surface; codegen derives the mount from
1444
+ * the app's invoked services × these declarations (I-26).
1445
+ */
1446
+ interface HookDeclaration {
1447
+ /** Provider key mounted at POST /api/hooks/:provider */
1448
+ provider: string;
1449
+ /** Bus event dispatched into the app on a verified callback */
1450
+ event: string;
1451
+ /** Env var carrying the provider's verification secret/channel token */
1452
+ credentialEnv: string;
1453
+ /** Factory export in @almadar/integrations: (secret?) => HookProvider */
1454
+ providerExport: string;
1455
+ }
1456
+ /**
1457
+ * Inbound-hook declarations per service — the single source the registry,
1458
+ * codegen, and the playground mount derive from.
1459
+ */
1460
+ declare const serviceHooks: Record<string, HookDeclaration[]>;
1461
+
1462
+ /** Entity type the credential rows persist under (never a `.lolo`-declared entity). */
1463
+ declare const CREDENTIAL_ENTITY_TYPE = "AlmadarIntegrationCredential";
1464
+ /** Env var holding the 64-char-hex AES-256 master key (Secret Manager in production). */
1465
+ declare const CREDENTIAL_MASTER_KEY_ENV = "ALMADAR_CREDENTIAL_MASTER_KEY";
1466
+ /**
1467
+ * Structural subset of `@almadar/runtime`'s `PersistenceAdapter` — declared
1468
+ * here because the dependency axis runs integrations → runtime, never the
1469
+ * reverse. Every `PersistenceAdapter` implementation satisfies it as-is.
1470
+ */
1471
+ interface CredentialPersistence {
1472
+ create(entityType: string, data: EntityRow): Promise<{
1473
+ id: string;
1474
+ }>;
1475
+ update(entityType: string, id: string, data: EntityRow): Promise<void>;
1476
+ delete(entityType: string, id: string): Promise<void>;
1477
+ list(entityType: string): Promise<EntityRow[]>;
1478
+ }
1479
+ /** Masked view of one stored credential — safe to return to a settings page. */
1480
+ interface CredentialEntry {
1481
+ service: string;
1482
+ envVar: string;
1483
+ last4: string;
1484
+ updatedAt: number;
1485
+ }
1486
+ /**
1487
+ * Tenant-scoped (app-wide) credential store: one AES-256-GCM-encrypted row
1488
+ * per (service, envVar) through the host's persistence adapter, master key
1489
+ * `ALMADAR_CREDENTIAL_MASTER_KEY` held alone in the platform secret store.
1490
+ *
1491
+ * Resolution contract: credential keys ARE env-var names (the same names
1492
+ * `serviceCredentials` declares and `connectionRef` carries), so a stored
1493
+ * value transparently shadows its env counterpart — store → env →
1494
+ * unconfigured, everywhere.
1495
+ *
1496
+ * `warm()` decrypts all rows into memory so resolution stays synchronous;
1497
+ * every write re-warms the affected entry and notifies subscribers (the
1498
+ * `RuntimeIntegrationManager` re-configures on that signal, so new keys go
1499
+ * live without a restart).
1500
+ */
1501
+ declare class CredentialStore {
1502
+ private readonly adapter;
1503
+ private readonly masterKeyHex;
1504
+ private readonly previousKeyHex;
1505
+ private readonly byEnvVar;
1506
+ private readonly listeners;
1507
+ private warmed;
1508
+ constructor(adapter: CredentialPersistence, masterKey?: string, previousMasterKey?: string);
1509
+ /** True when a valid master key is present (writes and decryption enabled). */
1510
+ get enabled(): boolean;
1511
+ /** Subscribe to credential changes; returns an unsubscribe function. */
1512
+ subscribe(listener: () => void): () => void;
1513
+ private notify;
1514
+ private encrypt;
1515
+ private decryptWithKey;
1516
+ /**
1517
+ * Decrypt one row, selecting the key by the row's stamped `keyId` (I-28):
1518
+ * current key first, then the rotation-window previous key. Legacy rows
1519
+ * (no `keyId`) try current then previous. Returns null when no held key
1520
+ * decrypts the row — the row is unreadable, never silently wrong (GCM
1521
+ * auth tags make a wrong-key success impossible).
1522
+ */
1523
+ private decryptRow;
1524
+ /**
1525
+ * Load and decrypt every stored row into memory. Returns the number of
1526
+ * resolvable credentials. Without a master key nothing decrypts (rows are
1527
+ * left in place, resolution falls through to env).
1528
+ */
1529
+ warm(): Promise<number>;
1530
+ /** Resolve one credential by env-var name (warmed values only). */
1531
+ resolve(envVar: string): string | undefined;
1532
+ /** All warmed values as an env-shaped map, for merging over the process env. */
1533
+ snapshotEnv(): Record<string, string>;
1534
+ /** Masked entries for display — never includes plaintext. */
1535
+ entries(): CredentialEntry[];
1536
+ /** Upsert one credential (encrypts, persists, re-warms the entry, notifies). */
1537
+ set(service: string, envVar: string, value: string): Promise<CredentialEntry>;
1538
+ /**
1539
+ * Re-encrypt every readable row under the CURRENT master key (I-28).
1540
+ * Rotation window: deploy the new key as `ALMADAR_CREDENTIAL_MASTER_KEY`
1541
+ * with the old one as `..._PREVIOUS`, call `rotate()`, then retire the
1542
+ * previous key. Rows no held key can read are counted, never dropped.
1543
+ */
1544
+ rotate(): Promise<{
1545
+ rotated: number;
1546
+ alreadyCurrent: number;
1547
+ unreadable: number;
1548
+ }>;
1549
+ /** Delete one credential row; resolution falls back to env afterwards. */
1550
+ remove(envVar: string): Promise<boolean>;
1551
+ }
1017
1552
 
1018
- export type { ArxivActions as A, CLIActions as C, DatabaseActions as D, EmailActions as E, GitHubActions as G, IconifyActions as I, LLMIntegrationActions as L, MLActions as M, OAuthActions as O, QueueActions as Q, RedisActions as R, StorageActions as S, TwilioActions as T, WebhookActions as W, YouTubeActions as Y, DatabaseDriver as a, DatabaseQueryParamValue as b, DatabaseQueryParams as c, DatabaseQueryResult as d, DatabaseRow as e, DeepAgentActions as f, DockerActions as g, IntegrationActionName as h, IntegrationContracts as i, IntegrationName as j, OtelActions as k, StripeActions as l, WikimediaActions as m };
1553
+ export { type ArxivActions as A, type CLIActions as C, type DatabaseActions as D, type EmailActions as E, type GitHubActions as G, type HookDeclaration as H, type IconifyActions as I, type LLMIntegrationActions as L, type MLActions as M, type OAuthActions as O, type QueueActions as Q, type RedisActions as R, type StorageActions as S, type TwilioActions as T, type WebhookActions as W, type YouTubeActions as Y, CREDENTIAL_ENTITY_TYPE as a, CREDENTIAL_MASTER_KEY_ENV as b, type CredentialEntry as c, type CredentialPersistence as d, CredentialStore as e, type DatabaseDriver as f, type DatabaseQueryParamValue as g, type DatabaseQueryParams as h, type DatabaseQueryResult as i, type DatabaseRow as j, type DeepAgentActions as k, type DockerActions as l, type IntegrationActionName as m, type IntegrationContracts as n, type IntegrationName as o, type OtelActions as p, type StripeActions as q, type WikimediaActions as r, serviceHooks as s };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@almadar/integrations",
3
- "version": "2.24.0",
3
+ "version": "2.26.0",
4
4
  "description": "External service integrations for Almadar applications",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -33,29 +33,34 @@
33
33
  "access": "public"
34
34
  },
35
35
  "dependencies": {
36
- "@almadar/core": "^10.58.0",
37
- "@almadar/llm": "^2.40.0",
36
+ "@almadar/core": "^10.67.0",
37
+ "@almadar/llm": "^2.41.0",
38
38
  "@almadar/logger": "^1.11.0",
39
+ "@aws-sdk/client-s3": "^3.700.0",
40
+ "@aws-sdk/s3-request-presigner": "^3.700.0",
39
41
  "@sendgrid/mail": "^8.1.4",
40
42
  "dotenv": "^16.4.0",
41
43
  "googleapis": "^144.0.0",
44
+ "openid-client": "6.8.7",
42
45
  "pg": "^8.13.1",
43
46
  "resend": "^4.0.1",
44
47
  "stripe": "^17.5.0",
45
48
  "twilio": "^5.3.6",
49
+ "web-push": "^3.6.7",
46
50
  "zod": "^3.23.0"
47
51
  },
48
52
  "devDependencies": {
49
53
  "@almadar/eslint-plugin": "^2.15.0",
50
54
  "@types/node": "^20.0.0",
51
55
  "@types/pg": "^8.11.10",
56
+ "@types/web-push": "^3.6.4",
52
57
  "@typescript-eslint/parser": "8.65.0",
58
+ "@typescript/native": "npm:typescript@^7.0.2",
53
59
  "eslint": "10.0.0",
54
60
  "tsup": "^8.0.0",
55
- "vitest": "^2.1.0",
56
61
  "turbo": "^2.8.17",
57
- "@typescript/native": "npm:typescript@^7.0.2",
58
- "typescript": "npm:@typescript/typescript6@^6.0.2"
62
+ "typescript": "npm:@typescript/typescript6@^6.0.2",
63
+ "vitest": "^2.1.0"
59
64
  },
60
65
  "repository": {
61
66
  "type": "git",
@@ -75,7 +80,7 @@
75
80
  ],
76
81
  "homepage": "https://github.com/almadar-io/almadar#readme",
77
82
  "scripts": {
78
- "build": "tsup",
83
+ "build": "NODE_OPTIONS=--max-old-space-size=8192 tsup",
79
84
  "build:watch": "tsup --watch",
80
85
  "test": "vitest --run",
81
86
  "test:watch": "vitest",