@shisyamo4131/air-guard-v2-schemas 2.4.2-dev.74 → 2.4.2-dev.76

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/index.js CHANGED
@@ -14,8 +14,11 @@ export { default as Customer, CustomerMinimal } from "./src/Customer.js";
14
14
  export { default as CutoffDate } from "./src/utils/CutoffDate.js";
15
15
  export { default as Employee } from "./src/Employee.js";
16
16
  export { VALIDATION_ERRORS } from "./src/errorDefinitions.js";
17
+ export { default as FcmToken } from "./src/FcmToken.js";
17
18
  export { GeocodableMixin } from "./src/mixins/GeocodableMixin.js";
18
19
  export { default as Insurance } from "./src/Insurance.js";
20
+ export { default as Notification } from "./src/Notification.js";
21
+ export { default as NotificationRecipient } from "./src/NotificationRecipient.js";
19
22
  export { default as OperationBilling } from "./src/OperationBilling.js";
20
23
  export { default as OperationResult } from "./src/OperationResult.js";
21
24
  export { default as OperationResultDetail } from "./src/OperationResultDetail.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shisyamo4131/air-guard-v2-schemas",
3
- "version": "2.4.2-dev.74",
3
+ "version": "2.4.2-dev.76",
4
4
  "description": "Schemas for AirGuard V2",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -16,6 +16,8 @@
16
16
  * @prop {string} actualEndTime - Actual end time (HH:MM format)
17
17
  * @prop {number} actualBreakMinutes - Actual break time (minutes)
18
18
  * @prop {string} status - Arrangement notification status
19
+ * @prop {Date} notificationSentAt - Push notification sent date and time
20
+ * @prop {string} notificationError - Push notification send error message
19
21
  * ---------------------------------------------------------------------------
20
22
  * @computed {Date} actualStartAt - Actual start date and time (Date object) (read-only)
21
23
  * - Returns a Date object with `actualStartTime` set based on `dateAt`.
@@ -159,6 +161,12 @@ const classProps = {
159
161
  default: 60,
160
162
  required: true,
161
163
  }),
164
+ notificationSentAt: defField("notificationSentAt", {
165
+ hidden: true,
166
+ }),
167
+ notificationError: defField("notificationError", {
168
+ hidden: true,
169
+ }),
162
170
  };
163
171
 
164
172
  export default class ArrangementNotification extends SiteOperationScheduleDetail {
@@ -0,0 +1,77 @@
1
+ /*****************************************************************************
2
+ * @file src/FcmToken.js
3
+ *****************************************************************************/
4
+ import FireModel from "@shisyamo4131/air-firebase-v2";
5
+ import { defField } from "./parts/fieldDefinitions.js";
6
+
7
+ /*****************************************************************************
8
+ * @class FcmToken
9
+ * @extends FireModel
10
+ *
11
+ * Firebase Cloud Messaging (FCM) のトークンをグローバル管理するためのコレクション
12
+ *
13
+ * - usePrefix: false でグローバルコレクション(Companies のサブコレクションではない)
14
+ * - ドキュメントID: FCMトークンそのもの
15
+ * - 同じトークンは同じデバイスを指すため、最後にログインしたユーザーの情報で上書きされる
16
+ *
17
+ * @property {string} token - FCMトークン(ドキュメントIDと同じ)
18
+ * @property {string} uid - ユーザーID(Firebase Authentication UID)
19
+ * @property {string} employeeId - 従業員ID
20
+ * @property {string} companyId - 会社ID
21
+ * @property {Date} updatedAt - 最終更新日時
22
+ *****************************************************************************/
23
+ export default class FcmToken extends FireModel {
24
+ static className = "FCMトークン";
25
+ static collectionPath = "FcmTokens";
26
+ static usePrefix = false; // グローバルコレクション
27
+
28
+ static classProps = {
29
+ token: defField("token", {
30
+ required: true,
31
+ hidden: true,
32
+ }),
33
+ uid: defField("uid", {
34
+ required: true,
35
+ hidden: true,
36
+ }),
37
+ employeeId: defField("employeeId", {
38
+ required: true,
39
+ hidden: true,
40
+ }),
41
+ companyId: defField("companyId", {
42
+ required: true,
43
+ hidden: true,
44
+ }),
45
+ updatedAt: defField("dateTimeAt", {
46
+ label: "更新日時",
47
+ default: () => new Date(),
48
+ hidden: true,
49
+ }),
50
+ };
51
+
52
+ /**
53
+ * fcmToken ドキュメントはドキュメントIDにトークンそのものが使われることを前提としているため、
54
+ * create メソッドをオーバーライドして、updateOptions に docId が含まれていることを確認する。
55
+ * @param {*} updateOptions
56
+ * @returns {Promise<DocumentReference>}
57
+ */
58
+ async create(updateOptions = {}) {
59
+ const { docId } = updateOptions;
60
+ if (!docId) {
61
+ throw new Error(
62
+ "FCMトークンのドキュメントIDはトークンそのものを指定してください",
63
+ );
64
+ }
65
+ return await super.create(updateOptions);
66
+ }
67
+
68
+ /**
69
+ * FCMトークンは更新できないため、常にエラーを投げる
70
+ * @param {*} updateOptions
71
+ */
72
+ async update(updateOptions = {}) {
73
+ throw new Error(
74
+ "FCMトークンは更新できません。新しいトークンでドキュメントを作成してください。",
75
+ );
76
+ }
77
+ }
@@ -0,0 +1,95 @@
1
+ /*****************************************************************************
2
+ * @file src/Notification.js
3
+ *****************************************************************************/
4
+ import FireModel from "@shisyamo4131/air-firebase-v2";
5
+ import { defField } from "./parts/fieldDefinitions.js";
6
+
7
+ /*****************************************************************************
8
+ * @class Notification
9
+ * @extends FireModel
10
+ *
11
+ * @description
12
+ * 通知ドキュメントのスキーマ定義。
13
+ * Companies/{companyId}/Notifications/{notificationId} に格納される。
14
+ * 通知の送信履歴と結果を管理するための親ドキュメント。
15
+ *
16
+ * @property {string} title - 通知タイトル
17
+ * @property {string} body - 通知本文
18
+ * @property {string} imageUrl - 画像URL(任意)
19
+ * @property {Object} data - カスタムデータ(任意)
20
+ * @property {Array<string>} recipientUserIds - 送信先ユーザーIDの配列
21
+ * @property {number} totalCount - 送信対象数
22
+ * @property {number} successCount - 送信成功数
23
+ * @property {number} failureCount - 送信失敗数
24
+ * @property {string} status - 送信ステータス(pending, processing, sent, failed, completed)
25
+ * @property {string} sourceType - 送信元タイプ(manual, arrangement, billing など)
26
+ * @property {string} sourceId - 送信元ドキュメントID
27
+ * @property {string} createdBy - 作成者UID
28
+ *
29
+ * @note
30
+ * - status の値:
31
+ * - pending: 送信待ち
32
+ * - processing: 送信中
33
+ * - sent: 送信成功
34
+ * - failed: 送信失敗
35
+ * - completed: 全送信完了
36
+ * - sourceType の例:
37
+ * - manual: 手動送信(UI から)
38
+ * - arrangement: 配置通知
39
+ * - billing: 請求通知
40
+ *
41
+ * @author shisyamo4131
42
+ *****************************************************************************/
43
+ export default class Notification extends FireModel {
44
+ static className = "通知";
45
+ static collectionPath = "Notifications";
46
+ static classProps = {
47
+ title: defField("oneLine", { label: "通知タイトル", required: true }),
48
+ body: defField("multipleLine", { label: "通知本文", required: true }),
49
+ imageUrl: defField("oneLine", { label: "画像URL", required: false }),
50
+ data: defField("object", { label: "カスタムデータ", required: false }),
51
+ recipientUserIds: defField("recipientUserIds", { required: false }),
52
+ totalCount: defField("number", {
53
+ label: "送信対象数",
54
+ default: 0,
55
+ required: false,
56
+ hidden: true,
57
+ }),
58
+ successCount: defField("number", {
59
+ label: "送信成功数",
60
+ default: 0,
61
+ required: false,
62
+ hidden: true,
63
+ }),
64
+ failureCount: defField("number", {
65
+ label: "送信失敗数",
66
+ default: 0,
67
+ required: false,
68
+ hidden: true,
69
+ }),
70
+ status: defField("oneLine", {
71
+ label: "送信ステータス",
72
+ default: "pending",
73
+ required: false,
74
+ hidden: true,
75
+ }),
76
+ sourceType: defField("oneLine", {
77
+ label: "送信元タイプ",
78
+ default: "",
79
+ required: false,
80
+ hidden: true,
81
+ }),
82
+ sourceId: defField("oneLine", {
83
+ label: "送信元ID",
84
+ default: "",
85
+ required: false,
86
+ hidden: true,
87
+ }),
88
+ createdBy: defField("oneLine", {
89
+ label: "作成者",
90
+ default: "",
91
+ required: false,
92
+ hidden: true,
93
+ }),
94
+ };
95
+ }
@@ -0,0 +1,68 @@
1
+ /*****************************************************************************
2
+ * @file src/NotificationRecipient.js
3
+ *****************************************************************************/
4
+ import { BaseClass } from "@shisyamo4131/air-firebase-v2";
5
+ import { defField } from "./parts/fieldDefinitions.js";
6
+
7
+ /*****************************************************************************
8
+ * @class NotificationRecipient
9
+ * @extends BaseClass
10
+ *
11
+ * @description
12
+ * 通知の受信者情報を管理するサブコレクションのスキーマ定義。
13
+ * Companies/{companyId}/Notifications/{notificationId}/Recipients/{recipientId} に格納される。
14
+ * 個別ユーザーごとの送信結果を記録する。
15
+ *
16
+ * @property {string} notificationId - 親 Notification ドキュメントのID
17
+ * @property {string} userId - 受信者のユーザーID
18
+ * @property {string} status - 送信ステータス(pending, sent, failed)
19
+ * @property {Date} sentAt - 送信日時
20
+ * @property {string} error - エラーメッセージ
21
+ *
22
+ * @note
23
+ * - NotificationRecipient は BaseClass を継承(FireModel ではない)
24
+ * - Notification ドキュメントのサブコレクションとして格納される
25
+ * - Cloud Functions のみが作成・更新、アプリ側は読み取り専用
26
+ * - status の値:
27
+ * - pending: 送信待ち
28
+ * - sent: 送信成功
29
+ * - failed: 送信失敗
30
+ * - sentAt: 送信が完了した日時(成功・失敗問わず)
31
+ * - error: 送信失敗時のエラーメッセージ
32
+ *
33
+ * @author shisyamo4131
34
+ *****************************************************************************/
35
+ export default class NotificationRecipient extends BaseClass {
36
+ static className = "通知受信者";
37
+ static classProps = {
38
+ notificationId: defField("oneLine", {
39
+ label: "通知ID",
40
+ default: "",
41
+ required: true,
42
+ hidden: true,
43
+ }),
44
+ userId: defField("oneLine", {
45
+ label: "ユーザーID",
46
+ default: "",
47
+ required: true,
48
+ hidden: true,
49
+ }),
50
+ status: defField("oneLine", {
51
+ label: "送信ステータス",
52
+ default: "pending",
53
+ required: false,
54
+ hidden: true,
55
+ }),
56
+ sentAt: defField("dateTimeAt", {
57
+ label: "送信日時",
58
+ required: false,
59
+ hidden: true,
60
+ }),
61
+ error: defField("oneLine", {
62
+ label: "エラーメッセージ",
63
+ default: "",
64
+ required: false,
65
+ hidden: true,
66
+ }),
67
+ };
68
+ }
@@ -36,4 +36,15 @@ export const arrayFields = {
36
36
  required: false,
37
37
  hidden: false,
38
38
  },
39
+
40
+ /**
41
+ * 通知の送信先ユーザーID配列
42
+ * Notification ドキュメントで使用
43
+ */
44
+ recipientUserIds: {
45
+ ...generalDefinitions.array,
46
+ label: "送信先ユーザーID",
47
+ required: false,
48
+ hidden: true,
49
+ },
39
50
  };
@@ -51,6 +51,11 @@ export const dateAtFields = {
51
51
  label: "資格喪失日",
52
52
  default: null,
53
53
  },
54
+ notificationSentAt: {
55
+ ...generalDefinitions.dateAt,
56
+ label: "通知送信日時",
57
+ default: null,
58
+ },
54
59
  periodOfStay: {
55
60
  ...generalDefinitions.dateAt,
56
61
  label: "在留期間満了日",
@@ -5,6 +5,10 @@ import { generalDefinitions } from "./defaultDefinition.js";
5
5
  */
6
6
  export const multipleLineFields = {
7
7
  multipleLine: generalDefinitions.multipleLine,
8
+ notificationError: {
9
+ ...generalDefinitions.multipleLine,
10
+ label: "通知送信エラー",
11
+ },
8
12
  remarks: {
9
13
  ...generalDefinitions.multipleLine,
10
14
  label: "備考",
@@ -175,6 +175,12 @@ export const oneLineFields = {
175
175
  },
176
176
  },
177
177
 
178
+ /** 従業員ID */
179
+ employeeId: {
180
+ ...generalDefinitions.oneLine,
181
+ label: "従業員ID",
182
+ },
183
+
178
184
  /** FAX番号 */
179
185
  fax: {
180
186
  ...generalDefinitions.oneLine,
@@ -364,6 +370,18 @@ export const oneLineFields = {
364
370
  length: 20,
365
371
  },
366
372
 
373
+ /** token */
374
+ token: {
375
+ ...generalDefinitions.oneLine,
376
+ label: "トークン",
377
+ },
378
+
379
+ /** ユーザーID */
380
+ uid: {
381
+ ...generalDefinitions.oneLine,
382
+ label: "ユーザーID",
383
+ },
384
+
367
385
  /** 作業内容 */
368
386
  workDescription: {
369
387
  ...generalDefinitions.oneLine,