@delopay/sdk 0.290.0 → 0.292.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/internal.cjs CHANGED
@@ -3659,15 +3659,21 @@ var Projects = class {
3659
3659
  this.request = request;
3660
3660
  }
3661
3661
  /**
3662
- * Create a new project under a merchant account.
3662
+ * Create a new project under a merchant account. Pass `parent_id` to create
3663
+ * it as a sub-project; past the merchant's maximum depth it is refused with
3664
+ * `400` and code `PR_01` (`project_depth_exceeded`).
3663
3665
  *
3664
- * @param params - Project creation parameters (name, description, etc.).
3666
+ * @param params - Project creation parameters (name, description, parent).
3665
3667
  * @param merchantId - The merchant account ID that owns this project.
3666
3668
  * @returns The created project.
3667
3669
  *
3668
3670
  * @example
3669
3671
  * ```typescript
3670
- * const project = await delopay.projects.create({ name: 'EU Stores' }, 'merch_123');
3672
+ * const eu = await delopay.projects.create({ project_name: 'EU Stores' }, 'merch_123');
3673
+ * const de = await delopay.projects.create(
3674
+ * { project_name: 'Germany', parent_id: eu.id },
3675
+ * 'merch_123',
3676
+ * );
3671
3677
  * ```
3672
3678
  */
3673
3679
  async create(params, merchantId) {
@@ -3692,7 +3698,14 @@ var Projects = class {
3692
3698
  return this.request("GET", path, { query: { merchant_id: merchantId } });
3693
3699
  }
3694
3700
  /**
3695
- * Update a project's details.
3701
+ * Update a project's details, or move it with `parent_id` (omitted keeps the
3702
+ * parent, `null` makes it a top-level project, an id moves it under that
3703
+ * project). A move is refused with `PR_01` when the moved subtree would
3704
+ * exceed the maximum depth and with `PR_02` (`project_cycle`) when the target
3705
+ * is the project itself or one of its sub-projects. When the merchant's
3706
+ * project tree changed while the move was being checked, it is refused with
3707
+ * `409` and code `PR_05` (`project_tree_changed`): read the tree again and
3708
+ * retry.
3696
3709
  *
3697
3710
  * @param projectId - The project ID to update.
3698
3711
  * @param params - Fields to update.
@@ -3708,6 +3721,9 @@ var Projects = class {
3708
3721
  * Delete a project.
3709
3722
  *
3710
3723
  * @param projectId - The project ID to delete.
3724
+ * Refused with `409` and code `PR_03` (`project_not_empty`) while the
3725
+ * project still has sub-projects or shops; move or delete those first.
3726
+ *
3711
3727
  * @param merchantId - Optional merchant scope. See {@link Projects.retrieve}.
3712
3728
  * @returns The deleted project object.
3713
3729
  */
@@ -3717,7 +3733,9 @@ var Projects = class {
3717
3733
  return this.request("DELETE", path, { query: { merchant_id: merchantId } });
3718
3734
  }
3719
3735
  /**
3720
- * List all projects for a merchant.
3736
+ * List all projects for a merchant, at every level, as a flat array. Rebuild
3737
+ * the tree from each project's `parent_id`; `level`, `path`,
3738
+ * `child_project_count` and `direct_shop_count` are filled in for each one.
3721
3739
  *
3722
3740
  * @param merchantId - The merchant account ID.
3723
3741
  * @returns Array of projects.
@@ -3730,6 +3748,11 @@ var Projects = class {
3730
3748
  /**
3731
3749
  * Get aggregate payment statistics across all projects for a merchant.
3732
3750
  *
3751
+ * Each project's figures cover its whole subtree (its own shops and the
3752
+ * shops of its sub-projects); `projects[].direct` holds the figures for the
3753
+ * project's own shops only, and `projects[].shops[]` lists only those. The
3754
+ * merchant totals count each shop once.
3755
+ *
3733
3756
  * The response's flat `shops[]` array holds every shop, including shops that
3734
3757
  * belong to no project — those are absent from `projects[].shops[]`, so look
3735
3758
  * a single shop up in `shops[]`. Requires `MerchantAccountRead`; a
@@ -3751,6 +3774,26 @@ var Projects = class {
3751
3774
  if (period !== void 0) query["period"] = String(period);
3752
3775
  return this.request("GET", "/projects/stats", { query });
3753
3776
  }
3777
+ /**
3778
+ * Get the project-depth limit that applies to a merchant: the maximum number
3779
+ * of project levels, where that limit comes from, and how deep the
3780
+ * merchant's tree currently is. Use it to tell whether a project can take a
3781
+ * sub-project (`project.level < max_depth`) before offering the action.
3782
+ *
3783
+ * @param merchantId - The merchant account ID.
3784
+ * @returns The merchant's project limits.
3785
+ *
3786
+ * @example
3787
+ * ```typescript
3788
+ * const { max_depth } = await delopay.projects.limits('merch_123');
3789
+ * const canNest = project.level < max_depth;
3790
+ * ```
3791
+ */
3792
+ async limits(merchantId) {
3793
+ return this.request("GET", "/projects/limits", {
3794
+ query: { merchant_id: merchantId }
3795
+ });
3796
+ }
3754
3797
  /**
3755
3798
  * Get a high-level overview (volume, counts, top connectors) for a merchant.
3756
3799
  *