m2m-components 6.2.0 → 6.2.1-alpha-1745306890332-ebabd11.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/{chunk-NQAHYFHI.mjs → chunk-4KB6V4QR.mjs} +4 -4
- package/{chunk-AJUMESCA.mjs → chunk-5MWKIL3R.mjs} +4 -4
- package/feedback/index.mjs +2 -2
- package/index.js +0 -18
- package/index.js.map +1 -1
- package/index.mjs +2 -7
- package/package.json +1 -1
- package/storage/refreshAuth.mjs +2 -2
- package/storage/useM2mAuth.mjs +2 -2
- package/chunk-BTRXDURR.mjs +0 -82
- package/chunk-BTRXDURR.mjs.map +0 -1
- package/chunk-HU2F6K3T.mjs +0 -26
- package/chunk-HU2F6K3T.mjs.map +0 -1
- package/chunk-JJLKJEBX.mjs +0 -53
- package/chunk-JJLKJEBX.mjs.map +0 -1
- package/chunk-LOFCW66C.mjs +0 -1
- package/chunk-LOFCW66C.mjs.map +0 -1
- package/chunk-Z3W2Q5MZ.mjs +0 -113
- package/chunk-Z3W2Q5MZ.mjs.map +0 -1
- package/endpoints/m2m-notifications.d.mts +0 -7
- package/endpoints/m2m-notifications.d.ts +0 -7
- package/endpoints/m2m-notifications.js +0 -130
- package/endpoints/m2m-notifications.js.map +0 -1
- package/endpoints/m2m-notifications.mjs +0 -11
- package/endpoints/m2m-notifications.mjs.map +0 -1
- package/endpoints/m2m-notifications.v1.d.mts +0 -1
- package/endpoints/m2m-notifications.v1.d.ts +0 -1
- package/endpoints/m2m-notifications.v1.js +0 -128
- package/endpoints/m2m-notifications.v1.js.map +0 -1
- package/endpoints/m2m-notifications.v1.mjs +0 -22
- package/endpoints/m2m-notifications.v1.mjs.map +0 -1
- package/m2m-notifications.v1-DiG2GtnZ.d.mts +0 -64
- package/m2m-notifications.v1-DiG2GtnZ.d.ts +0 -64
- package/notification/NotificationProvider.d.mts +0 -18
- package/notification/NotificationProvider.d.ts +0 -18
- package/notification/NotificationProvider.js +0 -211
- package/notification/NotificationProvider.js.map +0 -1
- package/notification/NotificationProvider.mjs +0 -14
- package/notification/NotificationProvider.mjs.map +0 -1
- package/notification/ServiceIdProvider.d.mts +0 -10
- package/notification/ServiceIdProvider.d.ts +0 -10
- package/notification/ServiceIdProvider.js +0 -61
- package/notification/ServiceIdProvider.js.map +0 -1
- package/notification/ServiceIdProvider.mjs +0 -10
- package/notification/ServiceIdProvider.mjs.map +0 -1
- package/notification/api.d.mts +0 -7
- package/notification/api.d.ts +0 -7
- package/notification/api.js +0 -163
- package/notification/api.js.map +0 -1
- package/notification/api.mjs +0 -13
- package/notification/api.mjs.map +0 -1
- package/notification/domain.d.mts +0 -24
- package/notification/domain.d.ts +0 -24
- package/notification/domain.js +0 -19
- package/notification/domain.js.map +0 -1
- package/notification/domain.mjs +0 -1
- package/notification/domain.mjs.map +0 -1
- package/notification/index.d.mts +0 -6
- package/notification/index.d.ts +0 -6
- package/notification/index.js +0 -271
- package/notification/index.js.map +0 -1
- package/notification/index.mjs +0 -28
- package/notification/index.mjs.map +0 -1
- /package/{chunk-NQAHYFHI.mjs.map → chunk-4KB6V4QR.mjs.map} +0 -0
- /package/{chunk-AJUMESCA.mjs.map → chunk-5MWKIL3R.mjs.map} +0 -0
|
@@ -1,211 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
|
|
30
|
-
// src/notification/NotificationProvider.tsx
|
|
31
|
-
var NotificationProvider_exports = {};
|
|
32
|
-
__export(NotificationProvider_exports, {
|
|
33
|
-
NotificationsProvider: () => NotificationsProvider,
|
|
34
|
-
useNotificationPermission: () => useNotificationPermission,
|
|
35
|
-
useNotifications: () => useNotifications
|
|
36
|
-
});
|
|
37
|
-
module.exports = __toCommonJS(NotificationProvider_exports);
|
|
38
|
-
var import_react2 = require("react");
|
|
39
|
-
|
|
40
|
-
// src/endpoints/m2m-notifications.v1.ts
|
|
41
|
-
var root = () => {
|
|
42
|
-
let __root = "";
|
|
43
|
-
if (globalThis.M2M_COMPONENTS_ENV === "local") {
|
|
44
|
-
__root = "";
|
|
45
|
-
}
|
|
46
|
-
if (globalThis.M2M_COMPONENTS_ENV === "localDev") {
|
|
47
|
-
__root = "";
|
|
48
|
-
}
|
|
49
|
-
if (globalThis.M2M_COMPONENTS_ENV === "development") {
|
|
50
|
-
__root = "https://api-notifications.dev.m2msystems.cloud";
|
|
51
|
-
}
|
|
52
|
-
if (globalThis.M2M_COMPONENTS_ENV === "production") {
|
|
53
|
-
__root = "https://api-notifications.m2msystems.cloud";
|
|
54
|
-
}
|
|
55
|
-
return __root;
|
|
56
|
-
};
|
|
57
|
-
var healthCheck = () => {
|
|
58
|
-
const __root = root();
|
|
59
|
-
const __queries = Object.entries({}).filter(([_, value]) => {
|
|
60
|
-
return value !== void 0;
|
|
61
|
-
}).map(([key, value]) => {
|
|
62
|
-
return `${key}=${value}`;
|
|
63
|
-
}).join("&");
|
|
64
|
-
const __path = `${__root}/${`health_check`}`;
|
|
65
|
-
return __queries ? `${__path}?${__queries}` : __path;
|
|
66
|
-
};
|
|
67
|
-
var registerNotification = () => {
|
|
68
|
-
const __root = root();
|
|
69
|
-
const __queries = Object.entries({}).filter(([_, value]) => {
|
|
70
|
-
return value !== void 0;
|
|
71
|
-
}).map(([key, value]) => {
|
|
72
|
-
return `${key}=${value}`;
|
|
73
|
-
}).join("&");
|
|
74
|
-
const __path = `${__root}/${`notifications`}`;
|
|
75
|
-
return __queries ? `${__path}?${__queries}` : __path;
|
|
76
|
-
};
|
|
77
|
-
var findNotificationsByServiceId = ({ id }) => {
|
|
78
|
-
const __root = root();
|
|
79
|
-
const __queries = Object.entries({}).filter(([_, value]) => {
|
|
80
|
-
return value !== void 0;
|
|
81
|
-
}).map(([key, value]) => {
|
|
82
|
-
return `${key}=${value}`;
|
|
83
|
-
}).join("&");
|
|
84
|
-
const __path = `${__root}/${`notifications/by_service_id/${id}`}`;
|
|
85
|
-
return __queries ? `${__path}?${__queries}` : __path;
|
|
86
|
-
};
|
|
87
|
-
var updateNotificationStatus = ({ id }) => {
|
|
88
|
-
const __root = root();
|
|
89
|
-
const __queries = Object.entries({}).filter(([_, value]) => {
|
|
90
|
-
return value !== void 0;
|
|
91
|
-
}).map(([key, value]) => {
|
|
92
|
-
return `${key}=${value}`;
|
|
93
|
-
}).join("&");
|
|
94
|
-
const __path = `${__root}/${`notifications/${id}`}`;
|
|
95
|
-
return __queries ? `${__path}?${__queries}` : __path;
|
|
96
|
-
};
|
|
97
|
-
var saveSubscription = () => {
|
|
98
|
-
const __root = root();
|
|
99
|
-
const __queries = Object.entries({}).filter(([_, value]) => {
|
|
100
|
-
return value !== void 0;
|
|
101
|
-
}).map(([key, value]) => {
|
|
102
|
-
return `${key}=${value}`;
|
|
103
|
-
}).join("&");
|
|
104
|
-
const __path = `${__root}/${`subscriptions`}`;
|
|
105
|
-
return __queries ? `${__path}?${__queries}` : __path;
|
|
106
|
-
};
|
|
107
|
-
var findMySubscriptions = () => {
|
|
108
|
-
const __root = root();
|
|
109
|
-
const __queries = Object.entries({}).filter(([_, value]) => {
|
|
110
|
-
return value !== void 0;
|
|
111
|
-
}).map(([key, value]) => {
|
|
112
|
-
return `${key}=${value}`;
|
|
113
|
-
}).join("&");
|
|
114
|
-
const __path = `${__root}/${`subscriptions`}`;
|
|
115
|
-
return __queries ? `${__path}?${__queries}` : __path;
|
|
116
|
-
};
|
|
117
|
-
var m2mNotifications_v1 = {
|
|
118
|
-
healthCheck,
|
|
119
|
-
registerNotification,
|
|
120
|
-
findNotificationsByServiceId,
|
|
121
|
-
updateNotificationStatus,
|
|
122
|
-
saveSubscription,
|
|
123
|
-
findMySubscriptions
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
// src/notification/NotificationProvider.tsx
|
|
127
|
-
var import_matsuri_hooks = require("matsuri-hooks");
|
|
128
|
-
var import_react3 = require("react");
|
|
129
|
-
|
|
130
|
-
// src/notification/ServiceIdProvider.tsx
|
|
131
|
-
var import_react = __toESM(require("react"));
|
|
132
|
-
var import_jsx_runtime = require("@emotion/react/jsx-runtime");
|
|
133
|
-
var ServiceIdContext = (0, import_react.createContext)(
|
|
134
|
-
void 0
|
|
135
|
-
);
|
|
136
|
-
var useServiceId = () => {
|
|
137
|
-
const context = import_react.default.useContext(ServiceIdContext);
|
|
138
|
-
if (context === void 0) {
|
|
139
|
-
throw new Error("useServiceId must be used within a ServiceIdProvider");
|
|
140
|
-
}
|
|
141
|
-
return context.serviceId;
|
|
142
|
-
};
|
|
143
|
-
|
|
144
|
-
// src/notification/NotificationProvider.tsx
|
|
145
|
-
var import_jsx_runtime2 = require("@emotion/react/jsx-runtime");
|
|
146
|
-
var NotificationPermissionContext = (0, import_react2.createContext)(void 0);
|
|
147
|
-
var NotificationsContext = (0, import_react2.createContext)(void 0);
|
|
148
|
-
var NotificationsProvider = ({
|
|
149
|
-
token,
|
|
150
|
-
children
|
|
151
|
-
}) => {
|
|
152
|
-
const serviceId = useServiceId();
|
|
153
|
-
const { data: subscriptions, refetch: refetchSubscriptions } = (0, import_matsuri_hooks.useAuthFetch)(token, m2mNotifications_v1.findMySubscriptions(), {});
|
|
154
|
-
const checkPermission = (0, import_react2.useCallback)(
|
|
155
|
-
(notificationType) => {
|
|
156
|
-
const subscription = subscriptions == null ? void 0 : subscriptions.find((item) => {
|
|
157
|
-
return item.serviceId === serviceId && item.notificationType === notificationType && item.resourceSubscription.resourceSelectType === "any";
|
|
158
|
-
});
|
|
159
|
-
return subscription == null ? void 0 : subscription.status;
|
|
160
|
-
},
|
|
161
|
-
[serviceId, subscriptions]
|
|
162
|
-
);
|
|
163
|
-
const {
|
|
164
|
-
data: notifications,
|
|
165
|
-
error,
|
|
166
|
-
refetch: refetchNotifications
|
|
167
|
-
} = (0, import_matsuri_hooks.useAuthFetch)(
|
|
168
|
-
token,
|
|
169
|
-
m2mNotifications_v1.findNotificationsByServiceId({ id: serviceId }),
|
|
170
|
-
{ swrConfig: { refreshInterval: 1e3 * 60 * 5 } }
|
|
171
|
-
);
|
|
172
|
-
if (error) {
|
|
173
|
-
console.error(error);
|
|
174
|
-
}
|
|
175
|
-
const permissionContextState = (0, import_react3.useMemo)(() => {
|
|
176
|
-
return {
|
|
177
|
-
checkPermission,
|
|
178
|
-
refetch: refetchSubscriptions
|
|
179
|
-
};
|
|
180
|
-
}, [checkPermission, refetchSubscriptions]);
|
|
181
|
-
const notificationsContextState = (0, import_react3.useMemo)(() => {
|
|
182
|
-
var _a, _b;
|
|
183
|
-
return {
|
|
184
|
-
notifications: (_a = notifications == null ? void 0 : notifications.data) != null ? _a : [],
|
|
185
|
-
isAllRead: (_b = notifications == null ? void 0 : notifications.data.every((n) => n.status === "read")) != null ? _b : true,
|
|
186
|
-
refetch: refetchNotifications
|
|
187
|
-
};
|
|
188
|
-
}, [refetchNotifications, notifications == null ? void 0 : notifications.data]);
|
|
189
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(NotificationPermissionContext.Provider, { value: permissionContextState, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(NotificationsContext.Provider, { value: notificationsContextState, children }) });
|
|
190
|
-
};
|
|
191
|
-
var useNotifications = () => {
|
|
192
|
-
const ctx = (0, import_react2.useContext)(NotificationsContext);
|
|
193
|
-
if (!ctx) {
|
|
194
|
-
throw new Error("NotificatoinProvider is not found");
|
|
195
|
-
}
|
|
196
|
-
return ctx;
|
|
197
|
-
};
|
|
198
|
-
var useNotificationPermission = () => {
|
|
199
|
-
const ctx = (0, import_react2.useContext)(NotificationPermissionContext);
|
|
200
|
-
if (!ctx) {
|
|
201
|
-
throw new Error("NotificatoinProvider is not found");
|
|
202
|
-
}
|
|
203
|
-
return ctx;
|
|
204
|
-
};
|
|
205
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
206
|
-
0 && (module.exports = {
|
|
207
|
-
NotificationsProvider,
|
|
208
|
-
useNotificationPermission,
|
|
209
|
-
useNotifications
|
|
210
|
-
});
|
|
211
|
-
//# sourceMappingURL=NotificationProvider.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/notification/NotificationProvider.tsx","../../src/endpoints/m2m-notifications.v1.ts","../../src/notification/ServiceIdProvider.tsx"],"sourcesContent":["import { Notification, Subscription, SubscriptionStatus } from \"./domain\";\nimport {\n PropsWithChildren,\n createContext,\n useCallback,\n useContext,\n} from \"react\";\nimport { m2mNotifications_v1 } from \"../endpoints/m2m-notifications.v1\";\nimport { useAuthFetch } from \"matsuri-hooks\";\nimport { useMemo } from \"react\";\nimport { useServiceId } from \"./ServiceIdProvider\";\n\nconst NotificationPermissionContext = createContext<\n | {\n checkPermission: (\n notificationType: string,\n ) => SubscriptionStatus | undefined;\n refetch: () => void;\n }\n | undefined\n>(undefined);\n\nconst NotificationsContext = createContext<\n | { notifications: Notification[]; isAllRead: boolean; refetch: () => void }\n | undefined\n>(undefined);\n\n// ServiceIdProviderの中で使うこと\nexport const NotificationsProvider = ({\n token,\n children,\n}: PropsWithChildren<{ token: string }>) => {\n const serviceId = useServiceId();\n\n const { data: subscriptions, refetch: refetchSubscriptions } = useAuthFetch<\n Subscription[]\n >(token, m2mNotifications_v1.findMySubscriptions(), {});\n const checkPermission = useCallback(\n (notificationType: string) => {\n const subscription = subscriptions?.find((item) => {\n return (\n item.serviceId === serviceId &&\n item.notificationType === notificationType &&\n item.resourceSubscription.resourceSelectType === \"any\"\n );\n });\n\n return subscription?.status;\n },\n [serviceId, subscriptions],\n );\n\n const {\n data: notifications,\n error,\n refetch: refetchNotifications,\n } = useAuthFetch<{ data: Notification[] }>(\n token,\n m2mNotifications_v1.findNotificationsByServiceId({ id: serviceId }),\n { swrConfig: { refreshInterval: 1000 * 60 * 5 } },\n );\n if (error) {\n // エラーが出てもユーザーは特に困らないので、ユーザーに伝える必要はないが、監視は必要。\n console.error(error);\n }\n\n const permissionContextState = useMemo(() => {\n return {\n checkPermission,\n refetch: refetchSubscriptions,\n };\n }, [checkPermission, refetchSubscriptions]);\n\n const notificationsContextState = useMemo(() => {\n return {\n notifications: notifications?.data ?? [],\n isAllRead: notifications?.data.every((n) => n.status === \"read\") ?? true,\n refetch: refetchNotifications,\n };\n }, [refetchNotifications, notifications?.data]);\n\n return (\n <NotificationPermissionContext.Provider value={permissionContextState}>\n <NotificationsContext.Provider value={notificationsContextState}>\n {children}\n </NotificationsContext.Provider>\n </NotificationPermissionContext.Provider>\n );\n};\n\nexport const useNotifications = () => {\n const ctx = useContext(NotificationsContext);\n if (!ctx) {\n throw new Error(\"NotificatoinProvider is not found\");\n }\n\n return ctx;\n};\n\nexport const useNotificationPermission = () => {\n const ctx = useContext(NotificationPermissionContext);\n if (!ctx) {\n throw new Error(\"NotificatoinProvider is not found\");\n }\n\n return ctx;\n};\n","/* eslint-disable */\n/**\n * A function that returns the URL part common to the endpoints.\n */\nexport const root = () => {\n let __root = \"\";\n\n if (globalThis.M2M_COMPONENTS_ENV === \"local\") {\n __root = \"\";\n }\n\n if (globalThis.M2M_COMPONENTS_ENV === \"localDev\") {\n __root = \"\";\n }\n\n if (globalThis.M2M_COMPONENTS_ENV === \"development\") {\n __root = \"https://api-notifications.dev.m2msystems.cloud\";\n }\n\n if (globalThis.M2M_COMPONENTS_ENV === \"production\") {\n __root = \"https://api-notifications.m2msystems.cloud\";\n }\n\n return __root;\n};\n/**\n * health check\n *\n */\nexport const healthCheck = () => {\n const __root = root();\n const __queries = Object.entries({})\n .filter(([_, value]) => {\n return value !== undefined;\n })\n .map(([key, value]) => {\n return `${key}=${value}`;\n })\n .join(\"&\");\n const __path = `${__root}/${`health_check`}`;\n return __queries ? `${__path}?${__queries}` : __path;\n};\n\n/**\n * 通知を登録する\n *\n */\nexport const registerNotification = () => {\n const __root = root();\n const __queries = Object.entries({})\n .filter(([_, value]) => {\n return value !== undefined;\n })\n .map(([key, value]) => {\n return `${key}=${value}`;\n })\n .join(\"&\");\n const __path = `${__root}/${`notifications`}`;\n return __queries ? `${__path}?${__queries}` : __path;\n};\n\n/**\n * 自分宛の通知をserviceIdを使って取得する\n *\n */\nexport const findNotificationsByServiceId = ({ id }: { id: string }) => {\n const __root = root();\n const __queries = Object.entries({})\n .filter(([_, value]) => {\n return value !== undefined;\n })\n .map(([key, value]) => {\n return `${key}=${value}`;\n })\n .join(\"&\");\n const __path = `${__root}/${`notifications/by_service_id/${id}`}`;\n return __queries ? `${__path}?${__queries}` : __path;\n};\n\n/**\n * 通知のステータスを更新する\n *\n */\nexport const updateNotificationStatus = ({ id }: { id: string }) => {\n const __root = root();\n const __queries = Object.entries({})\n .filter(([_, value]) => {\n return value !== undefined;\n })\n .map(([key, value]) => {\n return `${key}=${value}`;\n })\n .join(\"&\");\n const __path = `${__root}/${`notifications/${id}`}`;\n return __queries ? `${__path}?${__queries}` : __path;\n};\n\n/**\n * 通知の購読を更新する\n *\n */\nexport const saveSubscription = () => {\n const __root = root();\n const __queries = Object.entries({})\n .filter(([_, value]) => {\n return value !== undefined;\n })\n .map(([key, value]) => {\n return `${key}=${value}`;\n })\n .join(\"&\");\n const __path = `${__root}/${`subscriptions`}`;\n return __queries ? `${__path}?${__queries}` : __path;\n};\n\n/**\n * 自分の購読している通知を取得する\n *\n */\nexport const findMySubscriptions = () => {\n const __root = root();\n const __queries = Object.entries({})\n .filter(([_, value]) => {\n return value !== undefined;\n })\n .map(([key, value]) => {\n return `${key}=${value}`;\n })\n .join(\"&\");\n const __path = `${__root}/${`subscriptions`}`;\n return __queries ? `${__path}?${__queries}` : __path;\n};\nexport const m2mNotifications_v1 = {\n healthCheck,\n registerNotification,\n findNotificationsByServiceId,\n updateNotificationStatus,\n saveSubscription,\n findMySubscriptions,\n};\n","import React, { createContext, useMemo } from \"react\";\n\ninterface ServiceIdContextState {\n serviceId: string;\n}\n\nconst ServiceIdContext = createContext<ServiceIdContextState | undefined>(\n undefined,\n);\n\nexport const ServiceIdProvider = ({\n serviceId,\n children,\n}: {\n serviceId: string;\n children: React.ReactNode;\n}) => {\n const state = useMemo(() => ({ serviceId }), [serviceId]);\n\n return (\n <ServiceIdContext.Provider value={state}>\n {children}\n </ServiceIdContext.Provider>\n );\n};\n\nexport const useServiceId = () => {\n const context = React.useContext(ServiceIdContext);\n if (context === undefined) {\n throw new Error(\"useServiceId must be used within a ServiceIdProvider\");\n }\n return context.serviceId;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA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AA,IAClE,EAAE,WAAW,EAAE,iBAAiB,MAAO,KAAK,EAAE,EAAE;AAAA,EAClD;AACA,MAAI,OAAO;AAET,YAAQ,MAAM,KAAK;AAAA,EACrB;AAEA,QAAM,6BAAyB,uBAAQ,MAAM;AAC3C,WAAO;AAAA,MACL;AAAA,MACA,SAAS;AAAA,IACX;AAAA,EACF,GAAG,CAAC,iBAAiB,oBAAoB,CAAC;AAE1C,QAAM,gCAA4B,uBAAQ,MAAM;AAzElD;AA0EI,WAAO;AAAA,MACL,gBAAe,oDAAe,SAAf,YAAuB,CAAC;AAAA,MACvC,YAAW,oDAAe,KAAK,MAAM,CAAC,MAAM,EAAE,WAAW,YAA9C,YAAyD;AAAA,MACpE,SAAS;AAAA,IACX;AAAA,EACF,GAAG,CAAC,sBAAsB,+CAAe,IAAI,CAAC;AAE9C,SACE,6CAAC,8BAA8B,UAA9B,EAAuC,OAAO,wBAC7C,uDAAC,qBAAqB,UAArB,EAA8B,OAAO,2BACnC,UACH,GACF;AAEJ;AAEO,IAAM,mBAAmB,MAAM;AACpC,QAAM,UAAM,0BAAW,oBAAoB;AAC3C,MAAI,CAAC,KAAK;AACR,UAAM,IAAI,MAAM,mCAAmC;AAAA,EACrD;AAEA,SAAO;AACT;AAEO,IAAM,4BAA4B,MAAM;AAC7C,QAAM,UAAM,0BAAW,6BAA6B;AACpD,MAAI,CAAC,KAAK;AACR,UAAM,IAAI,MAAM,mCAAmC;AAAA,EACrD;AAEA,SAAO;AACT;","names":["import_react","import_react","React","import_jsx_runtime"]}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
NotificationsProvider,
|
|
3
|
-
useNotificationPermission,
|
|
4
|
-
useNotifications
|
|
5
|
-
} from "../chunk-BTRXDURR.mjs";
|
|
6
|
-
import "../chunk-HU2F6K3T.mjs";
|
|
7
|
-
import "../chunk-Z3W2Q5MZ.mjs";
|
|
8
|
-
import "../chunk-ZOXT4E27.mjs";
|
|
9
|
-
export {
|
|
10
|
-
NotificationsProvider,
|
|
11
|
-
useNotificationPermission,
|
|
12
|
-
useNotifications
|
|
13
|
-
};
|
|
14
|
-
//# sourceMappingURL=NotificationProvider.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import * as _emotion_react_jsx_runtime from '@emotion/react/jsx-runtime';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
|
|
4
|
-
declare const ServiceIdProvider: ({ serviceId, children, }: {
|
|
5
|
-
serviceId: string;
|
|
6
|
-
children: React.ReactNode;
|
|
7
|
-
}) => _emotion_react_jsx_runtime.JSX.Element;
|
|
8
|
-
declare const useServiceId: () => string;
|
|
9
|
-
|
|
10
|
-
export { ServiceIdProvider, useServiceId };
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import * as _emotion_react_jsx_runtime from '@emotion/react/jsx-runtime';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
|
|
4
|
-
declare const ServiceIdProvider: ({ serviceId, children, }: {
|
|
5
|
-
serviceId: string;
|
|
6
|
-
children: React.ReactNode;
|
|
7
|
-
}) => _emotion_react_jsx_runtime.JSX.Element;
|
|
8
|
-
declare const useServiceId: () => string;
|
|
9
|
-
|
|
10
|
-
export { ServiceIdProvider, useServiceId };
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
|
|
30
|
-
// src/notification/ServiceIdProvider.tsx
|
|
31
|
-
var ServiceIdProvider_exports = {};
|
|
32
|
-
__export(ServiceIdProvider_exports, {
|
|
33
|
-
ServiceIdProvider: () => ServiceIdProvider,
|
|
34
|
-
useServiceId: () => useServiceId
|
|
35
|
-
});
|
|
36
|
-
module.exports = __toCommonJS(ServiceIdProvider_exports);
|
|
37
|
-
var import_react = __toESM(require("react"));
|
|
38
|
-
var import_jsx_runtime = require("@emotion/react/jsx-runtime");
|
|
39
|
-
var ServiceIdContext = (0, import_react.createContext)(
|
|
40
|
-
void 0
|
|
41
|
-
);
|
|
42
|
-
var ServiceIdProvider = ({
|
|
43
|
-
serviceId,
|
|
44
|
-
children
|
|
45
|
-
}) => {
|
|
46
|
-
const state = (0, import_react.useMemo)(() => ({ serviceId }), [serviceId]);
|
|
47
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ServiceIdContext.Provider, { value: state, children });
|
|
48
|
-
};
|
|
49
|
-
var useServiceId = () => {
|
|
50
|
-
const context = import_react.default.useContext(ServiceIdContext);
|
|
51
|
-
if (context === void 0) {
|
|
52
|
-
throw new Error("useServiceId must be used within a ServiceIdProvider");
|
|
53
|
-
}
|
|
54
|
-
return context.serviceId;
|
|
55
|
-
};
|
|
56
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
57
|
-
0 && (module.exports = {
|
|
58
|
-
ServiceIdProvider,
|
|
59
|
-
useServiceId
|
|
60
|
-
});
|
|
61
|
-
//# sourceMappingURL=ServiceIdProvider.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/notification/ServiceIdProvider.tsx"],"sourcesContent":["import React, { createContext, useMemo } from \"react\";\n\ninterface ServiceIdContextState {\n serviceId: string;\n}\n\nconst ServiceIdContext = createContext<ServiceIdContextState | undefined>(\n undefined,\n);\n\nexport const ServiceIdProvider = ({\n serviceId,\n children,\n}: {\n serviceId: string;\n children: React.ReactNode;\n}) => {\n const state = useMemo(() => ({ serviceId }), [serviceId]);\n\n return (\n <ServiceIdContext.Provider value={state}>\n {children}\n </ServiceIdContext.Provider>\n );\n};\n\nexport const useServiceId = () => {\n const context = React.useContext(ServiceIdContext);\n if (context === undefined) {\n throw new Error(\"useServiceId must be used within a ServiceIdProvider\");\n }\n return context.serviceId;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA8C;AAoB1C;AAdJ,IAAM,uBAAmB;AAAA,EACvB;AACF;AAEO,IAAM,oBAAoB,CAAC;AAAA,EAChC;AAAA,EACA;AACF,MAGM;AACJ,QAAM,YAAQ,sBAAQ,OAAO,EAAE,UAAU,IAAI,CAAC,SAAS,CAAC;AAExD,SACE,4CAAC,iBAAiB,UAAjB,EAA0B,OAAO,OAC/B,UACH;AAEJ;AAEO,IAAM,eAAe,MAAM;AAChC,QAAM,UAAU,aAAAA,QAAM,WAAW,gBAAgB;AACjD,MAAI,YAAY,QAAW;AACzB,UAAM,IAAI,MAAM,sDAAsD;AAAA,EACxE;AACA,SAAO,QAAQ;AACjB;","names":["React"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/notification/api.d.mts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { Subscription } from './domain.mjs';
|
|
2
|
-
|
|
3
|
-
declare const requestUpdateNotificationStatusToRead: (token: string, id: string) => Promise<void>;
|
|
4
|
-
declare const requestSubscribe: (token: string, serviceId: string, input: Pick<Subscription, "notificationType" | "resourceSubscription">) => Promise<void>;
|
|
5
|
-
declare const requestUnSubscribe: (token: string, serviceId: string, input: Pick<Subscription, "notificationType" | "resourceSubscription">) => Promise<void>;
|
|
6
|
-
|
|
7
|
-
export { requestSubscribe, requestUnSubscribe, requestUpdateNotificationStatusToRead };
|
package/notification/api.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { Subscription } from './domain.js';
|
|
2
|
-
|
|
3
|
-
declare const requestUpdateNotificationStatusToRead: (token: string, id: string) => Promise<void>;
|
|
4
|
-
declare const requestSubscribe: (token: string, serviceId: string, input: Pick<Subscription, "notificationType" | "resourceSubscription">) => Promise<void>;
|
|
5
|
-
declare const requestUnSubscribe: (token: string, serviceId: string, input: Pick<Subscription, "notificationType" | "resourceSubscription">) => Promise<void>;
|
|
6
|
-
|
|
7
|
-
export { requestSubscribe, requestUnSubscribe, requestUpdateNotificationStatusToRead };
|
package/notification/api.js
DELETED
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/notification/api.ts
|
|
21
|
-
var api_exports = {};
|
|
22
|
-
__export(api_exports, {
|
|
23
|
-
requestSubscribe: () => requestSubscribe,
|
|
24
|
-
requestUnSubscribe: () => requestUnSubscribe,
|
|
25
|
-
requestUpdateNotificationStatusToRead: () => requestUpdateNotificationStatusToRead
|
|
26
|
-
});
|
|
27
|
-
module.exports = __toCommonJS(api_exports);
|
|
28
|
-
var import_matsuri_hooks = require("matsuri-hooks");
|
|
29
|
-
|
|
30
|
-
// src/endpoints/m2m-notifications.v1.ts
|
|
31
|
-
var root = () => {
|
|
32
|
-
let __root = "";
|
|
33
|
-
if (globalThis.M2M_COMPONENTS_ENV === "local") {
|
|
34
|
-
__root = "";
|
|
35
|
-
}
|
|
36
|
-
if (globalThis.M2M_COMPONENTS_ENV === "localDev") {
|
|
37
|
-
__root = "";
|
|
38
|
-
}
|
|
39
|
-
if (globalThis.M2M_COMPONENTS_ENV === "development") {
|
|
40
|
-
__root = "https://api-notifications.dev.m2msystems.cloud";
|
|
41
|
-
}
|
|
42
|
-
if (globalThis.M2M_COMPONENTS_ENV === "production") {
|
|
43
|
-
__root = "https://api-notifications.m2msystems.cloud";
|
|
44
|
-
}
|
|
45
|
-
return __root;
|
|
46
|
-
};
|
|
47
|
-
var healthCheck = () => {
|
|
48
|
-
const __root = root();
|
|
49
|
-
const __queries = Object.entries({}).filter(([_, value]) => {
|
|
50
|
-
return value !== void 0;
|
|
51
|
-
}).map(([key, value]) => {
|
|
52
|
-
return `${key}=${value}`;
|
|
53
|
-
}).join("&");
|
|
54
|
-
const __path = `${__root}/${`health_check`}`;
|
|
55
|
-
return __queries ? `${__path}?${__queries}` : __path;
|
|
56
|
-
};
|
|
57
|
-
var registerNotification = () => {
|
|
58
|
-
const __root = root();
|
|
59
|
-
const __queries = Object.entries({}).filter(([_, value]) => {
|
|
60
|
-
return value !== void 0;
|
|
61
|
-
}).map(([key, value]) => {
|
|
62
|
-
return `${key}=${value}`;
|
|
63
|
-
}).join("&");
|
|
64
|
-
const __path = `${__root}/${`notifications`}`;
|
|
65
|
-
return __queries ? `${__path}?${__queries}` : __path;
|
|
66
|
-
};
|
|
67
|
-
var findNotificationsByServiceId = ({ id }) => {
|
|
68
|
-
const __root = root();
|
|
69
|
-
const __queries = Object.entries({}).filter(([_, value]) => {
|
|
70
|
-
return value !== void 0;
|
|
71
|
-
}).map(([key, value]) => {
|
|
72
|
-
return `${key}=${value}`;
|
|
73
|
-
}).join("&");
|
|
74
|
-
const __path = `${__root}/${`notifications/by_service_id/${id}`}`;
|
|
75
|
-
return __queries ? `${__path}?${__queries}` : __path;
|
|
76
|
-
};
|
|
77
|
-
var updateNotificationStatus = ({ id }) => {
|
|
78
|
-
const __root = root();
|
|
79
|
-
const __queries = Object.entries({}).filter(([_, value]) => {
|
|
80
|
-
return value !== void 0;
|
|
81
|
-
}).map(([key, value]) => {
|
|
82
|
-
return `${key}=${value}`;
|
|
83
|
-
}).join("&");
|
|
84
|
-
const __path = `${__root}/${`notifications/${id}`}`;
|
|
85
|
-
return __queries ? `${__path}?${__queries}` : __path;
|
|
86
|
-
};
|
|
87
|
-
var saveSubscription = () => {
|
|
88
|
-
const __root = root();
|
|
89
|
-
const __queries = Object.entries({}).filter(([_, value]) => {
|
|
90
|
-
return value !== void 0;
|
|
91
|
-
}).map(([key, value]) => {
|
|
92
|
-
return `${key}=${value}`;
|
|
93
|
-
}).join("&");
|
|
94
|
-
const __path = `${__root}/${`subscriptions`}`;
|
|
95
|
-
return __queries ? `${__path}?${__queries}` : __path;
|
|
96
|
-
};
|
|
97
|
-
var findMySubscriptions = () => {
|
|
98
|
-
const __root = root();
|
|
99
|
-
const __queries = Object.entries({}).filter(([_, value]) => {
|
|
100
|
-
return value !== void 0;
|
|
101
|
-
}).map(([key, value]) => {
|
|
102
|
-
return `${key}=${value}`;
|
|
103
|
-
}).join("&");
|
|
104
|
-
const __path = `${__root}/${`subscriptions`}`;
|
|
105
|
-
return __queries ? `${__path}?${__queries}` : __path;
|
|
106
|
-
};
|
|
107
|
-
var m2mNotifications_v1 = {
|
|
108
|
-
healthCheck,
|
|
109
|
-
registerNotification,
|
|
110
|
-
findNotificationsByServiceId,
|
|
111
|
-
updateNotificationStatus,
|
|
112
|
-
saveSubscription,
|
|
113
|
-
findMySubscriptions
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
// src/notification/api.ts
|
|
117
|
-
var requestUpdateNotificationStatusToRead = async (token, id) => {
|
|
118
|
-
await (0, import_matsuri_hooks.fetcher)(
|
|
119
|
-
m2mNotifications_v1.updateNotificationStatus({
|
|
120
|
-
id
|
|
121
|
-
}),
|
|
122
|
-
{
|
|
123
|
-
method: "PUT",
|
|
124
|
-
token,
|
|
125
|
-
body: JSON.stringify({ status: "read" })
|
|
126
|
-
}
|
|
127
|
-
);
|
|
128
|
-
};
|
|
129
|
-
var requestSubscribe = async (token, serviceId, input) => {
|
|
130
|
-
const { error } = await (0, import_matsuri_hooks.fetcher)(m2mNotifications_v1.saveSubscription(), {
|
|
131
|
-
method: "POST",
|
|
132
|
-
token,
|
|
133
|
-
body: JSON.stringify({
|
|
134
|
-
...input,
|
|
135
|
-
serviceId,
|
|
136
|
-
status: "subscribed"
|
|
137
|
-
})
|
|
138
|
-
});
|
|
139
|
-
if (error) {
|
|
140
|
-
console.error(error);
|
|
141
|
-
}
|
|
142
|
-
};
|
|
143
|
-
var requestUnSubscribe = async (token, serviceId, input) => {
|
|
144
|
-
const { error } = await (0, import_matsuri_hooks.fetcher)(m2mNotifications_v1.saveSubscription(), {
|
|
145
|
-
method: "POST",
|
|
146
|
-
token,
|
|
147
|
-
body: JSON.stringify({
|
|
148
|
-
...input,
|
|
149
|
-
serviceId,
|
|
150
|
-
status: "denied"
|
|
151
|
-
})
|
|
152
|
-
});
|
|
153
|
-
if (error) {
|
|
154
|
-
console.error(error);
|
|
155
|
-
}
|
|
156
|
-
};
|
|
157
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
158
|
-
0 && (module.exports = {
|
|
159
|
-
requestSubscribe,
|
|
160
|
-
requestUnSubscribe,
|
|
161
|
-
requestUpdateNotificationStatusToRead
|
|
162
|
-
});
|
|
163
|
-
//# sourceMappingURL=api.js.map
|
package/notification/api.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/notification/api.ts","../../src/endpoints/m2m-notifications.v1.ts"],"sourcesContent":["import { Subscription } from \"./domain\";\nimport { fetcher } from \"matsuri-hooks\";\nimport { m2mNotifications_v1 } from \"../endpoints/m2m-notifications.v1\";\n\nexport const requestUpdateNotificationStatusToRead = async (\n token: string,\n id: string,\n) => {\n await fetcher(\n m2mNotifications_v1.updateNotificationStatus({\n id,\n }),\n {\n method: \"PUT\",\n token,\n body: JSON.stringify({ status: \"read\" }),\n },\n );\n};\n\nexport const requestSubscribe = async (\n token: string,\n serviceId: string,\n input: Pick<Subscription, \"notificationType\" | \"resourceSubscription\">,\n) => {\n const { error } = await fetcher(m2mNotifications_v1.saveSubscription(), {\n method: \"POST\",\n token,\n body: JSON.stringify({\n ...input,\n serviceId,\n status: \"subscribed\",\n }),\n });\n if (error) {\n console.error(error);\n }\n};\n\nexport const requestUnSubscribe = async (\n token: string,\n serviceId: string,\n input: Pick<Subscription, \"notificationType\" | \"resourceSubscription\">,\n) => {\n const { error } = await fetcher(m2mNotifications_v1.saveSubscription(), {\n method: \"POST\",\n token,\n body: JSON.stringify({\n ...input,\n serviceId,\n status: \"denied\",\n }),\n });\n if (error) {\n console.error(error);\n }\n};\n","/* eslint-disable */\n/**\n * A function that returns the URL part common to the endpoints.\n */\nexport const root = () => {\n let __root = \"\";\n\n if (globalThis.M2M_COMPONENTS_ENV === \"local\") {\n __root = \"\";\n }\n\n if (globalThis.M2M_COMPONENTS_ENV === \"localDev\") {\n __root = \"\";\n }\n\n if (globalThis.M2M_COMPONENTS_ENV === \"development\") {\n __root = \"https://api-notifications.dev.m2msystems.cloud\";\n }\n\n if (globalThis.M2M_COMPONENTS_ENV === \"production\") {\n __root = \"https://api-notifications.m2msystems.cloud\";\n }\n\n return __root;\n};\n/**\n * health check\n *\n */\nexport const healthCheck = () => {\n const __root = root();\n const __queries = Object.entries({})\n .filter(([_, value]) => {\n return value !== undefined;\n })\n .map(([key, value]) => {\n return `${key}=${value}`;\n })\n .join(\"&\");\n const __path = `${__root}/${`health_check`}`;\n return __queries ? `${__path}?${__queries}` : __path;\n};\n\n/**\n * 通知を登録する\n *\n */\nexport const registerNotification = () => {\n const __root = root();\n const __queries = Object.entries({})\n .filter(([_, value]) => {\n return value !== undefined;\n })\n .map(([key, value]) => {\n return `${key}=${value}`;\n })\n .join(\"&\");\n const __path = `${__root}/${`notifications`}`;\n return __queries ? `${__path}?${__queries}` : __path;\n};\n\n/**\n * 自分宛の通知をserviceIdを使って取得する\n *\n */\nexport const findNotificationsByServiceId = ({ id }: { id: string }) => {\n const __root = root();\n const __queries = Object.entries({})\n .filter(([_, value]) => {\n return value !== undefined;\n })\n .map(([key, value]) => {\n return `${key}=${value}`;\n })\n .join(\"&\");\n const __path = `${__root}/${`notifications/by_service_id/${id}`}`;\n return __queries ? `${__path}?${__queries}` : __path;\n};\n\n/**\n * 通知のステータスを更新する\n *\n */\nexport const updateNotificationStatus = ({ id }: { id: string }) => {\n const __root = root();\n const __queries = Object.entries({})\n .filter(([_, value]) => {\n return value !== undefined;\n })\n .map(([key, value]) => {\n return `${key}=${value}`;\n })\n .join(\"&\");\n const __path = `${__root}/${`notifications/${id}`}`;\n return __queries ? `${__path}?${__queries}` : __path;\n};\n\n/**\n * 通知の購読を更新する\n *\n */\nexport const saveSubscription = () => {\n const __root = root();\n const __queries = Object.entries({})\n .filter(([_, value]) => {\n return value !== undefined;\n })\n .map(([key, value]) => {\n return `${key}=${value}`;\n })\n .join(\"&\");\n const __path = `${__root}/${`subscriptions`}`;\n return __queries ? `${__path}?${__queries}` : __path;\n};\n\n/**\n * 自分の購読している通知を取得する\n *\n */\nexport const findMySubscriptions = () => {\n const __root = root();\n const __queries = Object.entries({})\n .filter(([_, value]) => {\n return value !== undefined;\n })\n .map(([key, value]) => {\n return `${key}=${value}`;\n })\n .join(\"&\");\n const __path = `${__root}/${`subscriptions`}`;\n return __queries ? `${__path}?${__queries}` : __path;\n};\nexport const m2mNotifications_v1 = {\n healthCheck,\n registerNotification,\n findNotificationsByServiceId,\n updateNotificationStatus,\n saveSubscription,\n findMySubscriptions,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,2BAAwB;;;ACGjB,IAAM,OAAO,MAAM;AACxB,MAAI,SAAS;AAEb,MAAI,WAAW,uBAAuB,SAAS;AAC7C,aAAS;AAAA,EACX;AAEA,MAAI,WAAW,uBAAuB,YAAY;AAChD,aAAS;AAAA,EACX;AAEA,MAAI,WAAW,uBAAuB,eAAe;AACnD,aAAS;AAAA,EACX;AAEA,MAAI,WAAW,uBAAuB,cAAc;AAClD,aAAS;AAAA,EACX;AAEA,SAAO;AACT;AAKO,IAAM,cAAc,MAAM;AAC/B,QAAM,SAAS,KAAK;AACpB,QAAM,YAAY,OAAO,QAAQ,CAAC,CAAC,EAChC,OAAO,CAAC,CAAC,GAA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;AAAA,MACA,MAAM,KAAK,UAAU,EAAE,QAAQ,OAAO,CAAC;AAAA,IACzC;AAAA,EACF;AACF;AAEO,IAAM,mBAAmB,OAC9B,OACA,WACA,UACG;AACH,QAAM,EAAE,MAAM,IAAI,UAAM,8BAAQ,oBAAoB,iBAAiB,GAAG;AAAA,IACtE,QAAQ;AAAA,IACR;AAAA,IACA,MAAM,KAAK,UAAU;AAAA,MACnB,GAAG;AAAA,MACH;AAAA,MACA,QAAQ;AAAA,IACV,CAAC;AAAA,EACH,CAAC;AACD,MAAI,OAAO;AACT,YAAQ,MAAM,KAAK;AAAA,EACrB;AACF;AAEO,IAAM,qBAAqB,OAChC,OACA,WACA,UACG;AACH,QAAM,EAAE,MAAM,IAAI,UAAM,8BAAQ,oBAAoB,iBAAiB,GAAG;AAAA,IACtE,QAAQ;AAAA,IACR;AAAA,IACA,MAAM,KAAK,UAAU;AAAA,MACnB,GAAG;AAAA,MACH;AAAA,MACA,QAAQ;AAAA,IACV,CAAC;AAAA,EACH,CAAC;AACD,MAAI,OAAO;AACT,YAAQ,MAAM,KAAK;AAAA,EACrB;AACF;","names":[]}
|
package/notification/api.mjs
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
requestSubscribe,
|
|
3
|
-
requestUnSubscribe,
|
|
4
|
-
requestUpdateNotificationStatusToRead
|
|
5
|
-
} from "../chunk-JJLKJEBX.mjs";
|
|
6
|
-
import "../chunk-Z3W2Q5MZ.mjs";
|
|
7
|
-
import "../chunk-ZOXT4E27.mjs";
|
|
8
|
-
export {
|
|
9
|
-
requestSubscribe,
|
|
10
|
-
requestUnSubscribe,
|
|
11
|
-
requestUpdateNotificationStatusToRead
|
|
12
|
-
};
|
|
13
|
-
//# sourceMappingURL=api.mjs.map
|
package/notification/api.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
interface Notification {
|
|
2
|
-
createdAt: number;
|
|
3
|
-
id: string;
|
|
4
|
-
message: string;
|
|
5
|
-
notificationType: string;
|
|
6
|
-
resourceId: string;
|
|
7
|
-
serviceId: string;
|
|
8
|
-
status: "unread" | "read";
|
|
9
|
-
userId: string;
|
|
10
|
-
}
|
|
11
|
-
interface ResourceSubscription {
|
|
12
|
-
resourceSelectType: "specific" | "any";
|
|
13
|
-
resourceId: string;
|
|
14
|
-
}
|
|
15
|
-
type SubscriptionStatus = "default" | "subscribed" | "denied";
|
|
16
|
-
interface Subscription {
|
|
17
|
-
userId: string;
|
|
18
|
-
serviceId: string;
|
|
19
|
-
notificationType: string;
|
|
20
|
-
resourceSubscription: ResourceSubscription;
|
|
21
|
-
status: SubscriptionStatus;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export type { Notification, ResourceSubscription, Subscription, SubscriptionStatus };
|
package/notification/domain.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
interface Notification {
|
|
2
|
-
createdAt: number;
|
|
3
|
-
id: string;
|
|
4
|
-
message: string;
|
|
5
|
-
notificationType: string;
|
|
6
|
-
resourceId: string;
|
|
7
|
-
serviceId: string;
|
|
8
|
-
status: "unread" | "read";
|
|
9
|
-
userId: string;
|
|
10
|
-
}
|
|
11
|
-
interface ResourceSubscription {
|
|
12
|
-
resourceSelectType: "specific" | "any";
|
|
13
|
-
resourceId: string;
|
|
14
|
-
}
|
|
15
|
-
type SubscriptionStatus = "default" | "subscribed" | "denied";
|
|
16
|
-
interface Subscription {
|
|
17
|
-
userId: string;
|
|
18
|
-
serviceId: string;
|
|
19
|
-
notificationType: string;
|
|
20
|
-
resourceSubscription: ResourceSubscription;
|
|
21
|
-
status: SubscriptionStatus;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export type { Notification, ResourceSubscription, Subscription, SubscriptionStatus };
|
package/notification/domain.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __copyProps = (to, from, except, desc) => {
|
|
7
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
-
for (let key of __getOwnPropNames(from))
|
|
9
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
-
}
|
|
12
|
-
return to;
|
|
13
|
-
};
|
|
14
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
-
|
|
16
|
-
// src/notification/domain.ts
|
|
17
|
-
var domain_exports = {};
|
|
18
|
-
module.exports = __toCommonJS(domain_exports);
|
|
19
|
-
//# sourceMappingURL=domain.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/notification/domain.ts"],"sourcesContent":["export interface Notification {\n createdAt: number;\n id: string;\n message: string;\n notificationType: string;\n resourceId: string;\n serviceId: string;\n status: \"unread\" | \"read\";\n userId: string;\n}\n\nexport interface ResourceSubscription {\n resourceSelectType: \"specific\" | \"any\";\n resourceId: string;\n}\n\nexport type SubscriptionStatus = \"default\" | \"subscribed\" | \"denied\";\n\nexport interface Subscription {\n userId: string;\n serviceId: string;\n notificationType: string;\n resourceSubscription: ResourceSubscription;\n status: SubscriptionStatus;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
package/notification/domain.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=domain.mjs.map
|