@jsb188/mday 1.1.5 → 1.1.6

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,177 @@
1
+ import { REPORT_SORT_OPTS, REPORT_TYPES, REPORT_ROW_PRESETS } from '../constants/report';
2
+
3
+ /**
4
+ * Enums
5
+ */
6
+
7
+ type ReportTypeEnum = typeof REPORT_TYPES[number];
8
+ type ReportRowPresetEnum = typeof REPORT_ROW_PRESETS[number];
9
+ type ReportsSortEnum = typeof REPORT_SORT_OPTS[number];
10
+
11
+ /**
12
+ * Filters
13
+ */
14
+
15
+ export interface ReportsFilterArgs {
16
+ preset?: '?' | null;
17
+ reportType: ReportTypeEnum;
18
+ period: string; // YYYY-MM-DD
19
+ query?: string | null;
20
+ }
21
+
22
+ /**
23
+ * Report; fields
24
+ */
25
+
26
+ interface ReportFieldsObj {
27
+ __allowMultiples?: boolean; // Allow multiple copies of the same report (from 1 report template)
28
+ __notAutomated?: boolean; // If true, report is not skipped during automation
29
+ __prompt: string; // Server-only, this prompt used on the entire report as a whole (ie. OSP generation)
30
+ gridLayoutStyle?: string;
31
+ sections?: ReportFieldsSection[];
32
+ rows?: ReportFieldsRow[];
33
+ metadata?: ReportFieldsRow[];
34
+ variables: {
35
+ month?: number; // Used for MONTH presets (required for all preset="MONTH" rows)
36
+ [key: string]: any;
37
+ };
38
+ }
39
+
40
+ interface ReportFieldsSection {
41
+ id?: string; // GraphQL Cursor, client-side only, but if present in Server, it will be an Array
42
+ key: string; // Every section must have a unique string UID
43
+ isGroupTitle?: boolean;
44
+ sectionKey: string;
45
+ sectionName: string;
46
+ title: string;
47
+ description: string;
48
+ rows?: ReportFieldsRow[];
49
+
50
+ __prompt_section?: string; // Server-only; full prompt for this section - this is the only prompt that allows {{variable}} regex
51
+ __prompt_examples?: string; // Server-only; for examples of what the output should be
52
+ __prompt_topics?: string; // Server-only; for topics this section should cover
53
+ }
54
+
55
+ interface ReportFieldsRow {
56
+ id?: string; // GraphQL Cursor, client-side only, but if present in Server, it will be an Array
57
+ key: string; // Key is used to map row/columns to answers
58
+ preset?: ReportRowPresetEnum;
59
+ className?: string;
60
+ isHeader?: boolean;
61
+ columns: Partial<ReportFieldsColumn>[];
62
+ }
63
+
64
+ type ReportRowGQL = Omit<ReportFieldsRow, 'key'> & {
65
+ id: string; // GraphQL Cursor, client-side only, but if present in Server, it will be an Array
66
+ };
67
+
68
+ interface ReportFieldsColumn {
69
+ id: string; // GraphQL Cursor, client-side only, but if present in Server, it will be an Array
70
+ key: string; // Key is used to map column to answers
71
+ className?: string;
72
+ labelClassName?: string;
73
+ label: string;
74
+ text: string;
75
+ placeholder: string | null;
76
+ value: string | null; // Available only in server; this value has the indexes to map answers to directly without keys
77
+ checked: boolean | null;
78
+ }
79
+
80
+ /**
81
+ * Report data
82
+ */
83
+
84
+ export interface ReportData {
85
+ __table: 'reports';
86
+
87
+ id: number;
88
+ type: ReportTypeEnum;
89
+ documentName: string;
90
+ title: string;
91
+ description: string;
92
+ order: number;
93
+
94
+ fields: ReportFieldsObj;
95
+ submission?: ReportSubmissionData | null;
96
+
97
+ template?: {
98
+ __table: 'report_templates';
99
+ id: number;
100
+ fields: ReportFieldsObj;
101
+ description: string | null;
102
+ };
103
+ }
104
+
105
+ export interface ReportGQL {
106
+ __deleted?: boolean;
107
+
108
+ id: string;
109
+ organizationId: string;
110
+ documentName: string;
111
+ title: string;
112
+ description: string;
113
+ type: ReportTypeEnum;
114
+ period: string; // YYYY-MM-DD
115
+ evidencesCount: number;
116
+ activityAt: string | null; // ISO date string
117
+
118
+ sections?: ReportFieldsSection[];
119
+ rows?: ReportRowGQL[];
120
+ }
121
+
122
+ /**
123
+ * Report submission data
124
+ */
125
+
126
+ export interface ReportEvidenceGQL {
127
+ __deleted?: boolean;
128
+
129
+ id: string; // GraphQL Cursor
130
+ reportSubmissionId: string;
131
+ sectionKey: string;
132
+ log: any; // LogEntryGQL
133
+ }
134
+
135
+ export interface ReportSubmissionGQL {
136
+ __deleted?: boolean;
137
+
138
+ id: string;
139
+ reportId: string;
140
+ organizationId: string;
141
+ sectionKey: string;
142
+ documentName: string;
143
+ sectionName: string;
144
+ title: string;
145
+ period: string; // YYYY-MM-DD
146
+ activityAt: string | null; // ISO date string
147
+ rows: ReportRowGQL[];
148
+ evidences: string[];
149
+ }
150
+
151
+ export interface ReportLogRelData {
152
+ __table: 'report_log_rels';
153
+ reportSubmissionId: number | bigint;
154
+ logId: number | bigint;
155
+ sectionKey: string;
156
+ }
157
+
158
+ export interface ReportSubmissionData {
159
+ __table: 'report_submissions';
160
+ id: number;
161
+ organizationId: number;
162
+ reportId: number;
163
+ period: Date; // YYYY-MM-DD in database, Date object in server via ORM
164
+ answers: Record<string, any>; // key-value pairs of answers
165
+ logRels?: ReportLogRelData[];
166
+ activityAt: Date;
167
+ }
168
+
169
+ /**
170
+ * Available reports
171
+ */
172
+
173
+ export interface ReportAvailabilityGQL {
174
+ id: string;
175
+ type: ReportTypeEnum;
176
+ periods: string[]; // YYYY-MM-DD
177
+ }