@breedware/exampaqs-shared 1.0.1 → 1.1.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.
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/sms/index.d.ts +39 -0
- package/dist/sms/index.d.ts.map +1 -0
- package/dist/sms/index.js +46 -0
- package/dist/sms/index.js.map +1 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC"}
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export declare const SMSTemplates: {
|
|
2
|
+
arrival: ({ studentName, status, time, guardian, schoolName }: {
|
|
3
|
+
studentName: string;
|
|
4
|
+
status: "early" | "late" | "on-time";
|
|
5
|
+
time: string;
|
|
6
|
+
guardian?: string;
|
|
7
|
+
schoolName: string;
|
|
8
|
+
}) => string;
|
|
9
|
+
departure: ({ studentName, time, guardian, schoolName }: {
|
|
10
|
+
studentName: string;
|
|
11
|
+
time: string;
|
|
12
|
+
guardian?: string;
|
|
13
|
+
schoolName: string;
|
|
14
|
+
}) => string;
|
|
15
|
+
excused: ({ studentName, date, parentName, schoolName }: {
|
|
16
|
+
studentName: string;
|
|
17
|
+
date: string;
|
|
18
|
+
parentName: string;
|
|
19
|
+
schoolName: string;
|
|
20
|
+
}) => string;
|
|
21
|
+
absent: ({ studentName, date, schoolName }: {
|
|
22
|
+
studentName: string;
|
|
23
|
+
date: string;
|
|
24
|
+
schoolName: string;
|
|
25
|
+
}) => string;
|
|
26
|
+
otp: ({ otpCode, purpose, schoolName }: {
|
|
27
|
+
otpCode: string;
|
|
28
|
+
purpose: string;
|
|
29
|
+
schoolName: string;
|
|
30
|
+
}) => string;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Computes the number of SMS segments (pages) for a given string.
|
|
34
|
+
* This assumes standard GSM-7 encoding.
|
|
35
|
+
* * Note: If using non-GSM characters (like emojis or special symbols),
|
|
36
|
+
* the limits drop to 70 chars (single) and 67 chars (multi-part).
|
|
37
|
+
*/
|
|
38
|
+
export declare const smsPagesComputer: (content: string) => number;
|
|
39
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/sms/index.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY;mEAEwC;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE;6DAKxH;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE;6DAK5E;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE;gDAK1F;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE;4CAK7D;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE;CAGjG,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,GAAI,SAAS,MAAM,KAAG,MAkBlD,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export const SMSTemplates = {
|
|
2
|
+
// 1. Student Arrival
|
|
3
|
+
arrival: ({ studentName, status, time, guardian, schoolName }) => {
|
|
4
|
+
return `Attendance Alert: ${studentName} arrived ${status} at ${time}. Dropped off by: ${guardian || 'Self'}. - ${schoolName}`;
|
|
5
|
+
},
|
|
6
|
+
// 2. Student Departure
|
|
7
|
+
departure: ({ studentName, time, guardian, schoolName }) => {
|
|
8
|
+
return `Departure Alert: ${studentName} left school at ${time}. Picked up by: ${guardian || 'Self'}. - ${schoolName}`;
|
|
9
|
+
},
|
|
10
|
+
// 3. Excused Absence
|
|
11
|
+
excused: ({ studentName, date, parentName, schoolName }) => {
|
|
12
|
+
return `Excuse Confirmed: ${studentName} is marked Excused for ${date}, per request by ${parentName}. - ${schoolName}`;
|
|
13
|
+
},
|
|
14
|
+
// 4. Unexcused Absence
|
|
15
|
+
absent: ({ studentName, date, schoolName }) => {
|
|
16
|
+
return `Urgent: ${studentName} is marked ABSENT today, ${date}. Please contact the office to verify. - ${schoolName}`;
|
|
17
|
+
},
|
|
18
|
+
// 5. Transaction OTP
|
|
19
|
+
otp: ({ otpCode, purpose, schoolName }) => {
|
|
20
|
+
return `Your OTP for ${purpose} is ${otpCode}. Valid for 5 mins. Do not share. - ${schoolName}`;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Computes the number of SMS segments (pages) for a given string.
|
|
25
|
+
* This assumes standard GSM-7 encoding.
|
|
26
|
+
* * Note: If using non-GSM characters (like emojis or special symbols),
|
|
27
|
+
* the limits drop to 70 chars (single) and 67 chars (multi-part).
|
|
28
|
+
*/
|
|
29
|
+
export const smsPagesComputer = (content) => {
|
|
30
|
+
const charCount = content.length;
|
|
31
|
+
// If the message is empty, it technically consumes 0 pages (or 1 depending on carrier billing)
|
|
32
|
+
if (charCount === 0)
|
|
33
|
+
return 0;
|
|
34
|
+
// Standard GSM-7 limit for a single message
|
|
35
|
+
const SINGLE_PAGE_LIMIT = 160;
|
|
36
|
+
// Limit for multi-part messages (7 characters reserved for UDH)
|
|
37
|
+
const MULTI_PAGE_LIMIT = 152;
|
|
38
|
+
if (charCount <= SINGLE_PAGE_LIMIT) {
|
|
39
|
+
return 1;
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
// Math.ceil ensures that even 1 extra character triggers a new page
|
|
43
|
+
return Math.ceil(charCount / MULTI_PAGE_LIMIT);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/sms/index.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,qBAAqB;IACrB,OAAO,EAAE,CAAC,EAAE,WAAW,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAsH,EAAE,EAAE;QACnL,OAAO,qBAAqB,WAAW,YAAY,MAAM,OAAO,IAAI,qBAAqB,QAAQ,IAAI,MAAM,OAAO,UAAU,EAAE,CAAC;IACjI,CAAC;IAED,uBAAuB;IACvB,SAAS,EAAE,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAgF,EAAE,EAAE;QACvI,OAAO,oBAAoB,WAAW,mBAAmB,IAAI,mB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