@jsb188/mday 1.1.5 → 1.1.7

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.
@@ -0,0 +1,173 @@
1
+ import { PRODUCT_LIVESTOCK_STATUS, PRODUCT_LIVESTOCK_TYPES, PRODUCT_TYPES } from '../constants/product';
2
+ import type { AccountData } from '@jsb188/app/types/account.d';
3
+ import type { OrganizationData, OrganizationGQL } from './types/organization.d';
4
+ import type { AddressObj, ScheduleObj } from '@jsb188/app/types/other.d';
5
+
6
+ /**
7
+ * Enums
8
+ */
9
+
10
+ export type ProductTypeEnum = typeof PRODUCT_TYPES[number];
11
+ export type ProductLivestockTypeEnum = typeof PRODUCT_LIVESTOCK_TYPES[number];
12
+ export type ProductLivestockStatusEnum = typeof PRODUCT_LIVESTOCK_STATUS[number];
13
+
14
+ /**
15
+ * Filters
16
+ */
17
+
18
+ export interface ProductsFilterArgs {
19
+ preset?: '?' | null;
20
+ productType: ProductTypeEnum;
21
+ query?: string | null;
22
+ calDate?: string | null; // "YYYY-MM-DD"
23
+ timeZone?: string | null; // Server only for now
24
+ // status: ProductLivestockStatusEnum;
25
+ }
26
+
27
+ /**
28
+ * Product details; Livestock
29
+ */
30
+
31
+ export interface ProductLivestockObj {
32
+ // This interface is not ready yet; old system has to be migrated.
33
+ '?': '?';
34
+ }
35
+
36
+ export interface ProductLivestockData {
37
+ __table: 'products_livestock';
38
+ id?: number | bigint;
39
+ productId: number | bigint;
40
+ type: ProductLivestockTypeEnum;
41
+ status: ProductLivestockStatusEnum;
42
+ birthDate?: string | null; // "YYYY-MM-DD"
43
+ deathDate?: string | null; // "YYYY-MM-DD"
44
+ damIdentifier?: string | null;
45
+ livestockIdentifier: string;
46
+ livestockGroup?: string | null;
47
+ metadata: {
48
+ overview: string;
49
+ };
50
+ }
51
+
52
+ export interface ProductLivestockGQL {
53
+ __typename: 'ProductLivestock';
54
+
55
+ id: string;
56
+ organizationId: string;
57
+ damIdentifier: string | null;
58
+ livestockIdentifier: string | null;
59
+ livestockGroup: string | null;
60
+
61
+ type: ProductLivestockTypeEnum;
62
+ status: ProductLivestockStatusEnum;
63
+ livestockClass: string;
64
+
65
+ birthDate: string | null; // "YYYY-MM-DD"
66
+ deathDate: string | null; // "YYYY-MM-DD"
67
+ }
68
+
69
+ /**
70
+ * Product details; Calendar event
71
+ */
72
+
73
+ export interface ProductCalEventObj {
74
+ name: string;
75
+ metadata: Partial<{
76
+ schedule: ScheduleObj | null;
77
+ address: Partial<AddressObj> | null;
78
+ }>;
79
+
80
+ startAt: Date | string; // ISO Date string
81
+ endAt?: Date | string | null; // ISO Date string
82
+ }
83
+
84
+ export interface ProductCalEventData extends ProductCalEventObj {
85
+ __table: 'products_calendar_events';
86
+ productId: number | bigint;
87
+ }
88
+
89
+ export interface ProductCalEventGQL {
90
+ __typename: 'ProductCalEvent';
91
+
92
+ id: string;
93
+ organizationId: string;
94
+
95
+ name: string;
96
+ schedule: ScheduleObj | null;
97
+ address: AddressObj | null;
98
+ startAt: Date;
99
+ endAt: Date;
100
+ }
101
+
102
+ export type ProductDetailsObj = ProductLivestockObj | ProductCalEventObj;
103
+ export type ProductDetailsData = ProductLivestockData | ProductCalEventData;
104
+ export type ProductDetailsGQL = ProductLivestockGQL | ProductCalEventGQL;
105
+
106
+ /**
107
+ * CalEvent; attendance
108
+ */
109
+
110
+ export interface ProductAttendanceObj {
111
+ productId: number | bigint;
112
+ organizationId: number | bigint;
113
+ accountId: number | bigint;
114
+ attended: boolean | null;
115
+ calDate: string; // "YYYY-MM-DD" format
116
+ history?: [string, '0' | '1'][] | null; // [YYYY-MM-DD, '0' | '1'][]
117
+ }
118
+
119
+ export interface ProductAttendanceData extends ProductAttendanceObj {
120
+ __table: 'products_attendance';
121
+ organization: OrganizationData;
122
+ account: AccountData; // account data
123
+ }
124
+
125
+ export interface ProductAttendanceGQL {
126
+ __deleted: boolean; // For client-side only
127
+ id: string;
128
+ productId: string;
129
+ organizationId: string;
130
+ attended: boolean | null;
131
+ calDate: string; // "YYYY-MM-DD" format
132
+ organization: OrganizationGQL;
133
+ checkedBy: any; // account data
134
+ }
135
+
136
+ /**
137
+ * CalEvent; load list
138
+ */
139
+
140
+ export interface ProductLoadListData {
141
+ __table: 'products_load_list';
142
+ organizationId: number | bigint;
143
+ productId: number | bigint;
144
+ calDate: Date; // Postgres returns "date" as JS Date, but it's safe to convert "YYYY-MM-DD" without time zone.
145
+ items: string[][]; // [ [itemName, quantity, unit], ... ]
146
+ createdAt: Date;
147
+ updatedAt: Date;
148
+ }
149
+
150
+ /**
151
+ * Product data objects
152
+ */
153
+
154
+ export interface ProductData {
155
+ __table: 'products';
156
+ productId: number | bigint;
157
+ organizationId: number | bigint;
158
+ details: ProductDetailsData;
159
+ createdAt: Date;
160
+ updatedAt: Date;
161
+ }
162
+
163
+ export interface ProductGQL {
164
+ __deleted?: boolean; // For client-side only
165
+
166
+ id: string;
167
+ organizationId: string;
168
+ cursor: string | null; // Cursor for pagination
169
+ details: ProductDetailsGQL | null;
170
+
171
+ createdAt: string; // ISO Date
172
+ updatedAt: string; // ISO Date
173
+ }
@@ -0,0 +1,203 @@
1
+ import { REPORT_SORT_OPTS, REPORT_TYPES, REPORT_ROW_PRESETS } from '../constants/report';
2
+ import type { StorageData, StorageGQL } from '@jsb188/app/types/storage.d';
3
+
4
+ /**
5
+ * Enums
6
+ */
7
+
8
+ type ReportTypeEnum = typeof REPORT_TYPES[number];
9
+ type ReportRowPresetEnum = typeof REPORT_ROW_PRESETS[number];
10
+ type ReportsSortEnum = typeof REPORT_SORT_OPTS[number];
11
+
12
+ /**
13
+ * Filters
14
+ */
15
+
16
+ export interface ReportsFilterArgs {
17
+ preset?: '?' | null;
18
+ reportType: ReportTypeEnum;
19
+ period: string; // YYYY-MM-DD
20
+ query?: string | null;
21
+ }
22
+
23
+ /**
24
+ * Report; fields
25
+ */
26
+
27
+ interface ReportFieldsObj {
28
+ __allowMultiples?: boolean; // Allow multiple copies of the same report (from 1 report template)
29
+ __notAutomated?: boolean; // If true, report is not skipped during automation
30
+ __prompt: string; // Server-only, this prompt used on the entire report as a whole (ie. OSP generation)
31
+ gridLayoutStyle?: string;
32
+ sections?: ReportFieldsSection[];
33
+ rows?: ReportFieldsRow[];
34
+ metadata?: ReportFieldsRow[];
35
+ variables: {
36
+ month?: number; // Used for MONTH presets (required for all preset="MONTH" rows)
37
+ [key: string]: any;
38
+ };
39
+ }
40
+
41
+ interface ReportFieldsSection {
42
+ id?: string; // GraphQL Cursor, client-side only, but if present in Server, it will be an Array
43
+ key: string; // Every section must have a unique string UID
44
+ isGroupTitle?: boolean;
45
+ sectionKey: string;
46
+ sectionName: string;
47
+ title: string;
48
+ description: string;
49
+ rows?: ReportFieldsRow[];
50
+ requireFileUploads?: boolean;
51
+ files?: StorageData[];
52
+
53
+ __prompt_section?: string; // Server-only; full prompt for this section - this is the only prompt that allows {{variable}} regex
54
+ __prompt_examples?: string; // Server-only; for examples of what the output should be
55
+ __prompt_topics?: string; // Server-only; for topics this section should cover
56
+ }
57
+
58
+ interface ReportFieldsRow {
59
+ id?: string; // GraphQL Cursor, client-side only, but if present in Server, it will be an Array
60
+ key: string; // Key is used to map row/columns to answers
61
+ preset?: ReportRowPresetEnum;
62
+ className?: string;
63
+ isHeader?: boolean;
64
+ columns: Partial<ReportFieldsColumn>[];
65
+ }
66
+
67
+ type ReportRowGQL = Omit<ReportFieldsRow, 'key'> & {
68
+ id: string; // GraphQL Cursor, client-side only, but if present in Server, it will be an Array
69
+ };
70
+
71
+ interface ReportFieldsColumn {
72
+ id: string; // GraphQL Cursor, client-side only, but if present in Server, it will be an Array
73
+ key: string; // Key is used to map column to answers
74
+ className?: string;
75
+ labelClassName?: string;
76
+ label: string;
77
+ text: string;
78
+ placeholder: string | null;
79
+ value: string | null; // Available only in server; this value has the indexes to map answers to directly without keys
80
+ checked: boolean | null;
81
+ }
82
+
83
+ /**
84
+ * Report data
85
+ */
86
+
87
+ export interface ReportData {
88
+ __table: 'reports';
89
+
90
+ id: number;
91
+ type: ReportTypeEnum;
92
+ documentName: string;
93
+ title: string;
94
+ description: string;
95
+ order: number;
96
+
97
+ fields: ReportFieldsObj;
98
+ submission?: ReportSubmissionData | null;
99
+
100
+ template?: {
101
+ __table: 'report_templates';
102
+ id: number;
103
+ fields: ReportFieldsObj;
104
+ description: string | null;
105
+ };
106
+ }
107
+
108
+ export interface ReportGQL {
109
+ __deleted?: boolean;
110
+
111
+ id: string;
112
+ organizationId: string;
113
+ documentName: string;
114
+ title: string;
115
+ description: string;
116
+ type: ReportTypeEnum;
117
+ period: string; // YYYY-MM-DD
118
+ evidencesCount: number;
119
+ activityAt: string | null; // ISO date string
120
+
121
+ sections?: ReportSectionGQL[];
122
+ rows?: ReportRowGQL[];
123
+ }
124
+
125
+ interface ReportSectionGQL {
126
+ id: string;
127
+ isGroupTitle?: boolean;
128
+ sectionKey: string;
129
+ sectionName: string;
130
+ title: string;
131
+ description: string;
132
+ rows?: ReportRowGQL[];
133
+ requireFileUploads?: boolean;
134
+ files?: StorageGQL[];
135
+ }
136
+
137
+ /**
138
+ * Report submission data
139
+ */
140
+
141
+ export interface ReportEvidenceGQL {
142
+ __deleted?: boolean;
143
+
144
+ id: string; // GraphQL Cursor
145
+ reportSubmissionId: string;
146
+ sectionKey: string;
147
+ log: any; // LogEntryGQL
148
+ }
149
+
150
+ export interface ReportSubmissionGQL {
151
+ __deleted?: boolean;
152
+
153
+ id: string;
154
+ reportId: string;
155
+ organizationId: string;
156
+ sectionKey: string;
157
+ documentName: string;
158
+ sectionName: string;
159
+ title: string;
160
+ period: string; // YYYY-MM-DD
161
+ activityAt: string | null; // ISO date string
162
+ rows: ReportRowGQL[];
163
+ evidences: string[];
164
+ requireFileUploads: boolean;
165
+ }
166
+
167
+ export interface ReportLogRelData {
168
+ __table: 'report_log_rels';
169
+ reportSubmissionId: number | bigint;
170
+ logId: number | bigint;
171
+ sectionKey: string;
172
+ }
173
+
174
+ export interface ReportStorageRelData {
175
+ __table: 'report_storage_rels';
176
+ reportSubmissionId: number | bigint;
177
+ storageId: number | bigint;
178
+ sectionKey: string;
179
+ order: number;
180
+ file: StorageData;
181
+ }
182
+
183
+ export interface ReportSubmissionData {
184
+ __table: 'report_submissions';
185
+ id: number;
186
+ organizationId: number;
187
+ reportId: number;
188
+ period: Date; // YYYY-MM-DD in database, Date object in server via ORM
189
+ answers: Record<string, any>; // key-value pairs of answers
190
+ logRels?: ReportLogRelData[];
191
+ storageRels?: ReportStorageRelData[];
192
+ activityAt: Date;
193
+ }
194
+
195
+ /**
196
+ * Available reports
197
+ */
198
+
199
+ export interface ReportAvailabilityGQL {
200
+ id: string;
201
+ type: ReportTypeEnum;
202
+ periods: string[]; // YYYY-MM-DD
203
+ }