@delopay/sdk 0.51.0 → 0.53.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/dist/index.d.cts CHANGED
@@ -582,6 +582,17 @@ interface CustomerListParams {
582
582
  limit?: number | null;
583
583
  offset?: number | null;
584
584
  email?: string | null;
585
+ /**
586
+ * Filter customers by the shop (business profile) they have transacted in.
587
+ * Membership is derived from `payment_intent` — a customer who never
588
+ * transacted appears under no shop.
589
+ */
590
+ profile_id?: string | null;
591
+ /**
592
+ * Filter customers by project; expands to all shops (business profiles)
593
+ * under that project.
594
+ */
595
+ project_id?: string | null;
585
596
  }
586
597
  interface PaymentMethodCreateRequest {
587
598
  payment_method: PaymentMethod;
@@ -2910,18 +2921,47 @@ declare class Customers {
2910
2921
  */
2911
2922
  delete(customerId: string): Promise<CustomerResponse>;
2912
2923
  /**
2913
- * List customers, optionally filtered by email.
2924
+ * List customers, optionally filtered by email, shop (`profile_id`), or
2925
+ * project (`project_id`).
2914
2926
  *
2915
2927
  * @param params - Optional filter and pagination parameters.
2916
2928
  * @returns Array of customer objects.
2929
+ *
2930
+ * @example
2931
+ * ```typescript
2932
+ * // Customers who have transacted in a specific shop.
2933
+ * const customers = await delopay.customers.list({ profile_id: 'pro_abc123' });
2934
+ * ```
2917
2935
  */
2918
2936
  list(params?: CustomerListParams): Promise<CustomerResponse[]>;
2919
- /** List customers with count. `GET /customers/list-with-count` */
2937
+ /**
2938
+ * List customers with count. Supports the same `profile_id` / `project_id`
2939
+ * shop filters as {@link list}. `GET /customers/list-with-count`
2940
+ */
2920
2941
  listWithCount(params?: CustomerListParams): Promise<{
2921
2942
  count: number;
2922
2943
  total_count: number;
2923
2944
  data: CustomerResponse[];
2924
2945
  }>;
2946
+ /**
2947
+ * List customers scoped to the authenticated dashboard user's shop
2948
+ * (business profile). The JWT auto-scopes to its own `profile`; an explicit
2949
+ * `profile_id` / `project_id` outside that scope is rejected with
2950
+ * `AccessForbidden`. `GET /customers/profile/list`
2951
+ *
2952
+ * @param params - Optional filter and pagination parameters.
2953
+ * @returns Array of customer objects.
2954
+ */
2955
+ listByProfile(params?: CustomerListParams): Promise<CustomerResponse[]>;
2956
+ /**
2957
+ * Profile-scoped variant of {@link listWithCount}.
2958
+ * `GET /customers/profile/list-with-count`
2959
+ */
2960
+ listByProfileWithCount(params?: CustomerListParams): Promise<{
2961
+ count: number;
2962
+ total_count: number;
2963
+ data: CustomerResponse[];
2964
+ }>;
2925
2965
  /** List mandates for a customer. `GET /customers/{customerId}/mandates` */
2926
2966
  listMandates(customerId: string): Promise<Record<string, unknown>[]>;
2927
2967
  }
@@ -4663,18 +4703,59 @@ declare class DelopayAuthenticationError extends DelopayError {
4663
4703
  });
4664
4704
  }
4665
4705
 
4706
+ /**
4707
+ * The payload of a webhook event, tagged by kind.
4708
+ *
4709
+ * Mirrors the backend's `{ "type": …, "object": … }` envelope: `type` names the
4710
+ * payload shape and `object` carries it. Narrow on `content.type` to get a
4711
+ * fully-typed `object`:
4712
+ *
4713
+ * ```typescript
4714
+ * if (event.content.type === 'payment_details') {
4715
+ * event.content.object.payment_id; // typed as PaymentResponse
4716
+ * }
4717
+ * ```
4718
+ */
4719
+ type WebhookContent = {
4720
+ type: 'payment_details';
4721
+ object: PaymentResponse;
4722
+ } | {
4723
+ type: 'refund_details';
4724
+ object: RefundResponse;
4725
+ } | {
4726
+ type: 'dispute_details';
4727
+ object: DisputeResponse;
4728
+ } | {
4729
+ type: 'mandate_details';
4730
+ object: MandateResponse;
4731
+ } | {
4732
+ type: 'payout_details';
4733
+ object: PayoutResponse;
4734
+ } | {
4735
+ type: 'subscription_details';
4736
+ object: ConfirmSubscriptionResponse;
4737
+ };
4666
4738
  /**
4667
4739
  * A parsed and verified Delopay webhook event.
4668
4740
  *
4669
- * The `type` field identifies the event (e.g. `'payment_succeeded'`).
4670
- * Specific event payload shapes are nested under `data`.
4741
+ * Matches the signed wire body exactly:
4742
+ * `{ merchant_id, event_id, event_type, content: { type, object }, timestamp }`.
4743
+ *
4744
+ * - `event_type` identifies the event, e.g. `'payment_succeeded'`.
4745
+ * - `content.type` tags the payload kind, e.g. `'payment_details'`.
4746
+ * - `content.object` is the payload; narrow on `content.type` to type it.
4671
4747
  */
4672
4748
  interface WebhookEvent {
4749
+ /** ID of the merchant that owns this event. */
4750
+ merchant_id: string;
4751
+ /** Unique ID for this event (stable across delivery retries). */
4752
+ event_id: string;
4673
4753
  /** Event type identifier, e.g. `'payment_succeeded'` or `'refund_succeeded'`. */
4674
- type: string;
4675
- /** Event payload. Shape depends on `type`. */
4676
- data: Record<string, unknown>;
4677
- [key: string]: unknown;
4754
+ event_type: EventType;
4755
+ /** The event payload, tagged by kind. Narrow on `content.type` to type `object`. */
4756
+ content: WebhookContent;
4757
+ /** ISO 8601 timestamp at which the webhook was sent. */
4758
+ timestamp: string;
4678
4759
  }
4679
4760
  declare const Webhooks: {
4680
4761
  /**
@@ -4709,7 +4790,7 @@ declare const Webhooks: {
4709
4790
  * req.header('x-webhook-signature-512') ?? '',
4710
4791
  * process.env.DELOPAY_WEBHOOK_SECRET!,
4711
4792
  * );
4712
- * console.log(event.type, event.data);
4793
+ * console.log(event.event_type, event.content.object);
4713
4794
  * res.sendStatus(200);
4714
4795
  * } catch {
4715
4796
  * res.status(400).send('Invalid signature');
package/dist/index.d.ts CHANGED
@@ -582,6 +582,17 @@ interface CustomerListParams {
582
582
  limit?: number | null;
583
583
  offset?: number | null;
584
584
  email?: string | null;
585
+ /**
586
+ * Filter customers by the shop (business profile) they have transacted in.
587
+ * Membership is derived from `payment_intent` — a customer who never
588
+ * transacted appears under no shop.
589
+ */
590
+ profile_id?: string | null;
591
+ /**
592
+ * Filter customers by project; expands to all shops (business profiles)
593
+ * under that project.
594
+ */
595
+ project_id?: string | null;
585
596
  }
586
597
  interface PaymentMethodCreateRequest {
587
598
  payment_method: PaymentMethod;
@@ -2910,18 +2921,47 @@ declare class Customers {
2910
2921
  */
2911
2922
  delete(customerId: string): Promise<CustomerResponse>;
2912
2923
  /**
2913
- * List customers, optionally filtered by email.
2924
+ * List customers, optionally filtered by email, shop (`profile_id`), or
2925
+ * project (`project_id`).
2914
2926
  *
2915
2927
  * @param params - Optional filter and pagination parameters.
2916
2928
  * @returns Array of customer objects.
2929
+ *
2930
+ * @example
2931
+ * ```typescript
2932
+ * // Customers who have transacted in a specific shop.
2933
+ * const customers = await delopay.customers.list({ profile_id: 'pro_abc123' });
2934
+ * ```
2917
2935
  */
2918
2936
  list(params?: CustomerListParams): Promise<CustomerResponse[]>;
2919
- /** List customers with count. `GET /customers/list-with-count` */
2937
+ /**
2938
+ * List customers with count. Supports the same `profile_id` / `project_id`
2939
+ * shop filters as {@link list}. `GET /customers/list-with-count`
2940
+ */
2920
2941
  listWithCount(params?: CustomerListParams): Promise<{
2921
2942
  count: number;
2922
2943
  total_count: number;
2923
2944
  data: CustomerResponse[];
2924
2945
  }>;
2946
+ /**
2947
+ * List customers scoped to the authenticated dashboard user's shop
2948
+ * (business profile). The JWT auto-scopes to its own `profile`; an explicit
2949
+ * `profile_id` / `project_id` outside that scope is rejected with
2950
+ * `AccessForbidden`. `GET /customers/profile/list`
2951
+ *
2952
+ * @param params - Optional filter and pagination parameters.
2953
+ * @returns Array of customer objects.
2954
+ */
2955
+ listByProfile(params?: CustomerListParams): Promise<CustomerResponse[]>;
2956
+ /**
2957
+ * Profile-scoped variant of {@link listWithCount}.
2958
+ * `GET /customers/profile/list-with-count`
2959
+ */
2960
+ listByProfileWithCount(params?: CustomerListParams): Promise<{
2961
+ count: number;
2962
+ total_count: number;
2963
+ data: CustomerResponse[];
2964
+ }>;
2925
2965
  /** List mandates for a customer. `GET /customers/{customerId}/mandates` */
2926
2966
  listMandates(customerId: string): Promise<Record<string, unknown>[]>;
2927
2967
  }
@@ -4663,18 +4703,59 @@ declare class DelopayAuthenticationError extends DelopayError {
4663
4703
  });
4664
4704
  }
4665
4705
 
4706
+ /**
4707
+ * The payload of a webhook event, tagged by kind.
4708
+ *
4709
+ * Mirrors the backend's `{ "type": …, "object": … }` envelope: `type` names the
4710
+ * payload shape and `object` carries it. Narrow on `content.type` to get a
4711
+ * fully-typed `object`:
4712
+ *
4713
+ * ```typescript
4714
+ * if (event.content.type === 'payment_details') {
4715
+ * event.content.object.payment_id; // typed as PaymentResponse
4716
+ * }
4717
+ * ```
4718
+ */
4719
+ type WebhookContent = {
4720
+ type: 'payment_details';
4721
+ object: PaymentResponse;
4722
+ } | {
4723
+ type: 'refund_details';
4724
+ object: RefundResponse;
4725
+ } | {
4726
+ type: 'dispute_details';
4727
+ object: DisputeResponse;
4728
+ } | {
4729
+ type: 'mandate_details';
4730
+ object: MandateResponse;
4731
+ } | {
4732
+ type: 'payout_details';
4733
+ object: PayoutResponse;
4734
+ } | {
4735
+ type: 'subscription_details';
4736
+ object: ConfirmSubscriptionResponse;
4737
+ };
4666
4738
  /**
4667
4739
  * A parsed and verified Delopay webhook event.
4668
4740
  *
4669
- * The `type` field identifies the event (e.g. `'payment_succeeded'`).
4670
- * Specific event payload shapes are nested under `data`.
4741
+ * Matches the signed wire body exactly:
4742
+ * `{ merchant_id, event_id, event_type, content: { type, object }, timestamp }`.
4743
+ *
4744
+ * - `event_type` identifies the event, e.g. `'payment_succeeded'`.
4745
+ * - `content.type` tags the payload kind, e.g. `'payment_details'`.
4746
+ * - `content.object` is the payload; narrow on `content.type` to type it.
4671
4747
  */
4672
4748
  interface WebhookEvent {
4749
+ /** ID of the merchant that owns this event. */
4750
+ merchant_id: string;
4751
+ /** Unique ID for this event (stable across delivery retries). */
4752
+ event_id: string;
4673
4753
  /** Event type identifier, e.g. `'payment_succeeded'` or `'refund_succeeded'`. */
4674
- type: string;
4675
- /** Event payload. Shape depends on `type`. */
4676
- data: Record<string, unknown>;
4677
- [key: string]: unknown;
4754
+ event_type: EventType;
4755
+ /** The event payload, tagged by kind. Narrow on `content.type` to type `object`. */
4756
+ content: WebhookContent;
4757
+ /** ISO 8601 timestamp at which the webhook was sent. */
4758
+ timestamp: string;
4678
4759
  }
4679
4760
  declare const Webhooks: {
4680
4761
  /**
@@ -4709,7 +4790,7 @@ declare const Webhooks: {
4709
4790
  * req.header('x-webhook-signature-512') ?? '',
4710
4791
  * process.env.DELOPAY_WEBHOOK_SECRET!,
4711
4792
  * );
4712
- * console.log(event.type, event.data);
4793
+ * console.log(event.event_type, event.content.object);
4713
4794
  * res.sendStatus(200);
4714
4795
  * } catch {
4715
4796
  * res.status(400).send('Invalid signature');
package/dist/index.js CHANGED
@@ -49,7 +49,7 @@ import {
49
49
  shadowFor,
50
50
  surfacePadValue,
51
51
  verticalGapValue
52
- } from "./chunk-P45MMRTD.js";
52
+ } from "./chunk-QH5ESES3.js";
53
53
  export {
54
54
  Analytics,
55
55
  AnalyticsDashboard,
package/dist/internal.cjs CHANGED
@@ -537,10 +537,17 @@ var Customers = class {
537
537
  return this.request("DELETE", `/customers/${encodeURIComponent(customerId)}`);
538
538
  }
539
539
  /**
540
- * List customers, optionally filtered by email.
540
+ * List customers, optionally filtered by email, shop (`profile_id`), or
541
+ * project (`project_id`).
541
542
  *
542
543
  * @param params - Optional filter and pagination parameters.
543
544
  * @returns Array of customer objects.
545
+ *
546
+ * @example
547
+ * ```typescript
548
+ * // Customers who have transacted in a specific shop.
549
+ * const customers = await delopay.customers.list({ profile_id: 'pro_abc123' });
550
+ * ```
544
551
  */
545
552
  async list(params) {
546
553
  return this.request("GET", "/customers/list", {
@@ -548,12 +555,38 @@ var Customers = class {
548
555
  });
549
556
  }
550
557
  // --- OLAP extensions (Task 4.6) ---
551
- /** List customers with count. `GET /customers/list-with-count` */
558
+ /**
559
+ * List customers with count. Supports the same `profile_id` / `project_id`
560
+ * shop filters as {@link list}. `GET /customers/list-with-count`
561
+ */
552
562
  async listWithCount(params) {
553
563
  return this.request("GET", "/customers/list-with-count", {
554
564
  query: params
555
565
  });
556
566
  }
567
+ /**
568
+ * List customers scoped to the authenticated dashboard user's shop
569
+ * (business profile). The JWT auto-scopes to its own `profile`; an explicit
570
+ * `profile_id` / `project_id` outside that scope is rejected with
571
+ * `AccessForbidden`. `GET /customers/profile/list`
572
+ *
573
+ * @param params - Optional filter and pagination parameters.
574
+ * @returns Array of customer objects.
575
+ */
576
+ async listByProfile(params) {
577
+ return this.request("GET", "/customers/profile/list", {
578
+ query: params
579
+ });
580
+ }
581
+ /**
582
+ * Profile-scoped variant of {@link listWithCount}.
583
+ * `GET /customers/profile/list-with-count`
584
+ */
585
+ async listByProfileWithCount(params) {
586
+ return this.request("GET", "/customers/profile/list-with-count", {
587
+ query: params
588
+ });
589
+ }
557
590
  /** List mandates for a customer. `GET /customers/{customerId}/mandates` */
558
591
  async listMandates(customerId) {
559
592
  return this.request("GET", `/customers/${encodeURIComponent(customerId)}/mandates`);
@@ -1172,11 +1205,7 @@ var Payments = class {
1172
1205
  * ```
1173
1206
  */
1174
1207
  async listAttempts(paymentId, options) {
1175
- return this.request(
1176
- "GET",
1177
- `/payments/${encodeURIComponent(paymentId)}/attempts`,
1178
- options
1179
- );
1208
+ return this.request("GET", `/payments/${encodeURIComponent(paymentId)}/attempts`, options);
1180
1209
  }
1181
1210
  /**
1182
1211
  * Update an existing payment intent before it is confirmed.
@@ -2521,7 +2550,7 @@ var Webhooks = {
2521
2550
  * req.header('x-webhook-signature-512') ?? '',
2522
2551
  * process.env.DELOPAY_WEBHOOK_SECRET!,
2523
2552
  * );
2524
- * console.log(event.type, event.data);
2553
+ * console.log(event.event_type, event.content.object);
2525
2554
  * res.sendStatus(200);
2526
2555
  * } catch {
2527
2556
  * res.status(400).send('Invalid signature');