@shisyamo4131/air-guard-v2-schemas 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.
Files changed (38) hide show
  1. package/index.js +15 -0
  2. package/package.json +44 -0
  3. package/src/Agreement.js +262 -0
  4. package/src/ArrangementNotification.js +505 -0
  5. package/src/Billing.js +159 -0
  6. package/src/Company.js +176 -0
  7. package/src/Customer.js +98 -0
  8. package/src/Employee.js +201 -0
  9. package/src/Operation.js +779 -0
  10. package/src/OperationBilling.js +193 -0
  11. package/src/OperationDetail.js +147 -0
  12. package/src/OperationResult.js +437 -0
  13. package/src/OperationResultDetail.js +72 -0
  14. package/src/Outsourcer.js +46 -0
  15. package/src/RoundSetting.js +123 -0
  16. package/src/Site.js +192 -0
  17. package/src/SiteOperationSchedule.js +503 -0
  18. package/src/SiteOperationScheduleDetail.js +99 -0
  19. package/src/SiteOrder.js +62 -0
  20. package/src/Tax.js +39 -0
  21. package/src/User.js +41 -0
  22. package/src/WorkingResult.js +297 -0
  23. package/src/apis/index.js +9 -0
  24. package/src/constants/arrangement-notification-status.js +68 -0
  25. package/src/constants/billing-unit-type.js +15 -0
  26. package/src/constants/contract-status.js +15 -0
  27. package/src/constants/day-type.js +44 -0
  28. package/src/constants/employment-status.js +15 -0
  29. package/src/constants/gender.js +11 -0
  30. package/src/constants/index.js +9 -0
  31. package/src/constants/prefectures.js +56 -0
  32. package/src/constants/shift-type.js +20 -0
  33. package/src/constants/site-status.js +15 -0
  34. package/src/parts/accessorDefinitions.js +109 -0
  35. package/src/parts/fieldDefinitions.js +642 -0
  36. package/src/utils/ContextualError.js +49 -0
  37. package/src/utils/CutoffDate.js +223 -0
  38. package/src/utils/index.js +48 -0
@@ -0,0 +1,109 @@
1
+ import { PREFECTURES_ARRAY } from "../constants/prefectures.js";
2
+ /**
3
+ * @typedef {object} AccessorImplementation - アクセサの実装を定義するオブジェクト。
4
+ * @property {function} get - getter関数。
5
+ * @property {function} [set] - setter関数(オプショナル)。
6
+ */
7
+
8
+ /**
9
+ * 各アクセサキーに対応する実装を格納するオブジェクト。
10
+ * @type {Object.<string, AccessorImplementation>}
11
+ */
12
+ const accessorImplementations = {
13
+ customerId: {
14
+ enumerable: true,
15
+ get() {
16
+ return this?.customer?.docId;
17
+ },
18
+ set(value) {
19
+ // No-op setter for read-only access
20
+ },
21
+ },
22
+ fullAddress: {
23
+ enumerable: true,
24
+ get() {
25
+ // 同じオブジェクトに 'prefecture' アクセサが定義されていることを前提とします
26
+ const prefecture = this.prefecture || "";
27
+ const city = this.city || "";
28
+ const address = this.address || "";
29
+ return `${prefecture}${city}${address}`;
30
+ },
31
+ set(value) {
32
+ // No-op setter for read-only access
33
+ },
34
+ },
35
+ fullName: {
36
+ enumerable: true,
37
+ get() {
38
+ if (!this.lastName || !this.firstName) return "";
39
+ return `${this.lastName} ${this.firstName}`;
40
+ },
41
+ set(value) {
42
+ // No-op setter for read-only access
43
+ },
44
+ },
45
+ prefecture: {
46
+ enumerable: true,
47
+ get() {
48
+ if (!this.hasOwnProperty("prefCode")) {
49
+ console.warn(
50
+ "[アクセサ: prefecture] このオブジェクトに prefCode が定義されていません。"
51
+ );
52
+ return "";
53
+ }
54
+
55
+ if (!this.prefCode) return ""; // No warning if prefCode is falsy but present
56
+
57
+ const result = PREFECTURES_ARRAY.find(
58
+ ({ value }) => value === this.prefCode
59
+ );
60
+
61
+ if (!result) {
62
+ console.warn(
63
+ `[アクセサ: prefecture] prefCode '${this.prefCode}' は PREFECTURES_ARRAY に見つかりません。`
64
+ );
65
+ return "";
66
+ }
67
+
68
+ if (!result.hasOwnProperty("title")) {
69
+ console.warn(
70
+ `[アクセサ: prefecture] PREFECTURES_ARRAY の prefCode '${this.prefCode}' に title が定義されていません。`
71
+ );
72
+ return "";
73
+ }
74
+
75
+ return result.title;
76
+ },
77
+ set(value) {
78
+ // No-op setter for read-only access
79
+ },
80
+ },
81
+ };
82
+
83
+ /**
84
+ * `Object.defineProperty` 用のアクセサディスクリプタを生成します。
85
+ *
86
+ * @param {string} key - `accessorImplementations` で検索するためのキー。
87
+ * @param {object} [options={}] - プロパティディスクリプタのオプション。
88
+ * @param {boolean} [options.configurable=true] - `configurable` 属性。
89
+ * @param {boolean} [options.enumerable=true] - `enumerable` 属性。
90
+ * @returns {PropertyDescriptor} `Object.defineProperty` で使用するためのプロパティディスクリプタ。
91
+ * @throws {Error} アクセサキーが見つからない場合。
92
+ */
93
+ export const defAccessor = (
94
+ key,
95
+ { configurable = false, enumerable = false } = {}
96
+ ) => {
97
+ const implementation = accessorImplementations[key];
98
+ if (!implementation) {
99
+ throw new Error(
100
+ `[accessorDefinitions.js defAccessor] キー "${key}" のアクセサ実装が見つかりません。`
101
+ );
102
+ }
103
+
104
+ return {
105
+ ...implementation,
106
+ configurable: configurable || implementation.configurable || false,
107
+ enumerable: enumerable || implementation.enumerable || false,
108
+ };
109
+ };