@nauticana/sail 1.1.25 → 1.1.27

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.
@@ -8,13 +8,10 @@ import { UserPaymentMethod } from '../model/appdata';
8
8
  /**
9
9
  * UserPaymentMethodService — consumer-side saved-payment-methods API.
10
10
  *
11
- * list and delete go through keel's generic REST CRUD against the
12
- * basis user_payment_method table — that table is UserSpecific (FK
13
- * column `user_id`), so the auto-filter scopes reads + owner-locks
14
- * DELETE without any custom server-side glue. setDefault has a custom
15
- * endpoint because it needs an atomic multi-row UPDATE
16
- * (`SET is_default = (id = ?) WHERE user_id = session`) that abstract
17
- * single-row CRUD can't express.
11
+ * list goes through keel's generic REST CRUD against the UserSpecific basis
12
+ * user_payment_method table. remove and setDefault are keel table actions:
13
+ * remove detaches the method at the provider before deleting the row, so keel
14
+ * grants no generic DELETE on the table.
18
15
  */
19
16
  @Injectable({ providedIn: 'root' })
20
17
  export class UserPaymentMethodService extends BaseRestService {
@@ -29,15 +26,12 @@ export class UserPaymentMethodService extends BaseRestService {
29
26
  return this.backend.list<UserPaymentMethod>('user_payment_method');
30
27
  }
31
28
 
32
- /** Delete a saved payment method. user_id is auto-scoped by keel. */
33
- delete(id: number): Observable<{ message: string }> {
34
- return this.backend.delete('user_payment_method', { Id: String(id) });
29
+ /** Detach a saved payment method at the provider and delete it. */
30
+ remove(id: number): Observable<{ message: string }> {
31
+ return this.http.post<{ message: string }>(this.url(RestURL.paymentMethodRemoveURL), { id });
35
32
  }
36
33
 
37
- /**
38
- * Mark one row as default; clears every other row in the same call.
39
- * Custom endpoint — see service-class doc for the rationale.
40
- */
34
+ /** Mark one row as default; clears every other row in the same call. */
41
35
  setDefault(id: number): Observable<{ message: string }> {
42
36
  return this.http.post<{ message: string }>(this.url(RestURL.paymentMethodSetDefaultURL), { id });
43
37
  }
@@ -31,6 +31,11 @@ export function isTransportFailure(err: unknown): boolean {
31
31
  return statusOf(err) === 0;
32
32
  }
33
33
 
34
+ /** True for keel's 403: the session is valid but lacks the grant for this action. */
35
+ export function isPermissionDenied(err: unknown): boolean {
36
+ return statusOf(err) === 403;
37
+ }
38
+
34
39
  /**
35
40
  * Human-readable message from any sail error shape — SailApiError (BackendService),
36
41
  * raw HttpErrorResponse (direct HttpClient calls), or plain Error.