sahab-utils 1.3.0 → 1.4.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.
@@ -444,13 +444,101 @@ export type Provider = {
444
444
  integrations?: {
445
445
  email?: string;
446
446
  isActive?: boolean;
447
+ /** Canonical values from `INTEGRATION_KEYS`, e.g. `'TAP_PAYMENTS'`. */
447
448
  key: string;
448
449
  /** Tap (and other gateways): server-side API secret */
449
450
  secretKey?: string;
450
- /** Tap Connect marketplace payout destination id (sub-merchant) */
451
+ /** Tap Connect marketplace payout destination id (sub-merchant). Set when the related `TapApplication` reaches `payout_enabled`. */
451
452
  tapDestinationId?: string;
452
453
  }[];
453
454
  };
455
+ export declare const INTEGRATION_KEYS: {
456
+ readonly TAP_PAYMENTS: "TAP_PAYMENTS";
457
+ };
458
+ export type IntegrationKey = (typeof INTEGRATION_KEYS)[keyof typeof INTEGRATION_KEYS];
459
+ export type TapKycStatus = 'draft' | 'documents_uploaded' | 'lead_created' | 'account_created' | 'payout_enabled' | 'rejected';
460
+ export type TapDocumentPurpose = 'commercial_registration' | 'national_id' | 'bank_statement' | 'iban_certificate';
461
+ export type TapLicenseType = 'LLC' | 'SOLE_PROPRIETORSHIP' | 'JOINT_STOCK' | 'PARTNERSHIP' | 'OTHER';
462
+ export type TapApplicationFile = {
463
+ purpose: TapDocumentPurpose;
464
+ fileId: string;
465
+ title?: string;
466
+ /** epoch seconds */
467
+ uploadedAt: number;
468
+ /** epoch seconds, mirrors Tap's expires_at */
469
+ expiresAt?: number;
470
+ };
471
+ export type TapApplicationFormData = {
472
+ country: 'SA';
473
+ brand: {
474
+ websiteUrl: string;
475
+ nameEn: string;
476
+ nameAr: string;
477
+ };
478
+ entity: {
479
+ licenseNumber: string;
480
+ unifiedNumber: string;
481
+ licenseType: TapLicenseType;
482
+ legalNameEn: string;
483
+ };
484
+ bank: {
485
+ beneficiaryName: string;
486
+ iban: string;
487
+ };
488
+ walletName: string;
489
+ owner: {
490
+ firstName: string;
491
+ middleName?: string;
492
+ lastName: string;
493
+ email: string;
494
+ phoneCountryCode: string;
495
+ phoneNumber: string;
496
+ nationalId: string;
497
+ nationality: string;
498
+ idType: 'national_id' | 'passport';
499
+ };
500
+ };
501
+ export type TapApplicationError = {
502
+ code?: string;
503
+ message: string;
504
+ /** epoch seconds */
505
+ at: number;
506
+ endpoint: 'files' | 'lead' | 'account' | 'update_lead';
507
+ };
508
+ /**
509
+ * Stored at: `service_providers/{providerId}/tapApplications/{applicationId}`.
510
+ *
511
+ * One document per onboarding attempt. On rejection a new application may be created;
512
+ * history is preserved. Invariant: at most one non-terminal application per provider.
513
+ * Terminal states: `payout_enabled`, `rejected`.
514
+ */
515
+ export type TapApplication = {
516
+ id: string;
517
+ providerId: string;
518
+ /** epoch seconds */
519
+ createdAt: number;
520
+ /** epoch seconds */
521
+ updatedAt: number;
522
+ /** admin uid that initiated the application */
523
+ createdBy: string;
524
+ kycStatus: TapKycStatus;
525
+ payoutEnabled: boolean;
526
+ formData?: TapApplicationFormData;
527
+ files?: TapApplicationFile[];
528
+ tapLeadId?: string;
529
+ /** retailer.id from Tap; mirrored up to provider.integrations[TAP_PAYMENTS].tapDestinationId on payout_enabled */
530
+ tapDestinationId?: string;
531
+ /** epoch seconds — lead → account transition */
532
+ submittedAt?: number;
533
+ /** epoch seconds — set by webhook on payout_enabled */
534
+ approvedAt?: number;
535
+ /** epoch seconds */
536
+ rejectedAt?: number;
537
+ rejectionReason?: string;
538
+ lastError?: TapApplicationError;
539
+ /** echo of post.url sent on lead creation */
540
+ webhookUrl?: string;
541
+ };
454
542
  export type Card = {
455
543
  id?: string;
456
544
  issuer?: string;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RegistrationSection = exports.ReviewStatus = exports.ComplaintStatus = exports.ComplaintType = exports.MovementType = exports.OrderPaymentType = exports.OrderStatus = exports.CarSize = void 0;
3
+ exports.INTEGRATION_KEYS = exports.RegistrationSection = exports.ReviewStatus = exports.ComplaintStatus = exports.ComplaintType = exports.MovementType = exports.OrderPaymentType = exports.OrderStatus = exports.CarSize = void 0;
4
4
  var CarSize;
5
5
  (function (CarSize) {
6
6
  CarSize[CarSize["X_SMALL"] = 0] = "X_SMALL";
@@ -77,3 +77,6 @@ var RegistrationSection;
77
77
  RegistrationSection[RegistrationSection["STATUS"] = 11] = "STATUS";
78
78
  RegistrationSection[RegistrationSection["DONE"] = 12] = "DONE";
79
79
  })(RegistrationSection || (exports.RegistrationSection = RegistrationSection = {}));
80
+ exports.INTEGRATION_KEYS = {
81
+ TAP_PAYMENTS: 'TAP_PAYMENTS',
82
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sahab-utils",
3
- "version": "1.3.0",
3
+ "version": "1.4.0",
4
4
  "description": "This package contains types and utils functions",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",