diff --git a/examples/echo-bot-ts-cjs/package-lock.json b/examples/echo-bot-ts-cjs/package-lock.json index 6ed8b3fa1..af21c3168 100644 --- a/examples/echo-bot-ts-cjs/package-lock.json +++ b/examples/echo-bot-ts-cjs/package-lock.json @@ -15,7 +15,7 @@ "@types/express": "^4.17.17", "@types/node": "^20.6.3", "rimraf": "^5.0.1", - "typescript": "^5.2.2" + "typescript": "^6.0.0" } }, "../..": { @@ -37,7 +37,7 @@ "publint": "0.3.18", "typedoc": "^0.28.14", "typedoc-plugin-markdown": "^4.3.0", - "typescript": "^5.5.4", + "typescript": "^6.0.0", "vitepress": "^1.0.1", "vitest": "^3.0.0" }, @@ -5803,7 +5803,9 @@ } }, "node_modules/typescript": { - "version": "5.9.3", + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-6.0.2.tgz", + "integrity": "sha512-bGdAIrZ0wiGDo5l8c++HWtbaNCWTS4UTv7RaTH/ThVIgjkveJt83m74bBHMJkuCbslY8ixgLBVZJIOiQlQTjfQ==", "dev": true, "license": "Apache-2.0", "bin": { diff --git a/examples/echo-bot-ts-cjs/package.json b/examples/echo-bot-ts-cjs/package.json index 8a91e3c6e..3fc5f7b7d 100644 --- a/examples/echo-bot-ts-cjs/package.json +++ b/examples/echo-bot-ts-cjs/package.json @@ -17,6 +17,6 @@ "@types/express": "^4.17.17", "@types/node": "^20.6.3", "rimraf": "^5.0.1", - "typescript": "^5.2.2" + "typescript": "^6.0.0" } } diff --git a/examples/echo-bot-ts-cjs/tsconfig.json b/examples/echo-bot-ts-cjs/tsconfig.json index 49e37f24e..6da4f2986 100644 --- a/examples/echo-bot-ts-cjs/tsconfig.json +++ b/examples/echo-bot-ts-cjs/tsconfig.json @@ -4,8 +4,7 @@ "module": "commonjs", "outDir": "./dist", "strict": true, - "esModuleInterop": true, - "forceConsistentCasingInFileNames": true + "types": ["node"] }, "exclude": ["node_modules"] } diff --git a/examples/echo-bot-ts-esm/package-lock.json b/examples/echo-bot-ts-esm/package-lock.json index 3b4a7be19..7c81e1b34 100644 --- a/examples/echo-bot-ts-esm/package-lock.json +++ b/examples/echo-bot-ts-esm/package-lock.json @@ -15,7 +15,7 @@ "@types/express": "^4.17.17", "@types/node": "^20.6.3", "rimraf": "^5.0.1", - "typescript": "^5.2.2" + "typescript": "^6.0.0" } }, "../..": { @@ -37,7 +37,7 @@ "publint": "0.3.18", "typedoc": "^0.28.14", "typedoc-plugin-markdown": "^4.3.0", - "typescript": "^5.5.4", + "typescript": "^6.0.0", "vitepress": "^1.0.1", "vitest": "^3.0.0" }, @@ -5803,7 +5803,9 @@ } }, "node_modules/typescript": { - "version": "5.9.3", + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-6.0.2.tgz", + "integrity": "sha512-bGdAIrZ0wiGDo5l8c++HWtbaNCWTS4UTv7RaTH/ThVIgjkveJt83m74bBHMJkuCbslY8ixgLBVZJIOiQlQTjfQ==", "dev": true, "license": "Apache-2.0", "bin": { diff --git a/examples/echo-bot-ts-esm/package.json b/examples/echo-bot-ts-esm/package.json index d36749259..e92c5eec5 100644 --- a/examples/echo-bot-ts-esm/package.json +++ b/examples/echo-bot-ts-esm/package.json @@ -18,6 +18,6 @@ "@types/express": "^4.17.17", "@types/node": "^20.6.3", "rimraf": "^5.0.1", - "typescript": "^5.2.2" + "typescript": "^6.0.0" } } diff --git a/examples/echo-bot-ts-esm/tsconfig.json b/examples/echo-bot-ts-esm/tsconfig.json index 592c51ae6..e672b9180 100644 --- a/examples/echo-bot-ts-esm/tsconfig.json +++ b/examples/echo-bot-ts-esm/tsconfig.json @@ -4,8 +4,8 @@ "module": "NodeNext", "moduleResolution": "NodeNext", "outDir": "./dist", - "esModuleInterop": true, - "forceConsistentCasingInFileNames": true + "strict": true, + "types": ["node"] }, "exclude": ["node_modules"] } diff --git a/generator/src/main/resources/line-bot-sdk-nodejs-generator/apiBody/normal.pebble b/generator/src/main/resources/line-bot-sdk-nodejs-generator/apiBody/normal.pebble index 9e2be8373..53895445c 100644 --- a/generator/src/main/resources/line-bot-sdk-nodejs-generator/apiBody/normal.pebble +++ b/generator/src/main/resources/line-bot-sdk-nodejs-generator/apiBody/normal.pebble @@ -14,25 +14,36 @@ "{{param.baseName}}": {{param.paramName}}, {% endfor %} }; - Object.keys(formParams).forEach((key: keyof typeof formParams) => { - if (formParams[key] === undefined) { - delete formParams[key]; - } - }); + + {% for param in op.formParams -%} + {% if param.required == false %} + if (formParams["{{param.baseName}}"] === undefined) { + delete formParams["{{param.baseName}}"]; + } + {% endif -%} + {% endfor %} + {% elseif op.hasQueryParams %}const queryParams = { {% for param in op.queryParams -%} - {% if param.isArray -%} + {% if param.isArray and param.required == false -%} + "{{param.baseName}}": {{param.paramName}} != null + ? [...{{param.paramName}}].join(",") + : undefined, + {% elseif param.isArray -%} "{{param.baseName}}": [...{{param.paramName}}].join(","), {% else -%} "{{param.baseName}}": {{param.paramName}}, {% endif -%} {% endfor %} }; - Object.keys(queryParams).forEach((key: keyof typeof queryParams) => { - if (queryParams[key] === undefined) { - delete queryParams[key]; - } - }); + + {% for param in op.queryParams -%} + {% if param.required == false %} + if (queryParams["{{param.baseName}}"] === undefined) { + delete queryParams["{{param.baseName}}"]; + } + {% endif -%} + {% endfor %} {% endif %} {% if op.hasHeaderParams %}const headerParams = { {% for param in op.headerParams -%} diff --git a/generator/src/main/resources/line-bot-sdk-nodejs-generator/api_test.pebble b/generator/src/main/resources/line-bot-sdk-nodejs-generator/api_test.pebble index 1732c4343..2f6e12ba4 100644 --- a/generator/src/main/resources/line-bot-sdk-nodejs-generator/api_test.pebble +++ b/generator/src/main/resources/line-bot-sdk-nodejs-generator/api_test.pebble @@ -121,6 +121,7 @@ function parseForm( requestCount++; equal(req.method, "{{ op.httpMethod }}"); + ok(req.url) const reqUrl = new URL(req.url, "http://localhost/"); equal(reqUrl.pathname, "{{ op.path }}" {% for param in op.allParams -%} @@ -151,8 +152,10 @@ function parseForm( "@line/bot-sdk/1.0.0-test", ); {% if op.isMultipart %} + const contentType = req.headers["content-type"]; + ok(contentType); ok( - req.headers["content-type"] + contentType .startsWith(`multipart/form-data; boundary=`), ); {% endif %} diff --git a/lib/channel-access-token/api/channelAccessTokenClient.ts b/lib/channel-access-token/api/channelAccessTokenClient.ts index 8db66a5e0..2432d51cb 100644 --- a/lib/channel-access-token/api/channelAccessTokenClient.ts +++ b/lib/channel-access-token/api/channelAccessTokenClient.ts @@ -83,11 +83,6 @@ export class ChannelAccessTokenClient { client_assertion_type: clientAssertionType, client_assertion: clientAssertion, }; - Object.keys(queryParams).forEach((key: keyof typeof queryParams) => { - if (queryParams[key] === undefined) { - delete queryParams[key]; - } - }); const res = await this.httpClient.get( "/oauth2/v2.1/tokens/kid", @@ -138,11 +133,6 @@ export class ChannelAccessTokenClient { client_id: clientId, client_secret: clientSecret, }; - Object.keys(formParams).forEach((key: keyof typeof formParams) => { - if (formParams[key] === undefined) { - delete formParams[key]; - } - }); const res = await this.httpClient.postForm( "/v2/oauth/accessToken", @@ -193,11 +183,6 @@ export class ChannelAccessTokenClient { client_assertion_type: clientAssertionType, client_assertion: clientAssertion, }; - Object.keys(formParams).forEach((key: keyof typeof formParams) => { - if (formParams[key] === undefined) { - delete formParams[key]; - } - }); const res = await this.httpClient.postForm( "/oauth2/v2.1/token", @@ -262,11 +247,26 @@ export class ChannelAccessTokenClient { client_id: clientId, client_secret: clientSecret, }; - Object.keys(formParams).forEach((key: keyof typeof formParams) => { - if (formParams[key] === undefined) { - delete formParams[key]; - } - }); + + if (formParams["grant_type"] === undefined) { + delete formParams["grant_type"]; + } + + if (formParams["client_assertion_type"] === undefined) { + delete formParams["client_assertion_type"]; + } + + if (formParams["client_assertion"] === undefined) { + delete formParams["client_assertion"]; + } + + if (formParams["client_id"] === undefined) { + delete formParams["client_id"]; + } + + if (formParams["client_secret"] === undefined) { + delete formParams["client_secret"]; + } const res = await this.httpClient.postForm("/oauth2/v3/token", formParams); const text = await res.text(); @@ -298,11 +298,6 @@ export class ChannelAccessTokenClient { const formParams = { access_token: accessToken, }; - Object.keys(formParams).forEach((key: keyof typeof formParams) => { - if (formParams[key] === undefined) { - delete formParams[key]; - } - }); const res = await this.httpClient.postForm("/v2/oauth/revoke", formParams); const text = await res.text(); @@ -350,11 +345,6 @@ export class ChannelAccessTokenClient { client_secret: clientSecret, access_token: accessToken, }; - Object.keys(formParams).forEach((key: keyof typeof formParams) => { - if (formParams[key] === undefined) { - delete formParams[key]; - } - }); const res = await this.httpClient.postForm( "/oauth2/v2.1/revoke", @@ -389,11 +379,6 @@ export class ChannelAccessTokenClient { const formParams = { access_token: accessToken, }; - Object.keys(formParams).forEach((key: keyof typeof formParams) => { - if (formParams[key] === undefined) { - delete formParams[key]; - } - }); const res = await this.httpClient.postForm("/v2/oauth/verify", formParams); const text = await res.text(); @@ -425,11 +410,6 @@ export class ChannelAccessTokenClient { const queryParams = { access_token: accessToken, }; - Object.keys(queryParams).forEach((key: keyof typeof queryParams) => { - if (queryParams[key] === undefined) { - delete queryParams[key]; - } - }); const res = await this.httpClient.get("/oauth2/v2.1/verify", queryParams); const text = await res.text(); diff --git a/lib/channel-access-token/tests/api/ChannelAccessTokenClientTest.spec.ts b/lib/channel-access-token/tests/api/ChannelAccessTokenClientTest.spec.ts index 21c677069..2d6bbccf2 100644 --- a/lib/channel-access-token/tests/api/ChannelAccessTokenClientTest.spec.ts +++ b/lib/channel-access-token/tests/api/ChannelAccessTokenClientTest.spec.ts @@ -69,6 +69,7 @@ describe("ChannelAccessTokenClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -132,6 +133,7 @@ describe("ChannelAccessTokenClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -195,6 +197,7 @@ describe("ChannelAccessTokenClient", () => { requestCount++; equal(req.method, "POST"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -245,6 +248,7 @@ describe("ChannelAccessTokenClient", () => { requestCount++; equal(req.method, "POST"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -295,6 +299,7 @@ describe("ChannelAccessTokenClient", () => { requestCount++; equal(req.method, "POST"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -345,6 +350,7 @@ describe("ChannelAccessTokenClient", () => { requestCount++; equal(req.method, "POST"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -395,6 +401,7 @@ describe("ChannelAccessTokenClient", () => { requestCount++; equal(req.method, "POST"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -453,6 +460,7 @@ describe("ChannelAccessTokenClient", () => { requestCount++; equal(req.method, "POST"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -511,6 +519,7 @@ describe("ChannelAccessTokenClient", () => { requestCount++; equal(req.method, "POST"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -552,6 +561,7 @@ describe("ChannelAccessTokenClient", () => { requestCount++; equal(req.method, "POST"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -593,6 +603,7 @@ describe("ChannelAccessTokenClient", () => { requestCount++; equal(req.method, "POST"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -643,6 +654,7 @@ describe("ChannelAccessTokenClient", () => { requestCount++; equal(req.method, "POST"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -693,6 +705,7 @@ describe("ChannelAccessTokenClient", () => { requestCount++; equal(req.method, "POST"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -734,6 +747,7 @@ describe("ChannelAccessTokenClient", () => { requestCount++; equal(req.method, "POST"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -775,6 +789,7 @@ describe("ChannelAccessTokenClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -826,6 +841,7 @@ describe("ChannelAccessTokenClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, diff --git a/lib/exceptions.ts b/lib/exceptions.ts index 7e6030e0a..783f61bdf 100644 --- a/lib/exceptions.ts +++ b/lib/exceptions.ts @@ -53,6 +53,9 @@ export class HTTPFetchError extends Error { super(message); this.name = this.constructor.name; - Object.assign(this, { status, statusText, headers, body }); + this.status = status; + this.statusText = statusText; + this.headers = headers; + this.body = body; } } diff --git a/lib/http-fetch.ts b/lib/http-fetch.ts index 4e65efe34..782ca646e 100644 --- a/lib/http-fetch.ts +++ b/lib/http-fetch.ts @@ -14,6 +14,9 @@ interface httpFetchClientConfig { } export function convertResponseToReadable(response: Response): Readable { + if (!response.body) { + throw new Error("Response body is null"); + } const reader = response.body.getReader(); return new Readable({ async read() { diff --git a/lib/insight/api/insightClient.ts b/lib/insight/api/insightClient.ts index d99b23f97..4fc651a12 100644 --- a/lib/insight/api/insightClient.ts +++ b/lib/insight/api/insightClient.ts @@ -104,11 +104,6 @@ export class InsightClient { const queryParams = { requestId: requestId, }; - Object.keys(queryParams).forEach((key: keyof typeof queryParams) => { - if (queryParams[key] === undefined) { - delete queryParams[key]; - } - }); const res = await this.httpClient.get( "/v2/bot/insight/message/event", @@ -145,11 +140,10 @@ export class InsightClient { const queryParams = { date: date, }; - Object.keys(queryParams).forEach((key: keyof typeof queryParams) => { - if (queryParams[key] === undefined) { - delete queryParams[key]; - } - }); + + if (queryParams["date"] === undefined) { + delete queryParams["date"]; + } const res = await this.httpClient.get( "/v2/bot/insight/followers", @@ -186,11 +180,6 @@ export class InsightClient { const queryParams = { date: date, }; - Object.keys(queryParams).forEach((key: keyof typeof queryParams) => { - if (queryParams[key] === undefined) { - delete queryParams[key]; - } - }); const res = await this.httpClient.get( "/v2/bot/insight/message/delivery", @@ -241,11 +230,6 @@ export class InsightClient { from: from, to: to, }; - Object.keys(queryParams).forEach((key: keyof typeof queryParams) => { - if (queryParams[key] === undefined) { - delete queryParams[key]; - } - }); const res = await this.httpClient.get( "/v2/bot/insight/message/event/aggregation", diff --git a/lib/insight/tests/api/InsightClientTest.spec.ts b/lib/insight/tests/api/InsightClientTest.spec.ts index a31dd4368..a0faf89f2 100644 --- a/lib/insight/tests/api/InsightClientTest.spec.ts +++ b/lib/insight/tests/api/InsightClientTest.spec.ts @@ -68,6 +68,7 @@ describe("InsightClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal(reqUrl.pathname, "/v2/bot/insight/demographic"); @@ -105,6 +106,7 @@ describe("InsightClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal(reqUrl.pathname, "/v2/bot/insight/demographic"); @@ -142,6 +144,7 @@ describe("InsightClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -195,6 +198,7 @@ describe("InsightClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -248,6 +252,7 @@ describe("InsightClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -301,6 +306,7 @@ describe("InsightClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -354,6 +360,7 @@ describe("InsightClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -407,6 +414,7 @@ describe("InsightClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -460,6 +468,7 @@ describe("InsightClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -536,6 +545,7 @@ describe("InsightClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, diff --git a/lib/liff/tests/api/LiffClientTest.spec.ts b/lib/liff/tests/api/LiffClientTest.spec.ts index cf877841e..d718af765 100644 --- a/lib/liff/tests/api/LiffClientTest.spec.ts +++ b/lib/liff/tests/api/LiffClientTest.spec.ts @@ -67,6 +67,7 @@ describe("LiffClient", () => { requestCount++; equal(req.method, "POST"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal(reqUrl.pathname, "/liff/v1/apps"); @@ -107,6 +108,7 @@ describe("LiffClient", () => { requestCount++; equal(req.method, "POST"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal(reqUrl.pathname, "/liff/v1/apps"); @@ -147,6 +149,7 @@ describe("LiffClient", () => { requestCount++; equal(req.method, "DELETE"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -190,6 +193,7 @@ describe("LiffClient", () => { requestCount++; equal(req.method, "DELETE"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -233,6 +237,7 @@ describe("LiffClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal(reqUrl.pathname, "/liff/v1/apps"); @@ -270,6 +275,7 @@ describe("LiffClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal(reqUrl.pathname, "/liff/v1/apps"); @@ -307,6 +313,7 @@ describe("LiffClient", () => { requestCount++; equal(req.method, "PUT"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -353,6 +360,7 @@ describe("LiffClient", () => { requestCount++; equal(req.method, "PUT"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, diff --git a/lib/manage-audience/api/manageAudienceClient.ts b/lib/manage-audience/api/manageAudienceClient.ts index 861138eb9..442a91441 100644 --- a/lib/manage-audience/api/manageAudienceClient.ts +++ b/lib/manage-audience/api/manageAudienceClient.ts @@ -326,11 +326,26 @@ export class ManageAudienceClient { includesExternalPublicGroups: includesExternalPublicGroups, createRoute: createRoute, }; - Object.keys(queryParams).forEach((key: keyof typeof queryParams) => { - if (queryParams[key] === undefined) { - delete queryParams[key]; - } - }); + + if (queryParams["description"] === undefined) { + delete queryParams["description"]; + } + + if (queryParams["status"] === undefined) { + delete queryParams["status"]; + } + + if (queryParams["size"] === undefined) { + delete queryParams["size"]; + } + + if (queryParams["includesExternalPublicGroups"] === undefined) { + delete queryParams["includesExternalPublicGroups"]; + } + + if (queryParams["createRoute"] === undefined) { + delete queryParams["createRoute"]; + } const res = await this.httpClient.get( "/v2/bot/audienceGroup/list", @@ -431,11 +446,26 @@ export class ManageAudienceClient { createRoute: createRoute, includesOwnedAudienceGroups: includesOwnedAudienceGroups, }; - Object.keys(queryParams).forEach((key: keyof typeof queryParams) => { - if (queryParams[key] === undefined) { - delete queryParams[key]; - } - }); + + if (queryParams["description"] === undefined) { + delete queryParams["description"]; + } + + if (queryParams["status"] === undefined) { + delete queryParams["status"]; + } + + if (queryParams["size"] === undefined) { + delete queryParams["size"]; + } + + if (queryParams["createRoute"] === undefined) { + delete queryParams["createRoute"]; + } + + if (queryParams["includesOwnedAudienceGroups"] === undefined) { + delete queryParams["includesOwnedAudienceGroups"]; + } const res = await this.httpClient.get( "/v2/bot/audienceGroup/shared/list", diff --git a/lib/manage-audience/tests/api/ManageAudienceBlobClientTest.spec.ts b/lib/manage-audience/tests/api/ManageAudienceBlobClientTest.spec.ts index 09bddb477..b3126466d 100644 --- a/lib/manage-audience/tests/api/ManageAudienceBlobClientTest.spec.ts +++ b/lib/manage-audience/tests/api/ManageAudienceBlobClientTest.spec.ts @@ -64,6 +64,7 @@ describe("ManageAudienceBlobClient", () => { requestCount++; equal(req.method, "PUT"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -75,11 +76,9 @@ describe("ManageAudienceBlobClient", () => { equal(req.headers["authorization"], `Bearer ${channel_access_token}`); equal(req.headers["user-agent"], "@line/bot-sdk/1.0.0-test"); - ok( - req.headers["content-type"].startsWith( - `multipart/form-data; boundary=`, - ), - ); + const contentType = req.headers["content-type"]; + ok(contentType); + ok(contentType.startsWith(`multipart/form-data; boundary=`)); let data: Buffer[] = []; @@ -162,6 +161,7 @@ describe("ManageAudienceBlobClient", () => { requestCount++; equal(req.method, "PUT"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -173,11 +173,9 @@ describe("ManageAudienceBlobClient", () => { equal(req.headers["authorization"], `Bearer ${channel_access_token}`); equal(req.headers["user-agent"], "@line/bot-sdk/1.0.0-test"); - ok( - req.headers["content-type"].startsWith( - `multipart/form-data; boundary=`, - ), - ); + const contentType = req.headers["content-type"]; + ok(contentType); + ok(contentType.startsWith(`multipart/form-data; boundary=`)); let data: Buffer[] = []; @@ -260,6 +258,7 @@ describe("ManageAudienceBlobClient", () => { requestCount++; equal(req.method, "POST"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -271,11 +270,9 @@ describe("ManageAudienceBlobClient", () => { equal(req.headers["authorization"], `Bearer ${channel_access_token}`); equal(req.headers["user-agent"], "@line/bot-sdk/1.0.0-test"); - ok( - req.headers["content-type"].startsWith( - `multipart/form-data; boundary=`, - ), - ); + const contentType = req.headers["content-type"]; + ok(contentType); + ok(contentType.startsWith(`multipart/form-data; boundary=`)); let data: Buffer[] = []; @@ -368,6 +365,7 @@ describe("ManageAudienceBlobClient", () => { requestCount++; equal(req.method, "POST"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -379,11 +377,9 @@ describe("ManageAudienceBlobClient", () => { equal(req.headers["authorization"], `Bearer ${channel_access_token}`); equal(req.headers["user-agent"], "@line/bot-sdk/1.0.0-test"); - ok( - req.headers["content-type"].startsWith( - `multipart/form-data; boundary=`, - ), - ); + const contentType = req.headers["content-type"]; + ok(contentType); + ok(contentType.startsWith(`multipart/form-data; boundary=`)); let data: Buffer[] = []; diff --git a/lib/manage-audience/tests/api/ManageAudienceClientTest.spec.ts b/lib/manage-audience/tests/api/ManageAudienceClientTest.spec.ts index 775e917e3..ddb5ca24f 100644 --- a/lib/manage-audience/tests/api/ManageAudienceClientTest.spec.ts +++ b/lib/manage-audience/tests/api/ManageAudienceClientTest.spec.ts @@ -78,6 +78,7 @@ describe("ManageAudienceClient", () => { requestCount++; equal(req.method, "PUT"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal(reqUrl.pathname, "/v2/bot/audienceGroup/upload"); @@ -118,6 +119,7 @@ describe("ManageAudienceClient", () => { requestCount++; equal(req.method, "PUT"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal(reqUrl.pathname, "/v2/bot/audienceGroup/upload"); @@ -158,6 +160,7 @@ describe("ManageAudienceClient", () => { requestCount++; equal(req.method, "POST"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal(reqUrl.pathname, "/v2/bot/audienceGroup/upload"); @@ -198,6 +201,7 @@ describe("ManageAudienceClient", () => { requestCount++; equal(req.method, "POST"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal(reqUrl.pathname, "/v2/bot/audienceGroup/upload"); @@ -238,6 +242,7 @@ describe("ManageAudienceClient", () => { requestCount++; equal(req.method, "POST"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal(reqUrl.pathname, "/v2/bot/audienceGroup/click"); @@ -278,6 +283,7 @@ describe("ManageAudienceClient", () => { requestCount++; equal(req.method, "POST"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal(reqUrl.pathname, "/v2/bot/audienceGroup/click"); @@ -318,6 +324,7 @@ describe("ManageAudienceClient", () => { requestCount++; equal(req.method, "POST"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal(reqUrl.pathname, "/v2/bot/audienceGroup/imp"); @@ -358,6 +365,7 @@ describe("ManageAudienceClient", () => { requestCount++; equal(req.method, "POST"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal(reqUrl.pathname, "/v2/bot/audienceGroup/imp"); @@ -398,6 +406,7 @@ describe("ManageAudienceClient", () => { requestCount++; equal(req.method, "DELETE"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -444,6 +453,7 @@ describe("ManageAudienceClient", () => { requestCount++; equal(req.method, "DELETE"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -490,6 +500,7 @@ describe("ManageAudienceClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -536,6 +547,7 @@ describe("ManageAudienceClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -582,6 +594,7 @@ describe("ManageAudienceClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -688,6 +701,7 @@ describe("ManageAudienceClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -794,6 +808,7 @@ describe("ManageAudienceClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -840,6 +855,7 @@ describe("ManageAudienceClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -886,6 +902,7 @@ describe("ManageAudienceClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -992,6 +1009,7 @@ describe("ManageAudienceClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -1098,6 +1116,7 @@ describe("ManageAudienceClient", () => { requestCount++; equal(req.method, "PUT"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -1147,6 +1166,7 @@ describe("ManageAudienceClient", () => { requestCount++; equal(req.method, "PUT"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, diff --git a/lib/messaging-api/api/messagingApiClient.ts b/lib/messaging-api/api/messagingApiClient.ts index 29e60bd2e..e91d6f6d7 100644 --- a/lib/messaging-api/api/messagingApiClient.ts +++ b/lib/messaging-api/api/messagingApiClient.ts @@ -380,11 +380,14 @@ export class MessagingApiClient { limit: limit, start: start, }; - Object.keys(queryParams).forEach((key: keyof typeof queryParams) => { - if (queryParams[key] === undefined) { - delete queryParams[key]; - } - }); + + if (queryParams["limit"] === undefined) { + delete queryParams["limit"]; + } + + if (queryParams["start"] === undefined) { + delete queryParams["start"]; + } const res = await this.httpClient.get( "/v2/bot/message/aggregation/list", @@ -520,11 +523,14 @@ export class MessagingApiClient { start: start, limit: limit, }; - Object.keys(queryParams).forEach((key: keyof typeof queryParams) => { - if (queryParams[key] === undefined) { - delete queryParams[key]; - } - }); + + if (queryParams["start"] === undefined) { + delete queryParams["start"]; + } + + if (queryParams["limit"] === undefined) { + delete queryParams["limit"]; + } const res = await this.httpClient.get("/v2/bot/followers/ids", queryParams); const text = await res.text(); @@ -629,11 +635,10 @@ export class MessagingApiClient { const queryParams = { start: start, }; - Object.keys(queryParams).forEach((key: keyof typeof queryParams) => { - if (queryParams[key] === undefined) { - delete queryParams[key]; - } - }); + + if (queryParams["start"] === undefined) { + delete queryParams["start"]; + } const res = await this.httpClient.get( "/v2/bot/group/{groupId}/members/ids".replace( @@ -713,11 +718,14 @@ export class MessagingApiClient { start: start, limit: limit, }; - Object.keys(queryParams).forEach((key: keyof typeof queryParams) => { - if (queryParams[key] === undefined) { - delete queryParams[key]; - } - }); + + if (queryParams["start"] === undefined) { + delete queryParams["start"]; + } + + if (queryParams["limit"] === undefined) { + delete queryParams["limit"]; + } const res = await this.httpClient.get( "/v2/bot/membership/{membershipId}/users/ids".replace( @@ -856,11 +864,6 @@ export class MessagingApiClient { const queryParams = { requestId: requestId, }; - Object.keys(queryParams).forEach((key: keyof typeof queryParams) => { - if (queryParams[key] === undefined) { - delete queryParams[key]; - } - }); const res = await this.httpClient.get( "/v2/bot/message/progress/narrowcast", @@ -895,11 +898,6 @@ export class MessagingApiClient { const queryParams = { date: date, }; - Object.keys(queryParams).forEach((key: keyof typeof queryParams) => { - if (queryParams[key] === undefined) { - delete queryParams[key]; - } - }); const res = await this.httpClient.get( "/v2/bot/message/delivery/broadcast", @@ -934,11 +932,6 @@ export class MessagingApiClient { const queryParams = { date: date, }; - Object.keys(queryParams).forEach((key: keyof typeof queryParams) => { - if (queryParams[key] === undefined) { - delete queryParams[key]; - } - }); const res = await this.httpClient.get( "/v2/bot/message/delivery/multicast", @@ -973,11 +966,6 @@ export class MessagingApiClient { const queryParams = { date: date, }; - Object.keys(queryParams).forEach((key: keyof typeof queryParams) => { - if (queryParams[key] === undefined) { - delete queryParams[key]; - } - }); const res = await this.httpClient.get( "/v2/bot/message/delivery/push", @@ -1012,11 +1000,6 @@ export class MessagingApiClient { const queryParams = { date: date, }; - Object.keys(queryParams).forEach((key: keyof typeof queryParams) => { - if (queryParams[key] === undefined) { - delete queryParams[key]; - } - }); const res = await this.httpClient.get( "/v2/bot/message/delivery/reply", @@ -1051,11 +1034,6 @@ export class MessagingApiClient { const queryParams = { date: date, }; - Object.keys(queryParams).forEach((key: keyof typeof queryParams) => { - if (queryParams[key] === undefined) { - delete queryParams[key]; - } - }); const res = await this.httpClient.get( "/v2/bot/message/delivery/pnp", @@ -1202,11 +1180,6 @@ export class MessagingApiClient { const queryParams = { requestId: requestId, }; - Object.keys(queryParams).forEach((key: keyof typeof queryParams) => { - if (queryParams[key] === undefined) { - delete queryParams[key]; - } - }); const res = await this.httpClient.get( "/v2/bot/richmenu/progress/batch", @@ -1363,11 +1336,10 @@ export class MessagingApiClient { const queryParams = { start: start, }; - Object.keys(queryParams).forEach((key: keyof typeof queryParams) => { - if (queryParams[key] === undefined) { - delete queryParams[key]; - } - }); + + if (queryParams["start"] === undefined) { + delete queryParams["start"]; + } const res = await this.httpClient.get( "/v2/bot/room/{roomId}/members/ids".replace("{roomId}", String(roomId)), @@ -1588,15 +1560,22 @@ export class MessagingApiClient { limit?: number, ): Promise> { const queryParams = { - status: [...status].join(","), + status: status != null ? [...status].join(",") : undefined, start: start, limit: limit, }; - Object.keys(queryParams).forEach((key: keyof typeof queryParams) => { - if (queryParams[key] === undefined) { - delete queryParams[key]; - } - }); + + if (queryParams["status"] === undefined) { + delete queryParams["status"]; + } + + if (queryParams["start"] === undefined) { + delete queryParams["start"]; + } + + if (queryParams["limit"] === undefined) { + delete queryParams["limit"]; + } const res = await this.httpClient.get("/v2/bot/coupon", queryParams); const text = await res.text(); diff --git a/lib/messaging-api/tests/api/MessagingApiBlobClientTest.spec.ts b/lib/messaging-api/tests/api/MessagingApiBlobClientTest.spec.ts index 80654fcc9..7413158bb 100644 --- a/lib/messaging-api/tests/api/MessagingApiBlobClientTest.spec.ts +++ b/lib/messaging-api/tests/api/MessagingApiBlobClientTest.spec.ts @@ -64,6 +64,7 @@ describe("MessagingApiBlobClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -107,6 +108,7 @@ describe("MessagingApiBlobClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -150,6 +152,7 @@ describe("MessagingApiBlobClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -196,6 +199,7 @@ describe("MessagingApiBlobClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -242,6 +246,7 @@ describe("MessagingApiBlobClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -289,6 +294,7 @@ describe("MessagingApiBlobClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -335,6 +341,7 @@ describe("MessagingApiBlobClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -381,6 +388,7 @@ describe("MessagingApiBlobClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -427,6 +435,7 @@ describe("MessagingApiBlobClient", () => { requestCount++; equal(req.method, "POST"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -476,6 +485,7 @@ describe("MessagingApiBlobClient", () => { requestCount++; equal(req.method, "POST"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, diff --git a/lib/messaging-api/tests/api/MessagingApiClientTest.spec.ts b/lib/messaging-api/tests/api/MessagingApiClientTest.spec.ts index 32325e705..225f90197 100644 --- a/lib/messaging-api/tests/api/MessagingApiClientTest.spec.ts +++ b/lib/messaging-api/tests/api/MessagingApiClientTest.spec.ts @@ -115,6 +115,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "POST"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -161,6 +162,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "POST"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -207,6 +209,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "DELETE"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal(reqUrl.pathname, "/v2/bot/user/all/richmenu"); @@ -244,6 +247,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "DELETE"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal(reqUrl.pathname, "/v2/bot/user/all/richmenu"); @@ -281,6 +285,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "PUT"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -324,6 +329,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "PUT"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -367,6 +373,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "POST"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal(reqUrl.pathname, "/v2/bot/coupon"); @@ -407,6 +414,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "POST"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal(reqUrl.pathname, "/v2/bot/coupon"); @@ -447,6 +455,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "POST"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal(reqUrl.pathname, "/v2/bot/richmenu"); @@ -487,6 +496,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "POST"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal(reqUrl.pathname, "/v2/bot/richmenu"); @@ -527,6 +537,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "POST"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal(reqUrl.pathname, "/v2/bot/richmenu/alias"); @@ -567,6 +578,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "POST"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal(reqUrl.pathname, "/v2/bot/richmenu/alias"); @@ -607,6 +619,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "DELETE"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -650,6 +663,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "DELETE"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -693,6 +707,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "DELETE"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -739,6 +754,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "DELETE"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -785,6 +801,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -850,6 +867,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -915,6 +933,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal(reqUrl.pathname, "/v2/bot/message/aggregation/info"); @@ -952,6 +971,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal(reqUrl.pathname, "/v2/bot/message/aggregation/info"); @@ -989,6 +1009,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal(reqUrl.pathname, "/v2/bot/info"); @@ -1026,6 +1047,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal(reqUrl.pathname, "/v2/bot/info"); @@ -1063,6 +1085,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -1106,6 +1129,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -1149,6 +1173,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal(reqUrl.pathname, "/v2/bot/user/all/richmenu"); @@ -1186,6 +1211,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal(reqUrl.pathname, "/v2/bot/user/all/richmenu"); @@ -1223,6 +1249,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -1288,6 +1315,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -1353,6 +1381,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -1396,6 +1425,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -1439,6 +1469,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -1487,6 +1518,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -1535,6 +1567,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -1593,6 +1626,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -1651,6 +1685,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -1694,6 +1729,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -1737,6 +1773,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -1806,6 +1843,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -1875,6 +1913,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal(reqUrl.pathname, "/v2/bot/membership/list"); @@ -1912,6 +1951,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal(reqUrl.pathname, "/v2/bot/membership/list"); @@ -1949,6 +1989,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -1992,6 +2033,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -2035,6 +2077,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal(reqUrl.pathname, "/v2/bot/message/quota"); @@ -2072,6 +2115,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal(reqUrl.pathname, "/v2/bot/message/quota"); @@ -2109,6 +2153,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal(reqUrl.pathname, "/v2/bot/message/quota/consumption"); @@ -2146,6 +2191,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal(reqUrl.pathname, "/v2/bot/message/quota/consumption"); @@ -2183,6 +2229,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -2236,6 +2283,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -2289,6 +2337,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -2342,6 +2391,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -2395,6 +2445,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -2448,6 +2499,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -2501,6 +2553,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -2554,6 +2607,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -2607,6 +2661,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -2660,6 +2715,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -2713,6 +2769,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -2766,6 +2823,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -2819,6 +2877,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -2862,6 +2921,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -2905,6 +2965,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -2948,6 +3009,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -2991,6 +3053,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -3037,6 +3100,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -3083,6 +3147,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal(reqUrl.pathname, "/v2/bot/richmenu/alias/list"); @@ -3120,6 +3185,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal(reqUrl.pathname, "/v2/bot/richmenu/alias/list"); @@ -3157,6 +3223,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -3210,6 +3277,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -3263,6 +3331,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -3306,6 +3375,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -3349,6 +3419,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal(reqUrl.pathname, "/v2/bot/richmenu/list"); @@ -3386,6 +3457,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal(reqUrl.pathname, "/v2/bot/richmenu/list"); @@ -3423,6 +3495,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -3466,6 +3539,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -3509,6 +3583,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -3557,6 +3632,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -3605,6 +3681,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -3663,6 +3740,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -3721,6 +3799,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal(reqUrl.pathname, "/v2/bot/channel/webhook/endpoint"); @@ -3758,6 +3837,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal(reqUrl.pathname, "/v2/bot/channel/webhook/endpoint"); @@ -3795,6 +3875,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "POST"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -3838,6 +3919,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "POST"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -3881,6 +3963,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "POST"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -3924,6 +4007,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "POST"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -3967,6 +4051,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "POST"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -4010,6 +4095,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "POST"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -4053,6 +4139,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "POST"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -4101,6 +4188,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "POST"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -4149,6 +4237,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "POST"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal(reqUrl.pathname, "/v2/bot/richmenu/bulk/link"); @@ -4189,6 +4278,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "POST"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal(reqUrl.pathname, "/v2/bot/richmenu/bulk/link"); @@ -4229,6 +4319,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -4306,6 +4397,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -4383,6 +4475,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "POST"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal(reqUrl.pathname, "/v2/bot/message/markAsRead"); @@ -4423,6 +4516,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "POST"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal(reqUrl.pathname, "/v2/bot/message/markAsRead"); @@ -4463,6 +4557,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "POST"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal(reqUrl.pathname, "/v2/bot/chat/markAsRead"); @@ -4503,6 +4598,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "POST"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal(reqUrl.pathname, "/v2/bot/chat/markAsRead"); @@ -4543,6 +4639,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "POST"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -4589,6 +4686,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "POST"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -4635,6 +4733,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "POST"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -4681,6 +4780,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "POST"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -4727,6 +4827,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "POST"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -4773,6 +4874,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "POST"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -4819,6 +4921,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "POST"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -4865,6 +4968,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "POST"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -4911,6 +5015,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "POST"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal(reqUrl.pathname, "/v2/bot/message/reply"); @@ -4951,6 +5056,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "POST"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal(reqUrl.pathname, "/v2/bot/message/reply"); @@ -4991,6 +5097,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "POST"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal(reqUrl.pathname, "/v2/bot/richmenu/batch"); @@ -5031,6 +5138,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "POST"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal(reqUrl.pathname, "/v2/bot/richmenu/batch"); @@ -5071,6 +5179,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "POST"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -5117,6 +5226,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "POST"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -5163,6 +5273,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "PUT"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal(reqUrl.pathname, "/v2/bot/channel/webhook/endpoint"); @@ -5203,6 +5314,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "PUT"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal(reqUrl.pathname, "/v2/bot/channel/webhook/endpoint"); @@ -5243,6 +5355,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "POST"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal(reqUrl.pathname, "/v2/bot/chat/loading/start"); @@ -5283,6 +5396,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "POST"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal(reqUrl.pathname, "/v2/bot/chat/loading/start"); @@ -5323,6 +5437,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "POST"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal(reqUrl.pathname, "/v2/bot/channel/webhook/test"); @@ -5363,6 +5478,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "POST"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal(reqUrl.pathname, "/v2/bot/channel/webhook/test"); @@ -5403,6 +5519,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "DELETE"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -5446,6 +5563,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "DELETE"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -5489,6 +5607,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "POST"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal(reqUrl.pathname, "/v2/bot/richmenu/bulk/unlink"); @@ -5529,6 +5648,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "POST"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal(reqUrl.pathname, "/v2/bot/richmenu/bulk/unlink"); @@ -5569,6 +5689,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "POST"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -5618,6 +5739,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "POST"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -5667,6 +5789,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "POST"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal(reqUrl.pathname, "/v2/bot/message/validate/broadcast"); @@ -5707,6 +5830,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "POST"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal(reqUrl.pathname, "/v2/bot/message/validate/broadcast"); @@ -5747,6 +5871,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "POST"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal(reqUrl.pathname, "/v2/bot/message/validate/multicast"); @@ -5787,6 +5912,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "POST"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal(reqUrl.pathname, "/v2/bot/message/validate/multicast"); @@ -5827,6 +5953,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "POST"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal(reqUrl.pathname, "/v2/bot/message/validate/narrowcast"); @@ -5867,6 +5994,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "POST"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal(reqUrl.pathname, "/v2/bot/message/validate/narrowcast"); @@ -5907,6 +6035,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "POST"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal(reqUrl.pathname, "/v2/bot/message/validate/push"); @@ -5947,6 +6076,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "POST"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal(reqUrl.pathname, "/v2/bot/message/validate/push"); @@ -5987,6 +6117,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "POST"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal(reqUrl.pathname, "/v2/bot/message/validate/reply"); @@ -6027,6 +6158,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "POST"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal(reqUrl.pathname, "/v2/bot/message/validate/reply"); @@ -6067,6 +6199,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "POST"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal(reqUrl.pathname, "/v2/bot/richmenu/validate/batch"); @@ -6107,6 +6240,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "POST"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal(reqUrl.pathname, "/v2/bot/richmenu/validate/batch"); @@ -6147,6 +6281,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "POST"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal(reqUrl.pathname, "/v2/bot/richmenu/validate"); @@ -6187,6 +6322,7 @@ describe("MessagingApiClient", () => { requestCount++; equal(req.method, "POST"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal(reqUrl.pathname, "/v2/bot/richmenu/validate"); diff --git a/lib/middleware.ts b/lib/middleware.ts index 1e6fefdbd..2a8eef980 100644 --- a/lib/middleware.ts +++ b/lib/middleware.ts @@ -83,7 +83,7 @@ export default function middleware(config: Types.MiddlewareConfig): Middleware { req.body = JSON.parse(strBody); next(); } catch (err) { - const { message } = err; + const message = err instanceof Error ? err.message : String(err); next(new JSONParseError(message, { raw: strBody })); } diff --git a/lib/module-attach/api/lineModuleAttachClient.ts b/lib/module-attach/api/lineModuleAttachClient.ts index cdd5f7cc3..b143ac51f 100644 --- a/lib/module-attach/api/lineModuleAttachClient.ts +++ b/lib/module-attach/api/lineModuleAttachClient.ts @@ -133,11 +133,34 @@ export class LineModuleAttachClient { scope: scope, brand_type: brandType, }; - Object.keys(formParams).forEach((key: keyof typeof formParams) => { - if (formParams[key] === undefined) { - delete formParams[key]; - } - }); + + if (formParams["code_verifier"] === undefined) { + delete formParams["code_verifier"]; + } + + if (formParams["client_id"] === undefined) { + delete formParams["client_id"]; + } + + if (formParams["client_secret"] === undefined) { + delete formParams["client_secret"]; + } + + if (formParams["region"] === undefined) { + delete formParams["region"]; + } + + if (formParams["basic_search_id"] === undefined) { + delete formParams["basic_search_id"]; + } + + if (formParams["scope"] === undefined) { + delete formParams["scope"]; + } + + if (formParams["brand_type"] === undefined) { + delete formParams["brand_type"]; + } const res = await this.httpClient.postForm( "/module/auth/v1/token", diff --git a/lib/module-attach/tests/api/LineModuleAttachClientTest.spec.ts b/lib/module-attach/tests/api/LineModuleAttachClientTest.spec.ts index baee98d0b..c53d3dc06 100644 --- a/lib/module-attach/tests/api/LineModuleAttachClientTest.spec.ts +++ b/lib/module-attach/tests/api/LineModuleAttachClientTest.spec.ts @@ -64,6 +64,7 @@ describe("LineModuleAttachClient", () => { requestCount++; equal(req.method, "POST"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -144,6 +145,7 @@ describe("LineModuleAttachClient", () => { requestCount++; equal(req.method, "POST"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, diff --git a/lib/module/api/lineModuleClient.ts b/lib/module/api/lineModuleClient.ts index f619d29e0..f0cffc335 100644 --- a/lib/module/api/lineModuleClient.ts +++ b/lib/module/api/lineModuleClient.ts @@ -155,11 +155,14 @@ export class LineModuleClient { start: start, limit: limit, }; - Object.keys(queryParams).forEach((key: keyof typeof queryParams) => { - if (queryParams[key] === undefined) { - delete queryParams[key]; - } - }); + + if (queryParams["start"] === undefined) { + delete queryParams["start"]; + } + + if (queryParams["limit"] === undefined) { + delete queryParams["limit"]; + } const res = await this.httpClient.get("/v2/bot/list", queryParams); const text = await res.text(); diff --git a/lib/module/tests/api/LineModuleClientTest.spec.ts b/lib/module/tests/api/LineModuleClientTest.spec.ts index 5cba550e8..e59c4a20c 100644 --- a/lib/module/tests/api/LineModuleClientTest.spec.ts +++ b/lib/module/tests/api/LineModuleClientTest.spec.ts @@ -66,6 +66,7 @@ describe("LineModuleClient", () => { requestCount++; equal(req.method, "POST"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -112,6 +113,7 @@ describe("LineModuleClient", () => { requestCount++; equal(req.method, "POST"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -158,6 +160,7 @@ describe("LineModuleClient", () => { requestCount++; equal(req.method, "POST"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal(reqUrl.pathname, "/v2/bot/channel/detach"); @@ -198,6 +201,7 @@ describe("LineModuleClient", () => { requestCount++; equal(req.method, "POST"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal(reqUrl.pathname, "/v2/bot/channel/detach"); @@ -238,6 +242,7 @@ describe("LineModuleClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -303,6 +308,7 @@ describe("LineModuleClient", () => { requestCount++; equal(req.method, "GET"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -368,6 +374,7 @@ describe("LineModuleClient", () => { requestCount++; equal(req.method, "POST"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, @@ -411,6 +418,7 @@ describe("LineModuleClient", () => { requestCount++; equal(req.method, "POST"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal( reqUrl.pathname, diff --git a/lib/shop/tests/api/ShopClientTest.spec.ts b/lib/shop/tests/api/ShopClientTest.spec.ts index 43fbb108d..32ead8cec 100644 --- a/lib/shop/tests/api/ShopClientTest.spec.ts +++ b/lib/shop/tests/api/ShopClientTest.spec.ts @@ -64,6 +64,7 @@ describe("ShopClient", () => { requestCount++; equal(req.method, "POST"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal(reqUrl.pathname, "/shop/v3/mission"); @@ -104,6 +105,7 @@ describe("ShopClient", () => { requestCount++; equal(req.method, "POST"); + ok(req.url); const reqUrl = new URL(req.url, "http://localhost/"); equal(reqUrl.pathname, "/shop/v3/mission"); diff --git a/package-lock.json b/package-lock.json index dd06f1cbb..648bd2bf3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -23,7 +23,7 @@ "publint": "0.3.18", "typedoc": "^0.28.14", "typedoc-plugin-markdown": "^4.3.0", - "typescript": "^5.5.4", + "typescript": "^6.0.0", "vitepress": "^1.0.1", "vitest": "^3.0.0" }, @@ -5591,9 +5591,9 @@ } }, "node_modules/typescript": { - "version": "5.9.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz", - "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-6.0.2.tgz", + "integrity": "sha512-bGdAIrZ0wiGDo5l8c++HWtbaNCWTS4UTv7RaTH/ThVIgjkveJt83m74bBHMJkuCbslY8ixgLBVZJIOiQlQTjfQ==", "dev": true, "license": "Apache-2.0", "bin": { diff --git a/package.json b/package.json index 055163e7d..e823bff31 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,8 @@ "!dist/cjs/*/tests" ], "scripts": { - "test": "npm run format && npm run build && vitest run", + "test": "npm run format && npm run typecheck && npm run build && vitest run", + "typecheck": "tsc -p tsconfig.dev.json", "covtest": "vitest run --coverage", "prettier": "prettier \"{lib,test}/**/*.ts\" \"scripts/**/*.{mjs,cjs,js}\" \"examples/**/*.{ts,js,mjs}\"", "format": "npm run prettier -- --write", @@ -75,7 +76,7 @@ "publint": "0.3.18", "typedoc": "^0.28.14", "typedoc-plugin-markdown": "^4.3.0", - "typescript": "^5.5.4", + "typescript": "^6.0.0", "vitepress": "^1.0.1", "vitest": "^3.0.0" }, diff --git a/test/helpers/test-server.ts b/test/helpers/test-server.ts index d4f67e8b5..c377fce06 100644 --- a/test/helpers/test-server.ts +++ b/test/helpers/test-server.ts @@ -8,7 +8,7 @@ import { JSONParseError, SignatureValidationFailed, } from "../../lib/exceptions.js"; -import * as finalhandler from "finalhandler"; +import finalhandler from "finalhandler"; // Use a map to store multiple server instances let servers: Map = new Map(); diff --git a/test/libs-webhook.spec.ts b/test/libs-webhook.spec.ts index 3af39e975..ac2b26ac2 100644 --- a/test/libs-webhook.spec.ts +++ b/test/libs-webhook.spec.ts @@ -25,7 +25,7 @@ describe("webhook", () => { }); it("unknownEvent", async () => { - const event: webhook.Event = { + const event = { type: "greatNewEvent", greatNewField: "aaaa", timestamp: 333333, @@ -34,8 +34,8 @@ describe("webhook", () => { deliveryContext: { isRedelivery: false, }, - }; + } as unknown as webhook.Event; // Intentionally casting an unknown event type to test forward compatibility with new event types. - console.assert(event.type === "greatNewEvent"); + console.assert(event.type === ("greatNewEvent" as string)); // Same reason as above. }); }); diff --git a/test/middleware.spec.ts b/test/middleware.spec.ts index e6247055f..861022e0e 100644 --- a/test/middleware.spec.ts +++ b/test/middleware.spec.ts @@ -277,7 +277,7 @@ describe("middleware test", () => { { description: "construct with no channelSecret", setup: () => { - middleware({ channelSecret: null }); + middleware({ channelSecret: null as unknown as string }); // Intentionally passing null to test runtime validation. }, expectedMessage: "no channel secret", }, @@ -289,7 +289,7 @@ describe("middleware test", () => { setup(); ok(false); } catch (err) { - equal(err.message, expectedMessage); + equal((err as Error).message, expectedMessage); } }); }); diff --git a/tsconfig.cjs.json b/tsconfig.cjs.json index 336c2f507..a17ebca4e 100644 --- a/tsconfig.cjs.json +++ b/tsconfig.cjs.json @@ -1,12 +1,16 @@ +// Build config for CJS output (dist/cjs/), used for the CommonJS publish path. +// Some settings must stay in sync with tsconfig.json. { "compilerOptions": { "module": "CommonJS", "target": "es2017", + "rootDir": "lib", "outDir": "./dist/cjs", "sourceMap": true, "declarationMap": true, "declaration": true, - "rootDirs": ["lib"] + "rootDirs": ["lib"], + "types": ["node"] }, "include": [ "lib/**/*.ts", diff --git a/tsconfig.dev.json b/tsconfig.dev.json new file mode 100644 index 000000000..dae6a7244 --- /dev/null +++ b/tsconfig.dev.json @@ -0,0 +1,13 @@ +// Type-check all TypeScript files regardless of build output (dist). +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "noEmit": true, + "rootDir": ".", + }, + "include": [ + "lib/**/*.ts", + "test/**/*.ts", + "vite.config.ts" + ], +} diff --git a/tsconfig.json b/tsconfig.json index 58f20519d..ee7c525c9 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,15 +1,18 @@ +// Build config for ESM output (dist/). +// Some settings must stay in sync with tsconfig.cjs.json. { "compilerOptions": { "module": "ESNext", "moduleResolution": "Bundler", "target": "ES2022", - "esModuleInterop": true, "noImplicitAny": true, "newLine": "LF", "sourceMap": true, "declarationMap": true, "outDir": "dist", + "rootDir": "lib", "rootDirs": ["lib", "test"], + "types": ["node"], "declaration": true, }, "include": [