@shisyamo4131/air-guard-v2-schemas 2.4.2-dev.75 → 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,6 +14,7 @@ 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";
19
20
  export { default as Notification } from "./src/Notification.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.75",
3
+ "version": "2.4.2-dev.76",
4
4
  "description": "Schemas for AirGuard V2",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -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
+ }
@@ -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,