cyc-type-def 1.0.0 → 1.0.1

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