@elqnt/notifications 1.0.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/dist/chunk-E6ORNZJX.js +36 -0
- package/dist/chunk-E6ORNZJX.js.map +1 -0
- package/dist/chunk-OPXXF4IO.mjs +36 -0
- package/dist/chunk-OPXXF4IO.mjs.map +1 -0
- package/dist/hooks/index.d.mts +11 -0
- package/dist/hooks/index.d.ts +11 -0
- package/dist/hooks/index.js +9 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/index.mjs +9 -0
- package/dist/hooks/index.mjs.map +1 -0
- package/dist/index.d.mts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +8 -0
- package/dist/index.mjs.map +1 -0
- package/dist/models/index.d.mts +17 -0
- package/dist/models/index.d.ts +17 -0
- package/dist/models/index.js +2 -0
- package/dist/models/index.js.map +1 -0
- package/dist/models/index.mjs +2 -0
- package/dist/models/index.mjs.map +1 -0
- package/package.json +52 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }"use client";
|
|
2
|
+
|
|
3
|
+
// hooks/use-email.ts
|
|
4
|
+
var _react = require('react');
|
|
5
|
+
var _browser = require('@elqnt/api-client/browser');
|
|
6
|
+
function useEmail(options) {
|
|
7
|
+
const apiOptions = _react.useMemo.call(void 0,
|
|
8
|
+
() => ({ baseUrl: options.baseUrl, orgId: options.orgId }),
|
|
9
|
+
[options.baseUrl, options.orgId]
|
|
10
|
+
);
|
|
11
|
+
const send = _react.useCallback.call(void 0,
|
|
12
|
+
async (request) => {
|
|
13
|
+
try {
|
|
14
|
+
const response = await _browser.browserApiRequest.call(void 0,
|
|
15
|
+
"/api/v1/email/send",
|
|
16
|
+
{
|
|
17
|
+
method: "POST",
|
|
18
|
+
body: request,
|
|
19
|
+
...apiOptions
|
|
20
|
+
}
|
|
21
|
+
);
|
|
22
|
+
return _nullishCoalesce(response.data, () => ( null));
|
|
23
|
+
} catch (e) {
|
|
24
|
+
console.warn("Failed to send email notification");
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
[apiOptions]
|
|
29
|
+
);
|
|
30
|
+
return { send };
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
exports.useEmail = useEmail;
|
|
36
|
+
//# sourceMappingURL=chunk-E6ORNZJX.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/eloquent-packages/eloquent-packages/packages/notifications/dist/chunk-E6ORNZJX.js","../hooks/use-email.ts"],"names":[],"mappings":"AAAA,yLAAY;AACZ;AACA;ACAA,8BAAqC;AACrC,oDAAkC;AAS3B,SAAS,QAAA,CAAS,OAAA,EAA0B;AACjD,EAAA,MAAM,WAAA,EAAa,4BAAA;AAAA,IACjB,CAAA,EAAA,GAAA,CAAO,EAAE,OAAA,EAAS,OAAA,CAAQ,OAAA,EAAS,KAAA,EAAO,OAAA,CAAQ,MAAM,CAAA,CAAA;AAAA,IACxD,CAAC,OAAA,CAAQ,OAAA,EAAS,OAAA,CAAQ,KAAK;AAAA,EACjC,CAAA;AAEA,EAAA,MAAM,KAAA,EAAO,gCAAA;AAAA,IACX,MAAA,CAAO,OAAA,EAAA,GAAiE;AACtE,MAAA,IAAI;AACF,QAAA,MAAM,SAAA,EAAW,MAAM,wCAAA;AAAA,UACrB,oBAAA;AAAA,UACA;AAAA,YACE,MAAA,EAAQ,MAAA;AAAA,YACR,IAAA,EAAM,OAAA;AAAA,YACN,GAAG;AAAA,UACL;AAAA,QACF,CAAA;AACA,QAAA,wBAAO,QAAA,CAAS,IAAA,UAAQ,MAAA;AAAA,MAC1B,EAAA,UAAQ;AACN,QAAA,OAAA,CAAQ,IAAA,CAAK,mCAAmC,CAAA;AAChD,QAAA,OAAO,IAAA;AAAA,MACT;AAAA,IACF,CAAA;AAAA,IACA,CAAC,UAAU;AAAA,EACb,CAAA;AAEA,EAAA,OAAO,EAAE,KAAK,CAAA;AAChB;ADRA;AACA;AACE;AACF,4BAAC","file":"/home/runner/work/eloquent-packages/eloquent-packages/packages/notifications/dist/chunk-E6ORNZJX.js","sourcesContent":[null,"\"use client\";\n\nimport { useCallback, useMemo } from \"react\";\nimport { browserApiRequest } from \"@elqnt/api-client/browser\";\nimport type { ApiClientOptions } from \"@elqnt/api-client/browser\";\nimport type { SendEmailRequest, SendEmailResponse } from \"../models\";\n\ninterface UseEmailOptions {\n baseUrl: string;\n orgId: string;\n}\n\nexport function useEmail(options: UseEmailOptions) {\n const apiOptions = useMemo<ApiClientOptions>(\n () => ({ baseUrl: options.baseUrl, orgId: options.orgId }),\n [options.baseUrl, options.orgId]\n );\n\n const send = useCallback(\n async (request: SendEmailRequest): Promise<SendEmailResponse | null> => {\n try {\n const response = await browserApiRequest<SendEmailResponse>(\n \"/api/v1/email/send\",\n {\n method: \"POST\",\n body: request,\n ...apiOptions,\n }\n );\n return response.data ?? null;\n } catch {\n console.warn(\"Failed to send email notification\");\n return null;\n }\n },\n [apiOptions]\n );\n\n return { send };\n}\n"]}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// hooks/use-email.ts
|
|
4
|
+
import { useCallback, useMemo } from "react";
|
|
5
|
+
import { browserApiRequest } from "@elqnt/api-client/browser";
|
|
6
|
+
function useEmail(options) {
|
|
7
|
+
const apiOptions = useMemo(
|
|
8
|
+
() => ({ baseUrl: options.baseUrl, orgId: options.orgId }),
|
|
9
|
+
[options.baseUrl, options.orgId]
|
|
10
|
+
);
|
|
11
|
+
const send = useCallback(
|
|
12
|
+
async (request) => {
|
|
13
|
+
try {
|
|
14
|
+
const response = await browserApiRequest(
|
|
15
|
+
"/api/v1/email/send",
|
|
16
|
+
{
|
|
17
|
+
method: "POST",
|
|
18
|
+
body: request,
|
|
19
|
+
...apiOptions
|
|
20
|
+
}
|
|
21
|
+
);
|
|
22
|
+
return response.data ?? null;
|
|
23
|
+
} catch {
|
|
24
|
+
console.warn("Failed to send email notification");
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
[apiOptions]
|
|
29
|
+
);
|
|
30
|
+
return { send };
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export {
|
|
34
|
+
useEmail
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=chunk-OPXXF4IO.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../hooks/use-email.ts"],"sourcesContent":["\"use client\";\n\nimport { useCallback, useMemo } from \"react\";\nimport { browserApiRequest } from \"@elqnt/api-client/browser\";\nimport type { ApiClientOptions } from \"@elqnt/api-client/browser\";\nimport type { SendEmailRequest, SendEmailResponse } from \"../models\";\n\ninterface UseEmailOptions {\n baseUrl: string;\n orgId: string;\n}\n\nexport function useEmail(options: UseEmailOptions) {\n const apiOptions = useMemo<ApiClientOptions>(\n () => ({ baseUrl: options.baseUrl, orgId: options.orgId }),\n [options.baseUrl, options.orgId]\n );\n\n const send = useCallback(\n async (request: SendEmailRequest): Promise<SendEmailResponse | null> => {\n try {\n const response = await browserApiRequest<SendEmailResponse>(\n \"/api/v1/email/send\",\n {\n method: \"POST\",\n body: request,\n ...apiOptions,\n }\n );\n return response.data ?? null;\n } catch {\n console.warn(\"Failed to send email notification\");\n return null;\n }\n },\n [apiOptions]\n );\n\n return { send };\n}\n"],"mappings":";;;AAEA,SAAS,aAAa,eAAe;AACrC,SAAS,yBAAyB;AAS3B,SAAS,SAAS,SAA0B;AACjD,QAAM,aAAa;AAAA,IACjB,OAAO,EAAE,SAAS,QAAQ,SAAS,OAAO,QAAQ,MAAM;AAAA,IACxD,CAAC,QAAQ,SAAS,QAAQ,KAAK;AAAA,EACjC;AAEA,QAAM,OAAO;AAAA,IACX,OAAO,YAAiE;AACtE,UAAI;AACF,cAAM,WAAW,MAAM;AAAA,UACrB;AAAA,UACA;AAAA,YACE,QAAQ;AAAA,YACR,MAAM;AAAA,YACN,GAAG;AAAA,UACL;AAAA,QACF;AACA,eAAO,SAAS,QAAQ;AAAA,MAC1B,QAAQ;AACN,gBAAQ,KAAK,mCAAmC;AAChD,eAAO;AAAA,MACT;AAAA,IACF;AAAA,IACA,CAAC,UAAU;AAAA,EACb;AAEA,SAAO,EAAE,KAAK;AAChB;","names":[]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { SendEmailRequest, SendEmailResponse } from '../models/index.mjs';
|
|
2
|
+
|
|
3
|
+
interface UseEmailOptions {
|
|
4
|
+
baseUrl: string;
|
|
5
|
+
orgId: string;
|
|
6
|
+
}
|
|
7
|
+
declare function useEmail(options: UseEmailOptions): {
|
|
8
|
+
send: (request: SendEmailRequest) => Promise<SendEmailResponse | null>;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export { useEmail };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { SendEmailRequest, SendEmailResponse } from '../models/index.js';
|
|
2
|
+
|
|
3
|
+
interface UseEmailOptions {
|
|
4
|
+
baseUrl: string;
|
|
5
|
+
orgId: string;
|
|
6
|
+
}
|
|
7
|
+
declare function useEmail(options: UseEmailOptions): {
|
|
8
|
+
send: (request: SendEmailRequest) => Promise<SendEmailResponse | null>;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export { useEmail };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/eloquent-packages/eloquent-packages/packages/notifications/dist/hooks/index.js"],"names":[],"mappings":"AAAA,qFAAY;AACZ,YAAY;AACZ;AACE;AACF,uDAA6B;AAC7B;AACE;AACF,6CAAC","file":"/home/runner/work/eloquent-packages/eloquent-packages/packages/notifications/dist/hooks/index.js"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/index.d.mts
ADDED
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/eloquent-packages/eloquent-packages/packages/notifications/dist/index.js"],"names":[],"mappings":"AAAA,qFAAY;AACZ;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,6CAAC","file":"/home/runner/work/eloquent-packages/eloquent-packages/packages/notifications/dist/index.js"}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SendEmailRequest is the request for sending a pre-rendered notification email
|
|
3
|
+
*/
|
|
4
|
+
interface SendEmailRequest {
|
|
5
|
+
to: string[];
|
|
6
|
+
subject: string;
|
|
7
|
+
body: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* SendEmailResponse is the response from sending an email
|
|
11
|
+
*/
|
|
12
|
+
interface SendEmailResponse {
|
|
13
|
+
success: boolean;
|
|
14
|
+
message?: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export type { SendEmailRequest, SendEmailResponse };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SendEmailRequest is the request for sending a pre-rendered notification email
|
|
3
|
+
*/
|
|
4
|
+
interface SendEmailRequest {
|
|
5
|
+
to: string[];
|
|
6
|
+
subject: string;
|
|
7
|
+
body: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* SendEmailResponse is the response from sending an email
|
|
11
|
+
*/
|
|
12
|
+
interface SendEmailResponse {
|
|
13
|
+
success: boolean;
|
|
14
|
+
message?: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export type { SendEmailRequest, SendEmailResponse };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/eloquent-packages/eloquent-packages/packages/notifications/dist/models/index.js"],"names":[],"mappings":"AAAA,yBAAY","file":"/home/runner/work/eloquent-packages/eloquent-packages/packages/notifications/dist/models/index.js"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@elqnt/notifications",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Notification infrastructure for Eloquent platform (email, push, SMS)",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"module": "./dist/index.mjs",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.mjs",
|
|
12
|
+
"require": "./dist/index.js"
|
|
13
|
+
},
|
|
14
|
+
"./models": {
|
|
15
|
+
"types": "./dist/models/index.d.ts",
|
|
16
|
+
"import": "./dist/models/index.mjs",
|
|
17
|
+
"require": "./dist/models/index.js"
|
|
18
|
+
},
|
|
19
|
+
"./hooks": {
|
|
20
|
+
"types": "./dist/hooks/index.d.ts",
|
|
21
|
+
"import": "./dist/hooks/index.mjs",
|
|
22
|
+
"require": "./dist/hooks/index.js"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"dist"
|
|
27
|
+
],
|
|
28
|
+
"scripts": {
|
|
29
|
+
"build": "tsup",
|
|
30
|
+
"dev": "tsup --watch",
|
|
31
|
+
"clean": "rm -rf dist",
|
|
32
|
+
"typecheck": "tsc --noEmit"
|
|
33
|
+
},
|
|
34
|
+
"repository": {
|
|
35
|
+
"type": "git",
|
|
36
|
+
"url": "git+https://github.com/Blazi-Commerce/eloquent-packages.git",
|
|
37
|
+
"directory": "packages/notifications"
|
|
38
|
+
},
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"@elqnt/api-client": "^1.0.0"
|
|
41
|
+
},
|
|
42
|
+
"peerDependencies": {
|
|
43
|
+
"react": "^18.0.0 || ^19.0.0"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@elqnt/api-client": "^1.0.0",
|
|
47
|
+
"@types/react": "^19.0.0",
|
|
48
|
+
"react": "^19.0.0",
|
|
49
|
+
"tsup": "^8.0.0",
|
|
50
|
+
"typescript": "^5.0.0"
|
|
51
|
+
}
|
|
52
|
+
}
|