@salespark/toolkit 2.1.20 → 2.1.21

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.cts CHANGED
@@ -1063,8 +1063,47 @@ declare function generatePassword(options?: GenerateOptions): string | Promise<s
1063
1063
  ****************************************************/
1064
1064
  declare const generatePasswordWithOptions: (options?: GenerateOptions) => string | Promise<string>;
1065
1065
 
1066
+ /******************************************************
1067
+ * ##: SMS Length Calculator
1068
+ * Calculates SMS length, segmentation, and encoding based on GSM rules.
1069
+ * Reference: 3GPP TS 23.038 (GSM 03.38)
1070
+ * History:
1071
+ * 14-03-2026: Created
1072
+ ****************************************************/
1073
+ type SmsEncoding = "GSM_7BIT" | "GSM_7BIT_EXT" | "UTF16";
1074
+ declare const GSM_7BIT_REGEXP: RegExp;
1075
+ declare const GSM_7BIT_EXT_REGEXP: RegExp;
1076
+ /******************************************************
1077
+ * Extended GSM characters that consume 2 septets each.
1078
+ * Per 3GPP TS 23.038 Table 3 (Basic Character Set Extension):
1079
+ * ^ { } \ [ ] ~ | €
1080
+ ****************************************************/
1081
+ declare const GSM_7BIT_EXT_CHAR_REGEXP: RegExp;
1082
+ type SmsLengthResult = {
1083
+ encoding: SmsEncoding;
1084
+ length: number;
1085
+ characterPerMessage: number;
1086
+ inCurrentMessage: number;
1087
+ remaining: number;
1088
+ messages: number;
1089
+ };
1090
+ /******************************************************
1091
+ * ##: SMS Length
1092
+ * Calculates encoding, length, and segmentation for an SMS message.
1093
+ * Extended GSM characters (^{}\\[]~|€) each count as 2 septets.
1094
+ * Supports optional per-encoding length overrides for carrier-specific limits.
1095
+ * @param {string} text - SMS message text
1096
+ * @param {Partial<Record<SmsEncoding, number>>} [singleOverrides] - Override
1097
+ * single-segment lengths per encoding
1098
+ * @param {Partial<Record<SmsEncoding, number>>} [multiOverrides] - Override
1099
+ * multi-segment lengths per encoding
1100
+ * History:
1101
+ * 14-03-2026: Created
1102
+ ****************************************************/
1103
+ declare const smsLength: (text: string, singleOverrides?: Partial<Record<SmsEncoding, number>>, multiOverrides?: Partial<Record<SmsEncoding, number>>) => SmsLengthResult;
1104
+
1066
1105
  /** Environment helpers (runtime-agnostic checks) */
1067
1106
  declare const isBrowser: boolean;
1068
1107
  declare const isNode: boolean;
1069
1108
 
1070
- export { type CapitalizeFirstOptions, type CapitalizeWordsOptions, type DeferFn, type EncodeDecodeConfig, type FormatCurrencyProOptions, type GenerateOptions, type HttpResponseLike, type SecurityCheckResult, type SecurityRisk, type SentenceCaseOptions, addSpaceBetweenNumbers, addThousandsSpace, areArraysDeepEqualUnordered, areArraysEqual, assessSecurityRisks, basicSanitize, capitalizeFirst, capitalizeWords, checkMarkdownSecurity, chunk, clamp, cleanObject, compact, currencyToSymbol, debounce, deburr, decodeBase36Code, decodeObject, decodeString, deferAfterResponse, deferAfterResponseNonCritical, deferNonCritical, deferPostReturn, delay, difference, encodeBase36Code, encodeObject, encodeString, fill, flatten, flattenDepth, flattenDepthBase, flattenOnce, formatBytes, formatCurrency, formatCurrencyPro, formatDecimalNumber, generatePassword, generatePasswordWithOptions, getStringSimilarity, groupBy, hasNilOrEmpty, humanFileSize, intersection, isBrowser, isFlattenable, isNil, isNilEmptyOrEmptyObject, isNilEmptyOrZeroLen, isNilEmptyOrZeroLength, isNilOrEmpty, isNilOrNaN, isNilOrZeroLen, isNilOrZeroLength, isNilText, isNilTextOrEmpty, isNode, isNullOrUndefined, isNullOrUndefinedEmptyOrZero, isNullOrUndefinedInArray, isNullOrUndefinedOrNaN, isNullOrUndefinedTextInc, isNullUndefinedOrEmpty, isNullUndefinedOrEmptyEnforced, isNullUndefinedOrZero, isPTTaxId, isValidIBAN, isValidPTTaxId, numbersEqual, objectToString, omit, otp, parseName, parseToBool, parseToNumber, pick, pluck, pushAll, randomDigits, removeDiacritics, round, safeAdd, safeDivide, safeJSONParse, safeMultiply, safeParseFloat, safeParseInt, safeSubtract, sanitize, sanitizeMarkdown, sentenceCase, shuffle, slugify, sortBy, stringSimilarity, symbolToCurrency, throttle, toBool, toInteger, toNumber, uniq, uniqBy };
1109
+ export { type CapitalizeFirstOptions, type CapitalizeWordsOptions, type DeferFn, type EncodeDecodeConfig, type FormatCurrencyProOptions, GSM_7BIT_EXT_CHAR_REGEXP, GSM_7BIT_EXT_REGEXP, GSM_7BIT_REGEXP, type GenerateOptions, type HttpResponseLike, type SecurityCheckResult, type SecurityRisk, type SentenceCaseOptions, type SmsEncoding, type SmsLengthResult, addSpaceBetweenNumbers, addThousandsSpace, areArraysDeepEqualUnordered, areArraysEqual, assessSecurityRisks, basicSanitize, capitalizeFirst, capitalizeWords, checkMarkdownSecurity, chunk, clamp, cleanObject, compact, currencyToSymbol, debounce, deburr, decodeBase36Code, decodeObject, decodeString, deferAfterResponse, deferAfterResponseNonCritical, deferNonCritical, deferPostReturn, delay, difference, encodeBase36Code, encodeObject, encodeString, fill, flatten, flattenDepth, flattenDepthBase, flattenOnce, formatBytes, formatCurrency, formatCurrencyPro, formatDecimalNumber, generatePassword, generatePasswordWithOptions, getStringSimilarity, groupBy, hasNilOrEmpty, humanFileSize, intersection, isBrowser, isFlattenable, isNil, isNilEmptyOrEmptyObject, isNilEmptyOrZeroLen, isNilEmptyOrZeroLength, isNilOrEmpty, isNilOrNaN, isNilOrZeroLen, isNilOrZeroLength, isNilText, isNilTextOrEmpty, isNode, isNullOrUndefined, isNullOrUndefinedEmptyOrZero, isNullOrUndefinedInArray, isNullOrUndefinedOrNaN, isNullOrUndefinedTextInc, isNullUndefinedOrEmpty, isNullUndefinedOrEmptyEnforced, isNullUndefinedOrZero, isPTTaxId, isValidIBAN, isValidPTTaxId, numbersEqual, objectToString, omit, otp, parseName, parseToBool, parseToNumber, pick, pluck, pushAll, randomDigits, removeDiacritics, round, safeAdd, safeDivide, safeJSONParse, safeMultiply, safeParseFloat, safeParseInt, safeSubtract, sanitize, sanitizeMarkdown, sentenceCase, shuffle, slugify, smsLength, sortBy, stringSimilarity, symbolToCurrency, throttle, toBool, toInteger, toNumber, uniq, uniqBy };
package/dist/index.d.ts CHANGED
@@ -1063,8 +1063,47 @@ declare function generatePassword(options?: GenerateOptions): string | Promise<s
1063
1063
  ****************************************************/
1064
1064
  declare const generatePasswordWithOptions: (options?: GenerateOptions) => string | Promise<string>;
1065
1065
 
1066
+ /******************************************************
1067
+ * ##: SMS Length Calculator
1068
+ * Calculates SMS length, segmentation, and encoding based on GSM rules.
1069
+ * Reference: 3GPP TS 23.038 (GSM 03.38)
1070
+ * History:
1071
+ * 14-03-2026: Created
1072
+ ****************************************************/
1073
+ type SmsEncoding = "GSM_7BIT" | "GSM_7BIT_EXT" | "UTF16";
1074
+ declare const GSM_7BIT_REGEXP: RegExp;
1075
+ declare const GSM_7BIT_EXT_REGEXP: RegExp;
1076
+ /******************************************************
1077
+ * Extended GSM characters that consume 2 septets each.
1078
+ * Per 3GPP TS 23.038 Table 3 (Basic Character Set Extension):
1079
+ * ^ { } \ [ ] ~ | €
1080
+ ****************************************************/
1081
+ declare const GSM_7BIT_EXT_CHAR_REGEXP: RegExp;
1082
+ type SmsLengthResult = {
1083
+ encoding: SmsEncoding;
1084
+ length: number;
1085
+ characterPerMessage: number;
1086
+ inCurrentMessage: number;
1087
+ remaining: number;
1088
+ messages: number;
1089
+ };
1090
+ /******************************************************
1091
+ * ##: SMS Length
1092
+ * Calculates encoding, length, and segmentation for an SMS message.
1093
+ * Extended GSM characters (^{}\\[]~|€) each count as 2 septets.
1094
+ * Supports optional per-encoding length overrides for carrier-specific limits.
1095
+ * @param {string} text - SMS message text
1096
+ * @param {Partial<Record<SmsEncoding, number>>} [singleOverrides] - Override
1097
+ * single-segment lengths per encoding
1098
+ * @param {Partial<Record<SmsEncoding, number>>} [multiOverrides] - Override
1099
+ * multi-segment lengths per encoding
1100
+ * History:
1101
+ * 14-03-2026: Created
1102
+ ****************************************************/
1103
+ declare const smsLength: (text: string, singleOverrides?: Partial<Record<SmsEncoding, number>>, multiOverrides?: Partial<Record<SmsEncoding, number>>) => SmsLengthResult;
1104
+
1066
1105
  /** Environment helpers (runtime-agnostic checks) */
1067
1106
  declare const isBrowser: boolean;
1068
1107
  declare const isNode: boolean;
1069
1108
 
1070
- export { type CapitalizeFirstOptions, type CapitalizeWordsOptions, type DeferFn, type EncodeDecodeConfig, type FormatCurrencyProOptions, type GenerateOptions, type HttpResponseLike, type SecurityCheckResult, type SecurityRisk, type SentenceCaseOptions, addSpaceBetweenNumbers, addThousandsSpace, areArraysDeepEqualUnordered, areArraysEqual, assessSecurityRisks, basicSanitize, capitalizeFirst, capitalizeWords, checkMarkdownSecurity, chunk, clamp, cleanObject, compact, currencyToSymbol, debounce, deburr, decodeBase36Code, decodeObject, decodeString, deferAfterResponse, deferAfterResponseNonCritical, deferNonCritical, deferPostReturn, delay, difference, encodeBase36Code, encodeObject, encodeString, fill, flatten, flattenDepth, flattenDepthBase, flattenOnce, formatBytes, formatCurrency, formatCurrencyPro, formatDecimalNumber, generatePassword, generatePasswordWithOptions, getStringSimilarity, groupBy, hasNilOrEmpty, humanFileSize, intersection, isBrowser, isFlattenable, isNil, isNilEmptyOrEmptyObject, isNilEmptyOrZeroLen, isNilEmptyOrZeroLength, isNilOrEmpty, isNilOrNaN, isNilOrZeroLen, isNilOrZeroLength, isNilText, isNilTextOrEmpty, isNode, isNullOrUndefined, isNullOrUndefinedEmptyOrZero, isNullOrUndefinedInArray, isNullOrUndefinedOrNaN, isNullOrUndefinedTextInc, isNullUndefinedOrEmpty, isNullUndefinedOrEmptyEnforced, isNullUndefinedOrZero, isPTTaxId, isValidIBAN, isValidPTTaxId, numbersEqual, objectToString, omit, otp, parseName, parseToBool, parseToNumber, pick, pluck, pushAll, randomDigits, removeDiacritics, round, safeAdd, safeDivide, safeJSONParse, safeMultiply, safeParseFloat, safeParseInt, safeSubtract, sanitize, sanitizeMarkdown, sentenceCase, shuffle, slugify, sortBy, stringSimilarity, symbolToCurrency, throttle, toBool, toInteger, toNumber, uniq, uniqBy };
1109
+ export { type CapitalizeFirstOptions, type CapitalizeWordsOptions, type DeferFn, type EncodeDecodeConfig, type FormatCurrencyProOptions, GSM_7BIT_EXT_CHAR_REGEXP, GSM_7BIT_EXT_REGEXP, GSM_7BIT_REGEXP, type GenerateOptions, type HttpResponseLike, type SecurityCheckResult, type SecurityRisk, type SentenceCaseOptions, type SmsEncoding, type SmsLengthResult, addSpaceBetweenNumbers, addThousandsSpace, areArraysDeepEqualUnordered, areArraysEqual, assessSecurityRisks, basicSanitize, capitalizeFirst, capitalizeWords, checkMarkdownSecurity, chunk, clamp, cleanObject, compact, currencyToSymbol, debounce, deburr, decodeBase36Code, decodeObject, decodeString, deferAfterResponse, deferAfterResponseNonCritical, deferNonCritical, deferPostReturn, delay, difference, encodeBase36Code, encodeObject, encodeString, fill, flatten, flattenDepth, flattenDepthBase, flattenOnce, formatBytes, formatCurrency, formatCurrencyPro, formatDecimalNumber, generatePassword, generatePasswordWithOptions, getStringSimilarity, groupBy, hasNilOrEmpty, humanFileSize, intersection, isBrowser, isFlattenable, isNil, isNilEmptyOrEmptyObject, isNilEmptyOrZeroLen, isNilEmptyOrZeroLength, isNilOrEmpty, isNilOrNaN, isNilOrZeroLen, isNilOrZeroLength, isNilText, isNilTextOrEmpty, isNode, isNullOrUndefined, isNullOrUndefinedEmptyOrZero, isNullOrUndefinedInArray, isNullOrUndefinedOrNaN, isNullOrUndefinedTextInc, isNullUndefinedOrEmpty, isNullUndefinedOrEmptyEnforced, isNullUndefinedOrZero, isPTTaxId, isValidIBAN, isValidPTTaxId, numbersEqual, objectToString, omit, otp, parseName, parseToBool, parseToNumber, pick, pluck, pushAll, randomDigits, removeDiacritics, round, safeAdd, safeDivide, safeJSONParse, safeMultiply, safeParseFloat, safeParseInt, safeSubtract, sanitize, sanitizeMarkdown, sentenceCase, shuffle, slugify, smsLength, sortBy, stringSimilarity, symbolToCurrency, throttle, toBool, toInteger, toNumber, uniq, uniqBy };
package/dist/index.js CHANGED
@@ -2618,10 +2618,66 @@ var generatePasswordWithOptions = (options) => {
2618
2618
  return requiresAsync ? generatePasswordAsync(options) : generatePasswordSync(options);
2619
2619
  };
2620
2620
 
2621
+ // src/utils/sms.ts
2622
+ var GSM_7BIT_REGEXP = /^[@£$¥èéùìòÇ\nØø\rÅåΔ_ΦΓΛΩΠΨΣΘΞÆæßÉ !"#¤%&'()*+,\-./0123456789:;<=>?¡ABCDEFGHIJKLMNOPQRSTUVWXYZÄÖÑܧ¿abcdefghijklmnopqrstuvwxyzäöñüà]*$/;
2623
+ var GSM_7BIT_EXT_REGEXP = /^[@£$¥èéùìòÇ\nØø\rÅåΔ_ΦΓΛΩΠΨΣΘΞÆæßÉ !"#¤%&'()*+,\-./0123456789:;<=>?¡ABCDEFGHIJKLMNOPQRSTUVWXYZÄÖÑܧ¿abcdefghijklmnopqrstuvwxyzäöñüà\^{}\\\[\]~|€]*$/;
2624
+ var GSM_7BIT_EXT_CHAR_REGEXP = /[\^{}\\\[\]~|€]/g;
2625
+ var messageLength = {
2626
+ GSM_7BIT: 160,
2627
+ GSM_7BIT_EXT: 160,
2628
+ UTF16: 70
2629
+ };
2630
+ var multiMessageLength = {
2631
+ GSM_7BIT: 153,
2632
+ GSM_7BIT_EXT: 153,
2633
+ UTF16: 67
2634
+ };
2635
+ var detectEncoding = (text) => {
2636
+ if (GSM_7BIT_REGEXP.test(text)) {
2637
+ return "GSM_7BIT";
2638
+ }
2639
+ if (GSM_7BIT_EXT_REGEXP.test(text)) {
2640
+ return "GSM_7BIT_EXT";
2641
+ }
2642
+ return "UTF16";
2643
+ };
2644
+ var smsLength = (text, singleOverrides, multiOverrides) => {
2645
+ const singleLengths = { ...messageLength, ...singleOverrides };
2646
+ const multiLengths = { ...multiMessageLength, ...multiOverrides };
2647
+ if (text.length === 0) {
2648
+ return {
2649
+ encoding: "GSM_7BIT",
2650
+ length: 0,
2651
+ characterPerMessage: singleLengths.GSM_7BIT,
2652
+ inCurrentMessage: 0,
2653
+ remaining: singleLengths.GSM_7BIT,
2654
+ messages: 0
2655
+ };
2656
+ }
2657
+ const encoding = detectEncoding(text);
2658
+ const extCharCount = encoding === "GSM_7BIT_EXT" ? (text.match(GSM_7BIT_EXT_CHAR_REGEXP) ?? []).length : 0;
2659
+ const length = text.length + extCharCount;
2660
+ let characterPerMessage = singleLengths[encoding];
2661
+ if (length > characterPerMessage) {
2662
+ characterPerMessage = multiLengths[encoding];
2663
+ }
2664
+ const messages = Math.ceil(length / characterPerMessage);
2665
+ const inCurrentMessage = length - characterPerMessage * (messages - 1);
2666
+ const remaining = characterPerMessage * messages - length;
2667
+ return {
2668
+ encoding,
2669
+ length,
2670
+ characterPerMessage,
2671
+ inCurrentMessage,
2672
+ remaining,
2673
+ messages
2674
+ };
2675
+ };
2676
+
2621
2677
  // src/index.ts
2622
2678
  var isBrowser = typeof globalThis !== "undefined" && typeof globalThis.document !== "undefined";
2623
2679
  var isNode = typeof process !== "undefined" && !!process.versions?.node;
2624
2680
 
2625
- export { addSpaceBetweenNumbers, addThousandsSpace, areArraysDeepEqualUnordered, areArraysEqual, assessSecurityRisks, basicSanitize, capitalizeFirst, capitalizeWords, checkMarkdownSecurity, chunk, clamp, cleanObject, compact, currencyToSymbol, debounce, deburr, decodeBase36Code, decodeObject, decodeString, deferAfterResponse, deferAfterResponseNonCritical, deferNonCritical, deferPostReturn, delay, difference, encodeBase36Code, encodeObject, encodeString, fill, flatten, flattenDepth, flattenDepthBase, flattenOnce, formatBytes, formatCurrency, formatCurrencyPro, formatDecimalNumber, generatePassword, generatePasswordWithOptions, getStringSimilarity, groupBy, hasNilOrEmpty, humanFileSize, intersection, isBrowser, isFlattenable, isNil, isNilEmptyOrEmptyObject, isNilEmptyOrZeroLen, isNilEmptyOrZeroLength, isNilOrEmpty, isNilOrNaN, isNilOrZeroLen, isNilOrZeroLength, isNilText, isNilTextOrEmpty, isNode, isNullOrUndefined, isNullOrUndefinedEmptyOrZero, isNullOrUndefinedInArray, isNullOrUndefinedOrNaN, isNullOrUndefinedTextInc, isNullUndefinedOrEmpty, isNullUndefinedOrEmptyEnforced, isNullUndefinedOrZero, isPTTaxId, isValidIBAN, isValidPTTaxId, numbersEqual, objectToString, omit, otp, parseName, parseToBool, parseToNumber, pick, pluck, pushAll, randomDigits, removeDiacritics, round, safeAdd, safeDivide, safeJSONParse, safeMultiply, safeParseFloat, safeParseInt, safeSubtract, sanitize, sanitizeMarkdown, sentenceCase, shuffle, slugify, sortBy, stringSimilarity, symbolToCurrency, throttle, toBool, toInteger, toNumber, uniq, uniqBy };
2681
+ export { GSM_7BIT_EXT_CHAR_REGEXP, GSM_7BIT_EXT_REGEXP, GSM_7BIT_REGEXP, addSpaceBetweenNumbers, addThousandsSpace, areArraysDeepEqualUnordered, areArraysEqual, assessSecurityRisks, basicSanitize, capitalizeFirst, capitalizeWords, checkMarkdownSecurity, chunk, clamp, cleanObject, compact, currencyToSymbol, debounce, deburr, decodeBase36Code, decodeObject, decodeString, deferAfterResponse, deferAfterResponseNonCritical, deferNonCritical, deferPostReturn, delay, difference, encodeBase36Code, encodeObject, encodeString, fill, flatten, flattenDepth, flattenDepthBase, flattenOnce, formatBytes, formatCurrency, formatCurrencyPro, formatDecimalNumber, generatePassword, generatePasswordWithOptions, getStringSimilarity, groupBy, hasNilOrEmpty, humanFileSize, intersection, isBrowser, isFlattenable, isNil, isNilEmptyOrEmptyObject, isNilEmptyOrZeroLen, isNilEmptyOrZeroLength, isNilOrEmpty, isNilOrNaN, isNilOrZeroLen, isNilOrZeroLength, isNilText, isNilTextOrEmpty, isNode, isNullOrUndefined, isNullOrUndefinedEmptyOrZero, isNullOrUndefinedInArray, isNullOrUndefinedOrNaN, isNullOrUndefinedTextInc, isNullUndefinedOrEmpty, isNullUndefinedOrEmptyEnforced, isNullUndefinedOrZero, isPTTaxId, isValidIBAN, isValidPTTaxId, numbersEqual, objectToString, omit, otp, parseName, parseToBool, parseToNumber, pick, pluck, pushAll, randomDigits, removeDiacritics, round, safeAdd, safeDivide, safeJSONParse, safeMultiply, safeParseFloat, safeParseInt, safeSubtract, sanitize, sanitizeMarkdown, sentenceCase, shuffle, slugify, smsLength, sortBy, stringSimilarity, symbolToCurrency, throttle, toBool, toInteger, toNumber, uniq, uniqBy };
2626
2682
  //# sourceMappingURL=index.js.map
2627
2683
  //# sourceMappingURL=index.js.map