@remit/data-ports 0.0.50 → 0.0.51

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remit/data-ports",
3
- "version": "0.0.50",
3
+ "version": "0.0.51",
4
4
  "type": "module",
5
5
  "main": "src/index.ts",
6
6
  "types": "src/index.ts",
package/src/errors.ts CHANGED
@@ -122,6 +122,23 @@ export class MessagePlacementUnsettledError extends ConflictError {
122
122
  }
123
123
  }
124
124
 
125
+ /**
126
+ * A configuration import refused because this configuration is not empty
127
+ * (#1021). The default is to refuse rather than to fold the file in: a person
128
+ * importing over a configuration they forgot they had should hear about it
129
+ * before anything moves. `details` counts what is already here, so the client
130
+ * can say what would be merged, and the same request with `onExisting: merge`
131
+ * goes through.
132
+ */
133
+ export class ConfigNotEmptyError extends ConflictError {
134
+ name = "ConfigNotEmptyError";
135
+
136
+ constructor(message: string, details: Record<string, string>) {
137
+ super(message);
138
+ this.publicApiError = { code: "config_not_empty", details };
139
+ }
140
+ }
141
+
125
142
  /**
126
143
  * A message exists but its body could not be fetched/parsed after every
127
144
  * body-sync retry was spent (issue #1270 / epic #1281 invariant 3). This is
@@ -0,0 +1,20 @@
1
+ import { FilterScope } from "@remit/domain-enums";
2
+ import { BadRequestError } from "./errors.js";
3
+
4
+ /**
5
+ * Epoch-seconds `ttl` derived from `expiresAt`, set only for a `Temporary`
6
+ * filter (RFC 034 Decision 1.3). A `Standing` filter never carries `ttl` — the
7
+ * reserved table-wide TTL attribute must stay absent, or the row would be swept
8
+ * (Decision 1.4).
9
+ */
10
+ export const deriveFilterTtl = (
11
+ scope: string,
12
+ expiresAt: string | undefined,
13
+ ): number | undefined => {
14
+ if (scope !== FilterScope.Temporary || !expiresAt) return undefined;
15
+ const ms = new Date(expiresAt).getTime();
16
+ if (Number.isNaN(ms)) {
17
+ throw new BadRequestError(`Invalid expiresAt: ${expiresAt}`);
18
+ }
19
+ return Math.floor(ms / 1000);
20
+ };
package/src/index.ts CHANGED
@@ -1,8 +1,10 @@
1
+ export { deriveFilterTtl } from "./filter-ttl.js";
1
2
  export type { IAccountRepository } from "./interfaces/account.js";
2
3
  export type { IAccountConfigRepository } from "./interfaces/account-config.js";
3
4
  export type { IAccountExportRequestRepository } from "./interfaces/account-export-request.js";
4
5
  export type { IAccountSettingRepository } from "./interfaces/account-setting.js";
5
6
  export type { IAddressRepository } from "./interfaces/address.js";
7
+ export type { IConfigImportRepository } from "./interfaces/config-import.js";
6
8
  export type { IEnvelopeRepository } from "./interfaces/envelope.js";
7
9
  export type { IFilterRepository } from "./interfaces/filter.js";
8
10
  export type { IFilterAnchorRepository } from "./interfaces/filter-anchor.js";
@@ -55,10 +57,13 @@ export type {
55
57
  BodyPartParameterUpsertInput,
56
58
  BodyPartStorageItem,
57
59
  BodyPartUpsertInput,
60
+ ConfigImportItem,
61
+ ConfigImportUnresolvedRefItem,
58
62
  CreateAccountConfigInput,
59
63
  CreateAccountExportRequestInput,
60
64
  CreateAccountInput,
61
65
  CreateAddressInput,
66
+ CreateConfigImportInput,
62
67
  CreateEnvelopeAddressInput,
63
68
  CreateEnvelopeInput,
64
69
  CreateFilterAnchorInput,
@@ -109,6 +114,7 @@ export type {
109
114
  UpdateAccountExportRequestInput,
110
115
  UpdateAccountInput,
111
116
  UpdateAddressInput,
117
+ UpdateConfigImportInput,
112
118
  UpdateEnvelopeInput,
113
119
  UpdateFilterInput,
114
120
  UpdateLabelInput,
@@ -0,0 +1,16 @@
1
+ import type {
2
+ ConfigImportItem,
3
+ CreateConfigImportInput,
4
+ UpdateConfigImportInput,
5
+ } from "../types.js";
6
+
7
+ export interface IConfigImportRepository {
8
+ create(input: CreateConfigImportInput): Promise<ConfigImportItem>;
9
+ get(importId: string): Promise<ConfigImportItem>;
10
+ update(
11
+ importId: string,
12
+ input: UpdateConfigImportInput,
13
+ ): Promise<ConfigImportItem>;
14
+ /** Newest first, so the caller reads the import a person just ran. */
15
+ listByAccountConfig(accountConfigId: string): Promise<ConfigImportItem[]>;
16
+ }
package/src/types.ts CHANGED
@@ -6,6 +6,8 @@ import type {
6
6
  BodyPartParameterSchema,
7
7
  BodyPartSchema,
8
8
  BodyPartStorageSchema,
9
+ ConfigImportSchema,
10
+ ConfigImportUnresolvedRefSchema,
9
11
  EnvelopeAddressSchema,
10
12
  EnvelopeSchema,
11
13
  FilterAnchorSchema,
@@ -256,6 +258,23 @@ export type UpdateOrganizeJobRequestInput = Partial<
256
258
  >
257
259
  >;
258
260
 
261
+ export type ConfigImportItem = z.infer<typeof ConfigImportSchema>;
262
+ export type ConfigImportUnresolvedRefItem = z.infer<
263
+ typeof ConfigImportUnresolvedRefSchema
264
+ >;
265
+
266
+ export type CreateConfigImportInput = Omit<
267
+ ConfigImportItem,
268
+ "importId" | "createdAt" | "updatedAt" | "state" | "completedAt"
269
+ > & {
270
+ state?: ConfigImportItem["state"];
271
+ completedAt?: ConfigImportItem["completedAt"];
272
+ };
273
+
274
+ export type UpdateConfigImportInput = Partial<
275
+ Pick<ConfigImportItem, "state" | "unresolvedRefs" | "completedAt">
276
+ >;
277
+
259
278
  export type UpsertAccountSettingInput = {
260
279
  accountConfigId: string;
261
280
  name: string;