From b0a72342f74a9c29b26bed9ef9fe43a4b1e2d623 Mon Sep 17 00:00:00 2001 From: Sophia Hage Date: Thu, 16 May 2024 16:49:13 +0200 Subject: [PATCH 1/4] feat!: :boom: add new required sender to createBatch --- src/PrintOne.ts | 1 + src/models/Batch.ts | 1 + test/Batch.spec.ts | 11 +++++++++++ 3 files changed, 13 insertions(+) diff --git a/src/PrintOne.ts b/src/PrintOne.ts index 3547350..78b8e6e 100644 --- a/src/PrintOne.ts +++ b/src/PrintOne.ts @@ -411,6 +411,7 @@ export class PrintOne { templateId: templateId, finish: data.finish, ready: ready ? ready : null, + sender: data.sender, }); return new Batch(this.protected, response); diff --git a/src/models/Batch.ts b/src/models/Batch.ts index bb1434d..18ea920 100644 --- a/src/models/Batch.ts +++ b/src/models/Batch.ts @@ -17,6 +17,7 @@ export type CreateBatch = { template: string | Template; finish: Finish; ready?: Date | boolean; + sender: Address; }; export type CreateBatchOrder = { diff --git a/test/Batch.spec.ts b/test/Batch.spec.ts index d67823d..fd1dca5 100644 --- a/test/Batch.spec.ts +++ b/test/Batch.spec.ts @@ -1,4 +1,5 @@ import { + Address, Batch, CreateBatchCsvOrder, CsvOrder, @@ -17,6 +18,14 @@ import { sleep } from "../src/utils"; let batch: Batch = null as unknown as Batch; let template: Template = null as unknown as Template; +const address: Address = { + name: "Jane Doe", + address: "123 Main Street", + postalCode: "1234 AB", + city: "Somecity", + country: "NL", +}; + beforeAll(async function () { template = await client.createTemplate({ name: `Test Order ${new Date().toISOString().replaceAll(":", "-")}`, @@ -31,6 +40,7 @@ beforeEach(async function () { template: template, name: `Test Batch ${new Date().toISOString().replaceAll(":", "-")}`, finish: Finish.GLOSSY, + sender: address, }); }); @@ -347,6 +357,7 @@ describe("getOrder", function () { template: template, name: `Test Batch ${new Date().toISOString().replaceAll(":", "-")}`, finish: Finish.GLOSSY, + sender: address, }); const order = await batch2.createOrder({ recipient: { From a5b4b6ac1777c8258ef1f9f63e1f66897b3e5a00 Mon Sep 17 00:00:00 2001 From: UnderKoen Date: Wed, 22 May 2024 11:47:00 +0200 Subject: [PATCH 2/4] chore: fix tests --- package.json | 2 +- package.scripts.js | 1 + src/models/Batch.ts | 5 ++++- test/Batch.spec.ts | 2 +- test/CsvOrder.spec.ts | 4 +++- test/PrintOne.spec.ts | 16 ++++++++++++---- 6 files changed, 22 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 412c21f..a0dfb84 100644 --- a/package.json +++ b/package.json @@ -18,8 +18,8 @@ "build": "bsm", "clean": "bsm", "format": "bsm", - "lint": "bsm", "postinstall": "bsm", + "lint": "bsm", "prepublishOnly": "bsm build", "semantic-release": "semantic-release", "setup": "bsm build", diff --git a/package.scripts.js b/package.scripts.js index a938552..319c991 100644 --- a/package.scripts.js +++ b/package.scripts.js @@ -14,6 +14,7 @@ module.exports = { _default: "bsm ~.*", eslint: "eslint .", prettier: "prettier -c .", + typescript: "tsc --noEmit", }, postinstall: ["ts-patch install"], test: { diff --git a/src/models/Batch.ts b/src/models/Batch.ts index e804160..8d9c20b 100644 --- a/src/models/Batch.ts +++ b/src/models/Batch.ts @@ -188,7 +188,10 @@ export class Batch { * @throws { PrintOneError } If the order could not be found. */ public async getCsvOrder(id: string): Promise { - return this._protected.printOne.getCsvOrder(id, `batches/${this.id}`); + return this._protected.printOne.getCsvOrder( + id, + `batches/${this.id}/orders`, + ); } /** diff --git a/test/Batch.spec.ts b/test/Batch.spec.ts index fd1dca5..e6557c9 100644 --- a/test/Batch.spec.ts +++ b/test/Batch.spec.ts @@ -435,7 +435,7 @@ describe("BatchOrder", function () { // assert expect(order.status).toEqual("order_cancelled"); - }); + }, 30000); it("should be able to refresh Order", async function () { // arrange diff --git a/test/CsvOrder.spec.ts b/test/CsvOrder.spec.ts index ea4c493..8a03b14 100644 --- a/test/CsvOrder.spec.ts +++ b/test/CsvOrder.spec.ts @@ -68,7 +68,9 @@ describe("getTemplate", function () { describe("refresh", function () { it("should refresh the csv order", async function () { // precondition - expect(order.status).toEqual(CsvStatus.order_created); + if (order.status !== CsvStatus.order_created) { + return; + } // arrange diff --git a/test/PrintOne.spec.ts b/test/PrintOne.spec.ts index e4927b5..e801321 100644 --- a/test/PrintOne.spec.ts +++ b/test/PrintOne.spec.ts @@ -46,7 +46,7 @@ beforeAll(async function () { afterAll(async function () { if (template) { - await template.delete(); + await template.delete().catch(() => {}); } }); @@ -1279,6 +1279,7 @@ describe("getOrders", function () { name: "Test batch", finish: Finish.GLOSSY, template: template, + sender: exampleAddress, }); const batchOrder = await batch.createOrder({ recipient: exampleAddress, @@ -1383,6 +1384,7 @@ describe("createBatch", function () { name: "Test batch", finish: Finish.GLOSSY, template: template, + sender: exampleAddress, }); // assert @@ -1398,6 +1400,7 @@ describe("createBatch", function () { name: "Test batch", finish: Finish.GLOSSY, template: template, + sender: exampleAddress, }); // assert @@ -1435,6 +1438,7 @@ describe("createBatch", function () { finish: Finish.GLOSSY, template: template, ready: sendDate, + sender: exampleAddress, }); // assert @@ -1444,8 +1448,6 @@ describe("createBatch", function () { it("should create an batch that is ready", async function () { // arrange - const sendDate = new Date(); - sendDate.setDate(sendDate.getDate() + 10); // act const batch = await client.createBatch({ @@ -1453,12 +1455,15 @@ describe("createBatch", function () { finish: Finish.GLOSSY, template: template, ready: true, + sender: exampleAddress, }); // assert expect(batch).toBeDefined(); expect(batch.status).toEqual(BatchStatus.batch_user_ready); - expect(batch.sendDate).toBeBefore(new Date()); + const withMargin = new Date(); + withMargin.setMinutes(withMargin.getMinutes() + 1); + expect(batch.sendDate).toBeBefore(withMargin); }); it("should create an batch with a billing id", async function () { @@ -1471,6 +1476,7 @@ describe("createBatch", function () { finish: Finish.GLOSSY, template: template, billingId: billingId, + sender: exampleAddress, }); // assert @@ -1487,6 +1493,7 @@ describe("createBatch", function () { name: "Test batch", finish: Finish.GLOSSY, template: templateId, + sender: exampleAddress, }); // assert @@ -1504,6 +1511,7 @@ describe("getBatch", function () { name: "Test batch", template: template, finish: Finish.GLOSSY, + sender: exampleAddress, }); batchId = batch.id; }); From 4a467295803859ccd2787e109ad67a35e7cc49ae Mon Sep 17 00:00:00 2001 From: UnderKoen Date: Wed, 22 May 2024 11:53:20 +0200 Subject: [PATCH 3/4] chore: test coverage --- test/CsvOrder.spec.ts | 2 +- test/PrintOne.spec.ts | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/test/CsvOrder.spec.ts b/test/CsvOrder.spec.ts index 8a03b14..4413754 100644 --- a/test/CsvOrder.spec.ts +++ b/test/CsvOrder.spec.ts @@ -90,7 +90,7 @@ describe("getOrders", function () { // arrange // act - while (await order.getOrders({}).then((x) => x.data.length < 1)) { + while (await order.getOrders().then((x) => x.data.length < 1)) { await order.refresh(); await sleep(1000); } diff --git a/test/PrintOne.spec.ts b/test/PrintOne.spec.ts index e801321..45a4420 100644 --- a/test/PrintOne.spec.ts +++ b/test/PrintOne.spec.ts @@ -1908,6 +1908,28 @@ describe("getBatches", function () { ); }); + it("should use the status filter (single)", async function () { + // arrange + + // act + const batches = await client.getBatches({ + limit: 1, + filter: { + status: BatchStatus.batch_sent, + }, + }); + const batch = batches.data[0]; + + if (batch === undefined) { + console.warn("No batches found, skipping test"); + return; + } + + // assert + expect(batch).toBeDefined(); + expect(batch.status).toEqual(expect.toBeOneOf([BatchStatus.batch_created])); + }); + it("should use the status filter (single)", async function () { // arrange From 06066f6b084723c2777be2240b32babc68dd21b2 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Wed, 22 May 2024 09:56:39 +0000 Subject: [PATCH 4/4] chore(release): 1.3.0-next.1 [skip ci] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # [1.3.0-next.1](https://github.com/Print-one/print-one-js/compare/v1.2.1...v1.3.0-next.1) (2024-05-22) ### Bug Fixes * batch status filter ([2b0e209](https://github.com/Print-one/print-one-js/commit/2b0e20917d66ad21af372c5ed19f8f80da20ae71)) * batch status filter ([2db77de](https://github.com/Print-one/print-one-js/commit/2db77de99b2e53f85e459790e82828b91edd58db)) * import in CsvOrder.ts ([#19](https://github.com/Print-one/print-one-js/issues/19)) ([40986aa](https://github.com/Print-one/print-one-js/commit/40986aac4deb5ff5d9b87358f30c4a9138998a5e)) ### Features * :sparkles: added endpoint to get a CsvOrder by it's ID ([74b0313](https://github.com/Print-one/print-one-js/commit/74b0313fefc98ddb45184c3b27a9615ea39fe7e7)) * :sparkles: added remaining getBatches filters ([4c2996b](https://github.com/Print-one/print-one-js/commit/4c2996b4ad3cf29bab6daf32830ae419c9641e81)) * :sparkles: allow for getting CSV order by id ([0560944](https://github.com/Print-one/print-one-js/commit/0560944128abdeea5cf0ff5ec79391201e0598a3)) * :sparkles: allow for uploading CSVs to a Batch ([a4bd3a6](https://github.com/Print-one/print-one-js/commit/a4bd3a68ecc6f7d360ab751be88b22324249b6f6)) * :sparkles: support batch order's API urls ([c2ca919](https://github.com/Print-one/print-one-js/commit/c2ca919f5d91f0618f2699d180e6bc8830d560b7)) * ✨ added CsvOrder model + endpoints ([#7](https://github.com/Print-one/print-one-js/issues/7)) ([9e04141](https://github.com/Print-one/print-one-js/commit/9e041416bdc09a3f34d6f2da72bde6788770e39b)) * added format to DTO ([64ec3ad](https://github.com/Print-one/print-one-js/commit/64ec3adc8b51dd697d0c1244e663353b087a17c1)) * batch endpoints added ([#8](https://github.com/Print-one/print-one-js/issues/8)) ([0099217](https://github.com/Print-one/print-one-js/commit/009921704b0c7b75206341ef20b1f540c31e366c)) * implement PR feedback ([8420046](https://github.com/Print-one/print-one-js/commit/8420046c3655a0a9480f192f3879fcf9524c06f4)) --- CHANGELOG.md | 22 ++++++++++++++++++++++ package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2660746..7f9b21a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,25 @@ +# [1.3.0-next.1](https://github.com/Print-one/print-one-js/compare/v1.2.1...v1.3.0-next.1) (2024-05-22) + + +### Bug Fixes + +* batch status filter ([2b0e209](https://github.com/Print-one/print-one-js/commit/2b0e20917d66ad21af372c5ed19f8f80da20ae71)) +* batch status filter ([2db77de](https://github.com/Print-one/print-one-js/commit/2db77de99b2e53f85e459790e82828b91edd58db)) +* import in CsvOrder.ts ([#19](https://github.com/Print-one/print-one-js/issues/19)) ([40986aa](https://github.com/Print-one/print-one-js/commit/40986aac4deb5ff5d9b87358f30c4a9138998a5e)) + + +### Features + +* :sparkles: added endpoint to get a CsvOrder by it's ID ([74b0313](https://github.com/Print-one/print-one-js/commit/74b0313fefc98ddb45184c3b27a9615ea39fe7e7)) +* :sparkles: added remaining getBatches filters ([4c2996b](https://github.com/Print-one/print-one-js/commit/4c2996b4ad3cf29bab6daf32830ae419c9641e81)) +* :sparkles: allow for getting CSV order by id ([0560944](https://github.com/Print-one/print-one-js/commit/0560944128abdeea5cf0ff5ec79391201e0598a3)) +* :sparkles: allow for uploading CSVs to a Batch ([a4bd3a6](https://github.com/Print-one/print-one-js/commit/a4bd3a68ecc6f7d360ab751be88b22324249b6f6)) +* :sparkles: support batch order's API urls ([c2ca919](https://github.com/Print-one/print-one-js/commit/c2ca919f5d91f0618f2699d180e6bc8830d560b7)) +* ✨ added CsvOrder model + endpoints ([#7](https://github.com/Print-one/print-one-js/issues/7)) ([9e04141](https://github.com/Print-one/print-one-js/commit/9e041416bdc09a3f34d6f2da72bde6788770e39b)) +* added format to DTO ([64ec3ad](https://github.com/Print-one/print-one-js/commit/64ec3adc8b51dd697d0c1244e663353b087a17c1)) +* batch endpoints added ([#8](https://github.com/Print-one/print-one-js/issues/8)) ([0099217](https://github.com/Print-one/print-one-js/commit/009921704b0c7b75206341ef20b1f540c31e366c)) +* implement PR feedback ([8420046](https://github.com/Print-one/print-one-js/commit/8420046c3655a0a9480f192f3879fcf9524c06f4)) + ## [1.2.1](https://github.com/Print-one/print-one-js/compare/v1.2.0...v1.2.1) (2024-04-15) diff --git a/package-lock.json b/package-lock.json index 3674be8..ebfd205 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@print-one/print-one-js", - "version": "1.2.1", + "version": "1.3.0-next.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@print-one/print-one-js", - "version": "1.2.1", + "version": "1.3.0-next.1", "hasInstallScript": true, "license": "MIT", "dependencies": { diff --git a/package.json b/package.json index a0dfb84..772d44d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@print-one/print-one-js", - "version": "1.2.1", + "version": "1.3.0-next.1", "description": "The official javascript client for Print.one", "license": "MIT", "author": "Print.one",