@@ -2,20 +2,13 @@ import * as NodeCrypto from "node:crypto";
22
33import type { RelayAgentActivityAggregateState } from "@t3tools/contracts/relay" ;
44import * as Context from "effect/Context" ;
5- import * as Data from "effect/Data" ;
65import * as Effect from "effect/Effect" ;
76import * as Encoding from "effect/Encoding" ;
87import * as Layer from "effect/Layer" ;
98import * as Option from "effect/Option" ;
109import * as Redacted from "effect/Redacted" ;
1110import * as Schema from "effect/Schema" ;
12- import {
13- Headers ,
14- HttpClient ,
15- HttpClientRequest ,
16- type HttpBody ,
17- type HttpClientError ,
18- } from "effect/unstable/http" ;
11+ import { Headers , HttpClient , HttpClientRequest } from "effect/unstable/http" ;
1912import type { ApnsCredentials } from "../Config.ts" ;
2013import type { ApnsNotificationPayload } from "./apnsDeliveryJobs.ts" ;
2114
@@ -45,18 +38,39 @@ export interface ApnsDeliveryResult {
4538 readonly apnsId : string | null ;
4639}
4740
48- export class ApnsSigningError extends Data . TaggedError ( "ApnsSigningError" ) < {
49- readonly phase : "encoding" | "signing" ;
50- readonly cause : unknown ;
51- } > { }
41+ export class ApnsSigningError extends Schema . TaggedErrorClass < ApnsSigningError > ( ) (
42+ "ApnsSigningError" ,
43+ {
44+ phase : Schema . Literals ( [ "encoding" , "signing" ] ) ,
45+ cause : Schema . Defect ( ) ,
46+ } ,
47+ ) {
48+ override get message ( ) : string {
49+ return `Failed during APNs JWT ${ this . phase } ` ;
50+ }
51+ }
5252
53- export class ApnsHttpRequestError extends Data . TaggedError ( "ApnsHttpRequestError" ) < {
54- readonly cause : HttpClientError . HttpClientError | HttpBody . HttpBodyError ;
55- } > { }
53+ export class ApnsHttpRequestError extends Schema . TaggedErrorClass < ApnsHttpRequestError > ( ) (
54+ "ApnsHttpRequestError" ,
55+ {
56+ cause : Schema . Defect ( ) ,
57+ } ,
58+ ) {
59+ override get message ( ) : string {
60+ return "APNs HTTP request failed" ;
61+ }
62+ }
5663
57- export class ApnsInvalidResponseError extends Data . TaggedError ( "ApnsInvalidResponseError" ) < {
58- readonly cause : unknown ;
59- } > { }
64+ export class ApnsInvalidResponseError extends Schema . TaggedErrorClass < ApnsInvalidResponseError > ( ) (
65+ "ApnsInvalidResponseError" ,
66+ {
67+ cause : Schema . Defect ( ) ,
68+ } ,
69+ ) {
70+ override get message ( ) : string {
71+ return "APNs returned an invalid response" ;
72+ }
73+ }
6074
6175export type ApnsError = ApnsSigningError | ApnsHttpRequestError | ApnsInvalidResponseError ;
6276
0 commit comments