@remit/data-ports 0.0.87 → 0.0.88
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/account-config.d.ts +11 -0
- package/dist/account-config.js +24 -0
- package/dist/errors.d.ts +11 -0
- package/dist/errors.js +14 -0
- package/dist/interfaces/outbox-message.d.ts +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { AccountConfigItem, CreateAccountConfigInput } from "./types.js";
|
|
2
|
+
export interface AccountConfigCreator {
|
|
3
|
+
get: (accountConfigId: string) => Promise<AccountConfigItem>;
|
|
4
|
+
create: (input: CreateAccountConfigInput) => Promise<AccountConfigItem>;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* The one way an AccountConfig row comes into being. Its id is derived from the
|
|
8
|
+
* caller's identity, so the row is its own owner: `userId` is the id itself,
|
|
9
|
+
* whichever path materializes it first.
|
|
10
|
+
*/
|
|
11
|
+
export declare const ensureAccountConfig: (accountConfig: AccountConfigCreator, accountConfigId: string) => Promise<AccountConfigItem>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ConflictError, NotFoundError } from "./errors.js";
|
|
2
|
+
/**
|
|
3
|
+
* The one way an AccountConfig row comes into being. Its id is derived from the
|
|
4
|
+
* caller's identity, so the row is its own owner: `userId` is the id itself,
|
|
5
|
+
* whichever path materializes it first.
|
|
6
|
+
*/
|
|
7
|
+
export const ensureAccountConfig = async (accountConfig, accountConfigId) => {
|
|
8
|
+
const existing = await accountConfig
|
|
9
|
+
.get(accountConfigId)
|
|
10
|
+
.catch((err) => {
|
|
11
|
+
if (err instanceof NotFoundError)
|
|
12
|
+
return undefined;
|
|
13
|
+
throw err;
|
|
14
|
+
});
|
|
15
|
+
if (existing)
|
|
16
|
+
return existing;
|
|
17
|
+
return accountConfig
|
|
18
|
+
.create({ accountConfigId, userId: accountConfigId })
|
|
19
|
+
.catch((err) => {
|
|
20
|
+
if (err instanceof ConflictError)
|
|
21
|
+
return accountConfig.get(accountConfigId);
|
|
22
|
+
throw err;
|
|
23
|
+
});
|
|
24
|
+
};
|
package/dist/errors.d.ts
CHANGED
|
@@ -108,6 +108,17 @@ export declare class UnrecoverableBodyError extends HTTPError {
|
|
|
108
108
|
name: string;
|
|
109
109
|
statusCode: number;
|
|
110
110
|
}
|
|
111
|
+
/**
|
|
112
|
+
* The host refused the work because a quota or platform limit was reached. The
|
|
113
|
+
* host decides what counts: its port adapters translate their platform's limit
|
|
114
|
+
* errors into this one, so the shared mapping answers 429 without reading a
|
|
115
|
+
* message. The message is the host's, written for the person who hit the limit.
|
|
116
|
+
*/
|
|
117
|
+
export declare class HostRefusedError extends HTTPError {
|
|
118
|
+
name: string;
|
|
119
|
+
statusCode: number;
|
|
120
|
+
constructor(message: string, cause: unknown);
|
|
121
|
+
}
|
|
111
122
|
export declare class CreateFailedConflictError extends ConflictError {
|
|
112
123
|
statusCode: number;
|
|
113
124
|
name: string;
|
package/dist/errors.js
CHANGED
|
@@ -124,6 +124,20 @@ export class UnrecoverableBodyError extends HTTPError {
|
|
|
124
124
|
name = "UnrecoverableBodyError";
|
|
125
125
|
statusCode = 422;
|
|
126
126
|
}
|
|
127
|
+
/**
|
|
128
|
+
* The host refused the work because a quota or platform limit was reached. The
|
|
129
|
+
* host decides what counts: its port adapters translate their platform's limit
|
|
130
|
+
* errors into this one, so the shared mapping answers 429 without reading a
|
|
131
|
+
* message. The message is the host's, written for the person who hit the limit.
|
|
132
|
+
*/
|
|
133
|
+
export class HostRefusedError extends HTTPError {
|
|
134
|
+
name = "HostRefusedError";
|
|
135
|
+
statusCode = 429;
|
|
136
|
+
constructor(message, cause) {
|
|
137
|
+
super(message, { cause });
|
|
138
|
+
this.publicApiError = { code: "request_refused" };
|
|
139
|
+
}
|
|
140
|
+
}
|
|
127
141
|
export class CreateFailedConflictError extends ConflictError {
|
|
128
142
|
statusCode = 409;
|
|
129
143
|
name = "CreateFailedConflictError";
|
|
@@ -48,7 +48,7 @@ export interface IOutboxMessageRepository {
|
|
|
48
48
|
updateIfStatus(accountConfigId: string, outboxMessageId: string, expected: OutboxMessageItem["status"], input: UpdateOutboxMessageInput): Promise<OutboxMessageItem | null>;
|
|
49
49
|
markSent(accountConfigId: string, outboxMessageId: string, fields: {
|
|
50
50
|
sentAt: number;
|
|
51
|
-
smtpMessageId?: string;
|
|
51
|
+
smtpMessageId?: string | undefined;
|
|
52
52
|
}): Promise<OutboxMessageItem>;
|
|
53
53
|
delete(accountConfigId: string, outboxMessageId: string): Promise<void>;
|
|
54
54
|
deleteMany(accountConfigId: string, outboxMessageIds: string[]): Promise<void>;
|