cyc-type-def 1.0.0 → 1.0.2

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/dist/index.js CHANGED
@@ -20,20 +20,605 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/index.ts
21
21
  var index_exports = {};
22
22
  __export(index_exports, {
23
- greet: () => greet,
24
- sum: () => sum
23
+ AppUser: () => AppUser,
24
+ AttSheep: () => AttSheep,
25
+ Attendance: () => Attendance,
26
+ BackupAttendance: () => BackupAttendance,
27
+ CG: () => CG,
28
+ Click: () => Click,
29
+ ClickAction: () => ClickAction,
30
+ Cluster: () => Cluster,
31
+ Column: () => Column,
32
+ DisplayAttendance: () => DisplayAttendance,
33
+ FollowUpStatus: () => FollowUpStatus,
34
+ LIST_STATUS: () => LIST_STATUS,
35
+ METHOD: () => METHOD,
36
+ PERMISSION: () => PERMISSION,
37
+ PERMISSION_TYPE: () => PERMISSION_TYPE,
38
+ ReportSheep: () => ReportSheep,
39
+ Session: () => Session,
40
+ SessionAttendance: () => SessionAttendance,
41
+ Sheep: () => Sheep,
42
+ SmallTeam: () => SmallTeam,
43
+ Title: () => Title,
44
+ TitleAttendance: () => TitleAttendance
25
45
  });
26
46
  module.exports = __toCommonJS(index_exports);
27
47
 
28
- // src/utils.ts
29
- function greet(name) {
30
- return `Hello, ${name}!`;
31
- }
32
- function sum(a, b) {
33
- return a + b;
34
- }
48
+ // src/constants/method.constant.ts
49
+ var METHOD = {
50
+ SKY: "S",
51
+ GROUND: "G",
52
+ TOTAL: "T"
53
+ };
54
+
55
+ // src/constants/status.constant.ts
56
+ var LIST_STATUS = ["OM", "NB", "AC", "NF", "RNF"];
57
+
58
+ // src/classes/attendance/SessionAttendance.ts
59
+ var SessionAttendance = class {
60
+ constructor(session) {
61
+ this.arrSheep = [];
62
+ if (session) {
63
+ this.code = session.code;
64
+ this.type = session.type;
65
+ this.desc = session.desc;
66
+ this.seq = session.seq;
67
+ this.needAbsReason = session.needAbsReason;
68
+ }
69
+ }
70
+ sortedArrAttSheep() {
71
+ let arrStatusCopy = LIST_STATUS;
72
+ return this.arrSheep.sort((a, b) => {
73
+ if (a.attended && b.attended || !a.attended && !b.attended) {
74
+ let indexA = arrStatusCopy.indexOf(a.status);
75
+ let indexB = arrStatusCopy.indexOf(b.status);
76
+ if (indexA < 0) {
77
+ return 1;
78
+ } else if (indexB < 0) {
79
+ return -1;
80
+ } else {
81
+ if (indexA < indexB) {
82
+ return -1;
83
+ } else if (indexA > indexB) {
84
+ return 1;
85
+ } else {
86
+ return a.name.localeCompare(b.name);
87
+ }
88
+ }
89
+ } else if (a.attended) {
90
+ return -1;
91
+ } else if (b.attended) {
92
+ return 1;
93
+ } else {
94
+ return -1;
95
+ }
96
+ });
97
+ }
98
+ get arrFilteredSheep() {
99
+ return this.input ? this.arrSheep.filter(
100
+ (sheep) => sheep.name.toLowerCase().includes(this.input.toLowerCase())
101
+ ) : this.arrSheep.slice();
102
+ }
103
+ getCnt(status, attType) {
104
+ if (!this.arrSheep) return 0;
105
+ else {
106
+ let cnt = 0;
107
+ for (let s of this.arrSheep) {
108
+ if (attType == METHOD.GROUND || attType == METHOD.SKY) {
109
+ if (attType == s.method && s.status == status && s.attended) cnt++;
110
+ } else if (attType == METHOD.TOTAL) {
111
+ if (s.status == status && s.attended) cnt++;
112
+ }
113
+ }
114
+ return cnt;
115
+ }
116
+ }
117
+ getAbsCnt() {
118
+ if (!this.arrSheep) return 0;
119
+ else {
120
+ let cnt = 0;
121
+ for (let s of this.arrSheep) {
122
+ if (s.status == "OM" && !s.attended) cnt++;
123
+ }
124
+ return cnt;
125
+ }
126
+ }
127
+ getDesc(status, attType) {
128
+ if (!this.arrSheep) return "";
129
+ else {
130
+ let desc = "";
131
+ for (let s of this.arrSheep) {
132
+ if (attType == METHOD.GROUND || attType == METHOD.SKY) {
133
+ if (attType == s.method && s.status == status && s.attended)
134
+ desc += s.name + ", ";
135
+ } else if (attType == METHOD.TOTAL) {
136
+ if (s.status == status && s.attended) desc += s.name + ", ";
137
+ }
138
+ }
139
+ desc = desc.slice(0, desc.length - 2);
140
+ return desc;
141
+ }
142
+ }
143
+ getAbsDesc() {
144
+ if (!this.arrSheep) return "";
145
+ else {
146
+ let desc = "";
147
+ for (let s of this.arrSheep) {
148
+ if (s.status == "OM" && !s.attended)
149
+ desc += s.name + " - " + s.absReason + ", ";
150
+ }
151
+ desc = desc.slice(0, desc.length - 2);
152
+ return desc;
153
+ }
154
+ }
155
+ calc() {
156
+ this.ground = new DisplayAttendance();
157
+ this.sky = new DisplayAttendance();
158
+ this.total = new DisplayAttendance();
159
+ this.calcFigure();
160
+ this.calcDesc();
161
+ }
162
+ /** generate count of OM, NB, AC, NF, RNF */
163
+ calcFigure() {
164
+ for (let status of LIST_STATUS) {
165
+ this.ground["cnt" + status] = this.getCnt(status, METHOD.GROUND);
166
+ this.ground.calcTotal();
167
+ }
168
+ for (let status of LIST_STATUS) {
169
+ this.sky["cnt" + status] = this.getCnt(status, METHOD.SKY);
170
+ this.sky.calcTotal();
171
+ }
172
+ for (let status of LIST_STATUS) {
173
+ this.total["cnt" + status] = this.getCnt(status, METHOD.TOTAL);
174
+ this.total.calcTotal();
175
+ }
176
+ this.cntAbs = this.getAbsCnt();
177
+ }
178
+ /** generate description of OM, NB, AC, NF, RNF */
179
+ calcDesc() {
180
+ for (let status of LIST_STATUS) {
181
+ this.ground["des" + status] = this.getDesc(status, METHOD.GROUND);
182
+ }
183
+ for (let status of LIST_STATUS) {
184
+ this.sky["des" + status] = this.getDesc(status, METHOD.SKY);
185
+ }
186
+ for (let status of LIST_STATUS) {
187
+ this.total["des" + status] = this.getDesc(status, METHOD.TOTAL);
188
+ }
189
+ this.desAbs = this.getAbsDesc();
190
+ }
191
+ /**
192
+ * reset all display attendance figure to zero
193
+ */
194
+ resetDisplayAttendance() {
195
+ this.ground = new DisplayAttendance();
196
+ this.sky = new DisplayAttendance();
197
+ this.total = new DisplayAttendance();
198
+ for (let status of LIST_STATUS) {
199
+ this.ground["cnt" + status] = 0;
200
+ this.sky["cnt" + status] = 0;
201
+ this.total["cnt" + status] = 0;
202
+ }
203
+ this.ground.total = 0;
204
+ this.sky.total = 0;
205
+ this.total.total = 0;
206
+ this.cntAbs = 0;
207
+ }
208
+ /**
209
+ * Sums CG's sessionAttendance into total sessionAttendance.
210
+ * @param sessionAttendance
211
+ */
212
+ sum(sessionAttendance) {
213
+ for (let status of LIST_STATUS) {
214
+ this.ground["cnt" + status] += sessionAttendance.ground["cnt" + status];
215
+ this.sky["cnt" + status] += sessionAttendance.sky["cnt" + status];
216
+ this.total["cnt" + status] += sessionAttendance.total["cnt" + status];
217
+ }
218
+ this.ground.total += sessionAttendance.ground.total;
219
+ this.sky.total += sessionAttendance.sky.total;
220
+ this.total.total += sessionAttendance.total.total;
221
+ this.cntAbs += sessionAttendance.cntAbs;
222
+ }
223
+ };
224
+ var AttSheep = class {
225
+ /**
226
+ * initialize AttSheep object from Sheep object
227
+ * @param sheep
228
+ */
229
+ constructor(sheep) {
230
+ this.idSheep = sheep.id;
231
+ this.name = sheep.name;
232
+ this.status = sheep.status;
233
+ this.attended = false;
234
+ this.absReason = "";
235
+ this.method = METHOD.GROUND;
236
+ }
237
+ copyAtt(attSheep) {
238
+ this.attended = attSheep.attended;
239
+ this.absReason = attSheep.absReason;
240
+ this.method = attSheep.method;
241
+ }
242
+ };
243
+ var DisplayAttendance = class {
244
+ calcTotal() {
245
+ this.total = this.cntOM + this.cntNB + this.cntAC + this.cntNF + this.cntRNF;
246
+ }
247
+ };
248
+
249
+ // src/classes/attendance/Attendance.ts
250
+ var Attendance = class {
251
+ constructor(attendance) {
252
+ if (attendance) {
253
+ Object.assign(this, attendance);
254
+ }
255
+ }
256
+ getSessionAttendance(session) {
257
+ }
258
+ setSessionAttendance(arrSession) {
259
+ if (this.arrSessionAttendance) {
260
+ let oriArr = this.deepCopySessionAttendance(this.arrSessionAttendance);
261
+ this.arrSessionAttendance = [];
262
+ for (let s of arrSession) {
263
+ this.arrSessionAttendance.push(new SessionAttendance(s));
264
+ }
265
+ for (let oriSession of oriArr) {
266
+ for (let newSession of this.arrSessionAttendance) {
267
+ if (oriSession.code == newSession.code) {
268
+ if (oriSession.arrSheep) {
269
+ newSession.arrSheep = [...oriSession.arrSheep];
270
+ }
271
+ }
272
+ }
273
+ }
274
+ } else {
275
+ this.arrSessionAttendance = [];
276
+ for (let s of arrSession) {
277
+ this.arrSessionAttendance.push(new SessionAttendance(s));
278
+ }
279
+ }
280
+ }
281
+ deepCopySessionAttendance(arrSessionAttendance) {
282
+ let arrRtn = [];
283
+ for (let s of arrSessionAttendance) {
284
+ let sessionAtt = new SessionAttendance();
285
+ sessionAtt.code = s.code;
286
+ sessionAtt.desc = s.desc;
287
+ sessionAtt.type = s.type;
288
+ sessionAtt.seq = s.seq;
289
+ sessionAtt.needAbsReason = s.needAbsReason;
290
+ sessionAtt.arrSheep = [];
291
+ for (let sheep of s.arrSheep) {
292
+ sessionAtt.arrSheep.push(sheep);
293
+ }
294
+ arrRtn.push(sessionAtt);
295
+ }
296
+ return arrRtn;
297
+ }
298
+ clearArrAttSheep(idCG, arrSheepForRef) {
299
+ if (this.arrSessionAttendance) {
300
+ for (let sessionAtt of this.arrSessionAttendance) {
301
+ sessionAtt.arrSheep = sessionAtt.arrSheep.filter((s) => {
302
+ return arrSheepForRef[s.idSheep] ? arrSheepForRef[s.idSheep].cg == idCG : false;
303
+ });
304
+ }
305
+ }
306
+ }
307
+ setArrAttSheep(arrSheep) {
308
+ for (let sessionAtt of this.arrSessionAttendance) {
309
+ for (let sheep of arrSheep) {
310
+ let found = false;
311
+ for (let attSheep of sessionAtt.arrSheep) {
312
+ if (attSheep.idSheep == sheep.id) {
313
+ found = true;
314
+ }
315
+ }
316
+ if (!found) sessionAtt.arrSheep.push(new AttSheep(sheep));
317
+ }
318
+ sessionAtt.arrSheep = sessionAtt.sortedArrAttSheep();
319
+ }
320
+ }
321
+ addSheep(sheep) {
322
+ for (let sessionAtt of this.arrSessionAttendance) {
323
+ sessionAtt.arrSheep.push(new AttSheep(sheep));
324
+ sessionAtt.arrSheep = sessionAtt.sortedArrAttSheep();
325
+ }
326
+ }
327
+ setCG(cg) {
328
+ this.idCg = cg.id;
329
+ this.idSt = cg.st;
330
+ this.idCluster = cg.cluster;
331
+ }
332
+ /**
333
+ * remove sheep where attended=false from arrSheep to submit attendance,
334
+ * won't remove OM
335
+ */
336
+ removeNotAttendForSubmission() {
337
+ for (let sessionAtt of this.arrSessionAttendance) {
338
+ sessionAtt.arrSheep = sessionAtt.arrSheep.filter(
339
+ (sheep) => sheep.attended || sheep.status == "OM"
340
+ );
341
+ }
342
+ }
343
+ /** calculate session attendance's figure & description */
344
+ calc() {
345
+ for (let sessionAtt of this.arrSessionAttendance) {
346
+ sessionAtt.calc();
347
+ }
348
+ }
349
+ /** Reset all display attendance figure to zero. */
350
+ resetDisplayAttendance() {
351
+ for (let session of this.arrSessionAttendance) {
352
+ session.resetDisplayAttendance();
353
+ }
354
+ }
355
+ getSessionAttendanceByCode(code) {
356
+ for (let session of this.arrSessionAttendance) {
357
+ if (session.code == code) {
358
+ return session;
359
+ }
360
+ }
361
+ return new SessionAttendance();
362
+ }
363
+ /**
364
+ * copy attendance to the writing panel
365
+ * @param attendance
366
+ */
367
+ copy(attendance) {
368
+ for (let sessionAtt of this.arrSessionAttendance) {
369
+ for (let prevSessionAtt of attendance.arrSessionAttendance) {
370
+ if (sessionAtt.code == prevSessionAtt.code) {
371
+ for (let attSheep of sessionAtt.arrSheep) {
372
+ let found = false;
373
+ for (let prevAttSheep of prevSessionAtt.arrSheep) {
374
+ if (attSheep.idSheep == prevAttSheep.idSheep) {
375
+ attSheep.copyAtt(prevAttSheep);
376
+ found = true;
377
+ }
378
+ }
379
+ if (!found) attSheep.attended = false;
380
+ }
381
+ }
382
+ }
383
+ }
384
+ }
385
+ };
386
+
387
+ // src/classes/attendance/BackupAttendance.ts
388
+ var BackupAttendance = class {
389
+ };
390
+
391
+ // src/classes/attendance/Session.ts
392
+ var Session = class {
393
+ constructor() {
394
+ }
395
+ };
396
+
397
+ // src/classes/attendance/Title.ts
398
+ var Title = class {
399
+ getKey() {
400
+ return "dddd";
401
+ }
402
+ };
403
+
404
+ // src/classes/pastoral-team/Sheep.ts
405
+ var Sheep = class {
406
+ constructor(id, name, status, cg, st, cluster, deleted, show, attCnt) {
407
+ this.id = id;
408
+ this.name = name;
409
+ this.status = status;
410
+ this.cg = cg;
411
+ this.st = st;
412
+ this.cluster = cluster;
413
+ this.deleted = deleted;
414
+ this.show = show;
415
+ this.attCnt = attCnt;
416
+ }
417
+ };
418
+
419
+ // src/classes/attendance-report/ReportSheep.ts
420
+ var ReportSheep = class extends Sheep {
421
+ constructor(sheep) {
422
+ super(
423
+ sheep.id,
424
+ sheep.name,
425
+ sheep.status,
426
+ sheep.cg,
427
+ sheep.st,
428
+ sheep.cluster,
429
+ sheep.deleted,
430
+ sheep.show,
431
+ sheep.attCnt
432
+ );
433
+ this.attMap = {};
434
+ }
435
+ };
436
+
437
+ // src/classes/attendance-report/TitleAttendance.ts
438
+ var TitleAttendance = class {
439
+ constructor(cgAtt, serviceAtt, title) {
440
+ this.cgAtt = cgAtt;
441
+ this.serviceAtt = serviceAtt;
442
+ this.title = title;
443
+ }
444
+ };
445
+
446
+ // src/classes/flw-up/FollowUpStatus.ts
447
+ var FollowUpStatus = class {
448
+ constructor() {
449
+ this.id = "";
450
+ this.method = "";
451
+ this.cluster = "";
452
+ this.st = "";
453
+ this.cg = "";
454
+ this.sheep = "";
455
+ this.in_list = true;
456
+ this.status = "";
457
+ this.timeStamp = "";
458
+ this.date = "";
459
+ this.discipler = "";
460
+ }
461
+ };
462
+
463
+ // src/classes/pastoral-team/CG.ts
464
+ var CG = class {
465
+ constructor(id, name, st, cluster, deleted) {
466
+ this.id = id;
467
+ this.name = name;
468
+ this.st = st;
469
+ this.cluster = cluster;
470
+ this.deleted = deleted;
471
+ }
472
+ };
473
+
474
+ // src/classes/pastoral-team/Cluster.ts
475
+ var Cluster = class {
476
+ constructor(id, name, deleted) {
477
+ this.id = id;
478
+ this.name = name;
479
+ this.deleted = deleted;
480
+ }
481
+ };
482
+
483
+ // src/classes/pastoral-team/SmallTeam.ts
484
+ var SmallTeam = class {
485
+ constructor(id, name, cluster, deleted) {
486
+ this.id = id;
487
+ this.name = name;
488
+ this.cluster = cluster;
489
+ this.deleted = deleted;
490
+ }
491
+ };
492
+
493
+ // src/classes/AppUser.ts
494
+ var AppUser = class {
495
+ constructor(id, name, phoneNum, permission) {
496
+ this.id = id;
497
+ this.name = name;
498
+ this.phoneNum = phoneNum;
499
+ this.permission = permission;
500
+ }
501
+ };
502
+
503
+ // src/classes/Click.ts
504
+ var Click = class {
505
+ };
506
+
507
+ // src/classes/Column.ts
508
+ var Column = class {
509
+ constructor(name) {
510
+ this.visible = false;
511
+ this.name = name;
512
+ }
513
+ };
514
+
515
+ // src/constants/click.constant.ts
516
+ var ClickAction = /* @__PURE__ */ ((ClickAction2) => {
517
+ ClickAction2[ClickAction2["P_WeeklyAttendance"] = 0] = "P_WeeklyAttendance";
518
+ ClickAction2[ClickAction2["P_AttendanceReport"] = 1] = "P_AttendanceReport";
519
+ ClickAction2[ClickAction2["P_CGNameList"] = 2] = "P_CGNameList";
520
+ ClickAction2[ClickAction2["F_CopyAttendance"] = 3] = "F_CopyAttendance";
521
+ ClickAction2[ClickAction2["F_CheckAttendanceHistory"] = 4] = "F_CheckAttendanceHistory";
522
+ ClickAction2[ClickAction2["F_AttendanceReminder"] = 5] = "F_AttendanceReminder";
523
+ ClickAction2[ClickAction2["F_ExportWeekAttendance"] = 6] = "F_ExportWeekAttendance";
524
+ ClickAction2[ClickAction2["F_ClickEditSheep"] = 7] = "F_ClickEditSheep";
525
+ ClickAction2[ClickAction2["F_EditSheep"] = 8] = "F_EditSheep";
526
+ ClickAction2[ClickAction2["F_VerticalViewAttendance"] = 9] = "F_VerticalViewAttendance";
527
+ return ClickAction2;
528
+ })(ClickAction || {});
529
+
530
+ // src/constants/permission.constant.ts
531
+ var PERMISSION = {
532
+ SUPER_USER: "Super user",
533
+ TL: "TL",
534
+ SCGL: "SCGL",
535
+ CGL: "CGL",
536
+ FL: "FL",
537
+ WM: "WM",
538
+ NOT_VERIFIED: "Not verified",
539
+ PASTORAL_ADMIN: "Pastoral Admin",
540
+ ST_ADMIN: "Small Team Admin"
541
+ };
542
+ var PERMISSION_TYPE = {
543
+ USER_MANAGEMENT: [PERMISSION.SUPER_USER],
544
+ WEEKLY_ATT: [
545
+ PERMISSION.SUPER_USER,
546
+ PERMISSION.TL,
547
+ PERMISSION.SCGL,
548
+ PERMISSION.PASTORAL_ADMIN
549
+ ],
550
+ ATT_RPT: [
551
+ PERMISSION.SUPER_USER,
552
+ PERMISSION.TL,
553
+ PERMISSION.SCGL,
554
+ PERMISSION.CGL,
555
+ PERMISSION.PASTORAL_ADMIN
556
+ ],
557
+ TITLE: [PERMISSION.SUPER_USER],
558
+ CLICKS: [PERMISSION.SUPER_USER],
559
+ // SHEEP_LIST: [PERMISSION.TL],
560
+ // view specific permissions
561
+ monthlyReport: [
562
+ PERMISSION.SUPER_USER,
563
+ PERMISSION.PASTORAL_ADMIN,
564
+ PERMISSION.TL
565
+ ],
566
+ read: [
567
+ PERMISSION.SUPER_USER,
568
+ PERMISSION.PASTORAL_ADMIN,
569
+ PERMISSION.TL,
570
+ PERMISSION.SCGL,
571
+ PERMISSION.CGL
572
+ ],
573
+ msjStudentRecord: [PERMISSION.SUPER_USER, PERMISSION.PASTORAL_ADMIN],
574
+ msjProgress: [
575
+ PERMISSION.SUPER_USER,
576
+ PERMISSION.TL,
577
+ PERMISSION.SCGL,
578
+ PERMISSION.CGL,
579
+ PERMISSION.PASTORAL_ADMIN
580
+ ],
581
+ msjToAttend: [
582
+ PERMISSION.SUPER_USER,
583
+ PERMISSION.TL,
584
+ PERMISSION.SCGL,
585
+ PERMISSION.CGL,
586
+ PERMISSION.PASTORAL_ADMIN
587
+ ],
588
+ addSheep: [
589
+ PERMISSION.SUPER_USER,
590
+ PERMISSION.PASTORAL_ADMIN,
591
+ PERMISSION.ST_ADMIN,
592
+ PERMISSION.TL,
593
+ PERMISSION.SCGL,
594
+ PERMISSION.CGL
595
+ ],
596
+ addCG: [PERMISSION.SUPER_USER, PERMISSION.PASTORAL_ADMIN],
597
+ // action specific permission
598
+ oprAddSheep: [PERMISSION.SUPER_USER, PERMISSION.PASTORAL_ADMIN]
599
+ };
35
600
  // Annotate the CommonJS export names for ESM import in node:
36
601
  0 && (module.exports = {
37
- greet,
38
- sum
602
+ AppUser,
603
+ AttSheep,
604
+ Attendance,
605
+ BackupAttendance,
606
+ CG,
607
+ Click,
608
+ ClickAction,
609
+ Cluster,
610
+ Column,
611
+ DisplayAttendance,
612
+ FollowUpStatus,
613
+ LIST_STATUS,
614
+ METHOD,
615
+ PERMISSION,
616
+ PERMISSION_TYPE,
617
+ ReportSheep,
618
+ Session,
619
+ SessionAttendance,
620
+ Sheep,
621
+ SmallTeam,
622
+ Title,
623
+ TitleAttendance
39
624
  });