@remit/drizzle-service 0.0.58 → 0.0.59
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 +1 -1
- package/src/repos/i4-address.test.ts +12 -12
- package/src/repos/i4-address.ts +9 -10
package/package.json
CHANGED
|
@@ -148,7 +148,6 @@ describe("AddressRepo", () => {
|
|
|
148
148
|
});
|
|
149
149
|
|
|
150
150
|
const ea = await repo.createEnvelopeAddress({
|
|
151
|
-
envelopeAddressId: envId,
|
|
152
151
|
messageId,
|
|
153
152
|
addressId,
|
|
154
153
|
normalizedEmail: "test@example.com",
|
|
@@ -170,7 +169,6 @@ describe("AddressRepo", () => {
|
|
|
170
169
|
test("upsertEnvelopeAddress is idempotent", async () => {
|
|
171
170
|
const messageId = randomUUID();
|
|
172
171
|
const input = {
|
|
173
|
-
envelopeAddressId: envelopeAddressId(messageId, "to", 1),
|
|
174
172
|
messageId,
|
|
175
173
|
addressId: randomUUID(),
|
|
176
174
|
normalizedEmail: "x@example.com",
|
|
@@ -179,15 +177,18 @@ describe("AddressRepo", () => {
|
|
|
179
177
|
};
|
|
180
178
|
const first = await repo.upsertEnvelopeAddress(input);
|
|
181
179
|
const second = await repo.upsertEnvelopeAddress(input);
|
|
182
|
-
assert.equal(
|
|
180
|
+
assert.equal(
|
|
181
|
+
first.envelopeAddressId,
|
|
182
|
+
envelopeAddressId(messageId, "to", 1),
|
|
183
|
+
);
|
|
184
|
+
assert.equal(second.envelopeAddressId, first.envelopeAddressId);
|
|
183
185
|
|
|
184
|
-
await repo.deleteEnvelopeAddress(
|
|
186
|
+
await repo.deleteEnvelopeAddress(first.envelopeAddressId);
|
|
185
187
|
});
|
|
186
188
|
|
|
187
189
|
test("deleteManyEnvelopeAddresses removes in batch", async () => {
|
|
188
190
|
const messageId = randomUUID();
|
|
189
191
|
const ea1 = {
|
|
190
|
-
envelopeAddressId: envelopeAddressId(messageId, "from", 0),
|
|
191
192
|
messageId,
|
|
192
193
|
addressId: randomUUID(),
|
|
193
194
|
normalizedEmail: "a@x.com",
|
|
@@ -196,22 +197,21 @@ describe("AddressRepo", () => {
|
|
|
196
197
|
};
|
|
197
198
|
const ea2 = {
|
|
198
199
|
...ea1,
|
|
199
|
-
envelopeAddressId: envelopeAddressId(messageId, "to", 1),
|
|
200
200
|
addressRole: "to" as const,
|
|
201
201
|
addressOrder: 1,
|
|
202
202
|
};
|
|
203
203
|
|
|
204
|
-
await repo.createEnvelopeAddress(ea1);
|
|
205
|
-
await repo.createEnvelopeAddress(ea2);
|
|
204
|
+
const created1 = await repo.createEnvelopeAddress(ea1);
|
|
205
|
+
const created2 = await repo.createEnvelopeAddress(ea2);
|
|
206
206
|
|
|
207
207
|
await repo.deleteManyEnvelopeAddresses([
|
|
208
|
-
|
|
209
|
-
|
|
208
|
+
created1.envelopeAddressId,
|
|
209
|
+
created2.envelopeAddressId,
|
|
210
210
|
]);
|
|
211
211
|
|
|
212
212
|
const results = await repo.getEnvelopeAddress([
|
|
213
|
-
|
|
214
|
-
|
|
213
|
+
created1.envelopeAddressId,
|
|
214
|
+
created2.envelopeAddressId,
|
|
215
215
|
]);
|
|
216
216
|
assert.equal(results.length, 0);
|
|
217
217
|
});
|
package/src/repos/i4-address.ts
CHANGED
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
} from "drizzle-orm";
|
|
24
24
|
import type { Db } from "../db.js";
|
|
25
25
|
import { NotFoundError } from "../error.js";
|
|
26
|
-
import { envelopeAddressId
|
|
26
|
+
import { envelopeAddressId } from "../id.js";
|
|
27
27
|
import { decodeToken, resultList } from "../pagination.js";
|
|
28
28
|
import {
|
|
29
29
|
JUNK_ONLY_FLAG,
|
|
@@ -744,15 +744,14 @@ export class AddressRepo implements IAddressRepository {
|
|
|
744
744
|
input: CreateEnvelopeAddressInput,
|
|
745
745
|
): Promise<EnvelopeAddressItem> {
|
|
746
746
|
const now = Date.now();
|
|
747
|
-
const envelopeAddressId = deriveEnvelopeAddressId(
|
|
748
|
-
input.messageId,
|
|
749
|
-
input.addressRole,
|
|
750
|
-
input.addressOrder,
|
|
751
|
-
);
|
|
752
747
|
const [row] = await this.db
|
|
753
748
|
.insert(envelopeAddressTable)
|
|
754
749
|
.values({
|
|
755
|
-
envelopeAddressId
|
|
750
|
+
envelopeAddressId: envelopeAddressId(
|
|
751
|
+
input.messageId,
|
|
752
|
+
input.addressRole,
|
|
753
|
+
input.addressOrder,
|
|
754
|
+
),
|
|
756
755
|
messageId: input.messageId,
|
|
757
756
|
addressId: input.addressId,
|
|
758
757
|
displayName: input.displayName,
|
|
@@ -770,7 +769,7 @@ export class AddressRepo implements IAddressRepository {
|
|
|
770
769
|
input: CreateEnvelopeAddressInput,
|
|
771
770
|
): Promise<EnvelopeAddressItem> {
|
|
772
771
|
const now = Date.now();
|
|
773
|
-
const
|
|
772
|
+
const rowId = envelopeAddressId(
|
|
774
773
|
input.messageId,
|
|
775
774
|
input.addressRole,
|
|
776
775
|
input.addressOrder,
|
|
@@ -778,7 +777,7 @@ export class AddressRepo implements IAddressRepository {
|
|
|
778
777
|
const [row] = await this.db
|
|
779
778
|
.insert(envelopeAddressTable)
|
|
780
779
|
.values({
|
|
781
|
-
envelopeAddressId,
|
|
780
|
+
envelopeAddressId: rowId,
|
|
782
781
|
messageId: input.messageId,
|
|
783
782
|
addressId: input.addressId,
|
|
784
783
|
displayName: input.displayName,
|
|
@@ -791,7 +790,7 @@ export class AddressRepo implements IAddressRepository {
|
|
|
791
790
|
.onConflictDoNothing()
|
|
792
791
|
.returning();
|
|
793
792
|
if (!row) {
|
|
794
|
-
return this.getEnvelopeAddress(
|
|
793
|
+
return this.getEnvelopeAddress(rowId);
|
|
795
794
|
}
|
|
796
795
|
return rowToEnvelopeAddress(row);
|
|
797
796
|
}
|