@logto/connector-http-email 0.2.0 → 0.3.0

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/lib/index.js CHANGED
@@ -92,8 +92,8 @@ var createHttpMailConnector = async ({ getConfig }) => {
92
92
  sendMessage: sendMessage(getConfig)
93
93
  };
94
94
  };
95
- var src_default = createHttpMailConnector;
95
+ var index_default = createHttpMailConnector;
96
96
  export {
97
- src_default as default
97
+ index_default as default
98
98
  };
99
99
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/constant.ts","../src/types.ts"],"sourcesContent":["import { assert } from '@silverhand/essentials';\nimport { got, HTTPError } from 'got';\n\nimport type {\n GetConnectorConfig,\n SendMessageFunction,\n CreateConnector,\n EmailConnector,\n} from '@logto/connector-kit';\nimport {\n ConnectorError,\n ConnectorErrorCodes,\n validateConfig,\n ConnectorType,\n} from '@logto/connector-kit';\n\nimport { defaultMetadata } from './constant.js';\nimport { httpMailConfigGuard } from './types.js';\n\nconst sendMessage =\n (getConfig: GetConnectorConfig): SendMessageFunction =>\n async (data, inputConfig) => {\n const { to, type, payload } = data;\n const config = inputConfig ?? (await getConfig(defaultMetadata.id));\n validateConfig(config, httpMailConfigGuard);\n const { endpoint, authorization } = config;\n\n try {\n return await got.post(endpoint, {\n headers: {\n Authorization: authorization,\n 'Content-Type': 'application/json',\n },\n json: {\n to,\n type,\n payload,\n },\n });\n } catch (error: unknown) {\n if (error instanceof HTTPError) {\n const {\n response: { body: rawBody },\n } = error;\n\n assert(\n typeof rawBody === 'string',\n new ConnectorError(\n ConnectorErrorCodes.InvalidResponse,\n `Invalid response raw body type: ${typeof rawBody}`\n )\n );\n\n throw new ConnectorError(ConnectorErrorCodes.General, rawBody);\n }\n\n throw new ConnectorError(ConnectorErrorCodes.General, error);\n }\n };\n\nconst createHttpMailConnector: CreateConnector<EmailConnector> = async ({ getConfig }) => {\n return {\n metadata: defaultMetadata,\n type: ConnectorType.Email,\n configGuard: httpMailConfigGuard,\n sendMessage: sendMessage(getConfig),\n };\n};\n\nexport default createHttpMailConnector;\n","import type { ConnectorMetadata } from '@logto/connector-kit';\nimport { ConnectorConfigFormItemType } from '@logto/connector-kit';\n\nexport const defaultMetadata: ConnectorMetadata = {\n id: 'http-email',\n target: 'http-email',\n platform: null,\n name: {\n en: 'HTTP Email',\n },\n logo: './logo.svg',\n logoDark: null,\n description: {\n en: 'Send email via HTTP call.',\n },\n readme: './README.md',\n formItems: [\n {\n key: 'endpoint',\n label: 'Endpoint',\n type: ConnectorConfigFormItemType.Text,\n required: true,\n placeholder: '<https://example.com/your-http-endpoint>',\n },\n {\n key: 'authorization',\n label: 'Authorization Header',\n type: ConnectorConfigFormItemType.Text,\n required: false,\n placeholder: '<Bearer your-token>',\n tooltip:\n 'The authorization header to be sent with the request, you can verify the value in your server.',\n },\n ],\n};\n","import { z } from 'zod';\n\nexport const httpMailConfigGuard = z.object({\n endpoint: z.string(),\n authorization: z.string().optional(),\n});\n\nexport type HttpMailConfig = z.infer<typeof httpMailConfigGuard>;\n"],"mappings":";AAAA,SAAS,cAAc;AACvB,SAAS,KAAK,iBAAiB;AAQ/B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;;;ACbP,SAAS,mCAAmC;AAErC,IAAM,kBAAqC;AAAA,EAChD,IAAI;AAAA,EACJ,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,MAAM;AAAA,IACJ,IAAI;AAAA,EACN;AAAA,EACA,MAAM;AAAA,EACN,UAAU;AAAA,EACV,aAAa;AAAA,IACX,IAAI;AAAA,EACN;AAAA,EACA,QAAQ;AAAA,EACR,WAAW;AAAA,IACT;AAAA,MACE,KAAK;AAAA,MACL,OAAO;AAAA,MACP,MAAM,4BAA4B;AAAA,MAClC,UAAU;AAAA,MACV,aAAa;AAAA,IACf;AAAA,IACA;AAAA,MACE,KAAK;AAAA,MACL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.ts","../src/constant.ts","../src/types.ts"],"sourcesContent":["import { assert } from '@silverhand/essentials';\nimport { got, HTTPError } from 'got';\n\nimport type {\n GetConnectorConfig,\n SendMessageFunction,\n CreateConnector,\n EmailConnector,\n} from '@logto/connector-kit';\nimport {\n ConnectorError,\n ConnectorErrorCodes,\n validateConfig,\n ConnectorType,\n} from '@logto/connector-kit';\n\nimport { defaultMetadata } from './constant.js';\nimport { httpMailConfigGuard } from './types.js';\n\nconst sendMessage =\n (getConfig: GetConnectorConfig): SendMessageFunction =>\n async (data, inputConfig) => {\n const { to, type, payload } = data;\n const config = inputConfig ?? (await getConfig(defaultMetadata.id));\n validateConfig(config, httpMailConfigGuard);\n const { endpoint, authorization } = config;\n\n try {\n return await got.post(endpoint, {\n headers: {\n Authorization: authorization,\n 'Content-Type': 'application/json',\n },\n json: {\n to,\n type,\n payload,\n },\n });\n } catch (error: unknown) {\n if (error instanceof HTTPError) {\n const {\n response: { body: rawBody },\n } = error;\n\n assert(\n typeof rawBody === 'string',\n new ConnectorError(\n ConnectorErrorCodes.InvalidResponse,\n `Invalid response raw body type: ${typeof rawBody}`\n )\n );\n\n throw new ConnectorError(ConnectorErrorCodes.General, rawBody);\n }\n\n throw new ConnectorError(ConnectorErrorCodes.General, error);\n }\n };\n\nconst createHttpMailConnector: CreateConnector<EmailConnector> = async ({ getConfig }) => {\n return {\n metadata: defaultMetadata,\n type: ConnectorType.Email,\n configGuard: httpMailConfigGuard,\n sendMessage: sendMessage(getConfig),\n };\n};\n\nexport default createHttpMailConnector;\n","import type { ConnectorMetadata } from '@logto/connector-kit';\nimport { ConnectorConfigFormItemType } from '@logto/connector-kit';\n\nexport const defaultMetadata: ConnectorMetadata = {\n id: 'http-email',\n target: 'http-email',\n platform: null,\n name: {\n en: 'HTTP Email',\n },\n logo: './logo.svg',\n logoDark: null,\n description: {\n en: 'Send email via HTTP call.',\n },\n readme: './README.md',\n formItems: [\n {\n key: 'endpoint',\n label: 'Endpoint',\n type: ConnectorConfigFormItemType.Text,\n required: true,\n placeholder: '<https://example.com/your-http-endpoint>',\n },\n {\n key: 'authorization',\n label: 'Authorization Header',\n type: ConnectorConfigFormItemType.Text,\n required: false,\n placeholder: '<Bearer your-token>',\n tooltip:\n 'The authorization header to be sent with the request, you can verify the value in your server.',\n },\n ],\n};\n","import { z } from 'zod';\n\nexport const httpMailConfigGuard = z.object({\n endpoint: z.string(),\n authorization: z.string().optional(),\n});\n\nexport type HttpMailConfig = z.infer<typeof httpMailConfigGuard>;\n"],"mappings":";AAAA,SAAS,cAAc;AACvB,SAAS,KAAK,iBAAiB;AAQ/B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;;;ACbP,SAAS,mCAAmC;AAErC,IAAM,kBAAqC;AAAA,EAChD,IAAI;AAAA,EACJ,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,MAAM;AAAA,IACJ,IAAI;AAAA,EACN;AAAA,EACA,MAAM;AAAA,EACN,UAAU;AAAA,EACV,aAAa;AAAA,IACX,IAAI;AAAA,EACN;AAAA,EACA,QAAQ;AAAA,EACR,WAAW;AAAA,IACT;AAAA,MACE,KAAK;AAAA,MACL,OAAO;AAAA,MACP,MAAM,4BAA4B;AAAA,MAClC,UAAU;AAAA,MACV,aAAa;AAAA,IACf;AAAA,IACA;AAAA,MACE,KAAK;AAAA,MACL,OAAO;AAAA,MACP,MAAM,4BAA4B;AAAA,MAClC,UAAU;AAAA,MACV,aAAa;AAAA,MACb,SACE;AAAA,IACJ;AAAA,EACF;AACF;;;AClCA,SAAS,SAAS;AAEX,IAAM,sBAAsB,EAAE,OAAO;AAAA,EAC1C,UAAU,EAAE,OAAO;AAAA,EACnB,eAAe,EAAE,OAAO,EAAE,SAAS;AACrC,CAAC;;;AFcD,IAAM,cACJ,CAAC,cACD,OAAO,MAAM,gBAAgB;AAC3B,QAAM,EAAE,IAAI,MAAM,QAAQ,IAAI;AAC9B,QAAM,SAAS,eAAgB,MAAM,UAAU,gBAAgB,EAAE;AACjE,iBAAe,QAAQ,mBAAmB;AAC1C,QAAM,EAAE,UAAU,cAAc,IAAI;AAEpC,MAAI;AACF,WAAO,MAAM,IAAI,KAAK,UAAU;AAAA,MAC9B,SAAS;AAAA,QACP,eAAe;AAAA,QACf,gBAAgB;AAAA,MAClB;AAAA,MACA,MAAM;AAAA,QACJ;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,IACF,CAAC;AAAA,EACH,SAAS,OAAgB;AACvB,QAAI,iBAAiB,WAAW;AAC9B,YAAM;AAAA,QACJ,UAAU,EAAE,MAAM,QAAQ;AAAA,MAC5B,IAAI;AAEJ;AAAA,QACE,OAAO,YAAY;AAAA,QACnB,IAAI;AAAA,UACF,oBAAoB;AAAA,UACpB,mCAAmC,OAAO,OAAO;AAAA,QACnD;AAAA,MACF;AAEA,YAAM,IAAI,eAAe,oBAAoB,SAAS,OAAO;AAAA,IAC/D;AAEA,UAAM,IAAI,eAAe,oBAAoB,SAAS,KAAK;AAAA,EAC7D;AACF;AAEF,IAAM,0BAA2D,OAAO,EAAE,UAAU,MAAM;AACxF,SAAO;AAAA,IACL,UAAU;AAAA,IACV,MAAM,cAAc;AAAA,IACpB,aAAa;AAAA,IACb,aAAa,YAAY,SAAS;AAAA,EACpC;AACF;AAEA,IAAO,gBAAQ;","names":[]}
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@logto/connector-http-email",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Email connector to send email via HTTP call.",
5
5
  "author": "Silverhand Inc. <contact@silverhand.io>",
6
6
  "dependencies": {
7
- "@logto/connector-kit": "^4.0.0",
7
+ "@logto/connector-kit": "^4.3.0",
8
8
  "@silverhand/essentials": "^2.9.1",
9
9
  "got": "^14.0.0",
10
- "zod": "^3.23.8"
10
+ "zod": "^3.24.2"
11
11
  },
12
12
  "main": "./lib/index.js",
13
13
  "module": "./lib/index.js",
@@ -21,7 +21,7 @@
21
21
  "logo-dark.svg"
22
22
  ],
23
23
  "engines": {
24
- "node": "^20.9.0"
24
+ "node": "^22.14.0"
25
25
  },
26
26
  "eslintConfig": {
27
27
  "extends": "@silverhand",
@@ -42,17 +42,17 @@
42
42
  "devDependencies": {
43
43
  "@silverhand/eslint-config": "6.0.1",
44
44
  "@silverhand/ts-config": "6.0.0",
45
- "@types/node": "^20.11.20",
45
+ "@types/node": "^22.14.0",
46
46
  "@types/supertest": "^6.0.2",
47
- "@vitest/coverage-v8": "^2.1.8",
47
+ "@vitest/coverage-v8": "^3.1.1",
48
48
  "eslint": "^8.56.0",
49
49
  "lint-staged": "^15.0.2",
50
- "nock": "^13.3.1",
51
- "prettier": "^3.0.0",
50
+ "nock": "^14.0.3",
51
+ "prettier": "^3.5.3",
52
52
  "supertest": "^7.0.0",
53
53
  "tsup": "^8.3.0",
54
54
  "typescript": "^5.5.3",
55
- "vitest": "^2.1.8"
55
+ "vitest": "^3.1.1"
56
56
  },
57
57
  "scripts": {
58
58
  "precommit": "lint-staged",