ofsc-utility 1.0.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/case-converters/index.d.ts +11 -0
- package/dist/case-converters/index.js +76 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +52 -0
- package/dist/oauthTokenService/index.d.ts +1 -0
- package/dist/oauthTokenService/index.js +30 -0
- package/dist/transformers/index.d.ts +14 -0
- package/dist/transformers/index.js +97 -0
- package/dist/types.d.ts +40 -0
- package/dist/types.js +2 -0
- package/dist/utilities/index.d.ts +0 -0
- package/dist/utilities/index.js +1 -0
- package/dist/validators/index.d.ts +14 -0
- package/dist/validators/index.js +126 -0
- package/package.json +39 -0
- package/readme.md +18 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Case conversion utilities
|
|
3
|
+
*/
|
|
4
|
+
export declare function toCamelCase(str: string): string;
|
|
5
|
+
export declare function toPascalCase(str: string): string;
|
|
6
|
+
export declare function toSnakeCase(str: string): string;
|
|
7
|
+
export declare function toKebabCase(str: string): string;
|
|
8
|
+
export declare function toTitleCase(str: string): string;
|
|
9
|
+
export declare function toSentenceCase(str: string): string;
|
|
10
|
+
export declare function toConstantCase(str: string): string;
|
|
11
|
+
export declare function toDotCase(str: string): string;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Case conversion utilities
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.toCamelCase = toCamelCase;
|
|
7
|
+
exports.toPascalCase = toPascalCase;
|
|
8
|
+
exports.toSnakeCase = toSnakeCase;
|
|
9
|
+
exports.toKebabCase = toKebabCase;
|
|
10
|
+
exports.toTitleCase = toTitleCase;
|
|
11
|
+
exports.toSentenceCase = toSentenceCase;
|
|
12
|
+
exports.toConstantCase = toConstantCase;
|
|
13
|
+
exports.toDotCase = toDotCase;
|
|
14
|
+
function toCamelCase(str) {
|
|
15
|
+
if (!str)
|
|
16
|
+
return '';
|
|
17
|
+
return str
|
|
18
|
+
.replace(/(?:^\w|[A-Z]|\b\w)/g, (word, index) => index === 0 ? word.toLowerCase() : word.toUpperCase())
|
|
19
|
+
.replace(/\s+/g, '')
|
|
20
|
+
.replace(/[_-]/g, '');
|
|
21
|
+
}
|
|
22
|
+
function toPascalCase(str) {
|
|
23
|
+
if (!str)
|
|
24
|
+
return '';
|
|
25
|
+
return str
|
|
26
|
+
.replace(/(?:^\w|[A-Z]|\b\w)/g, (word) => word.toUpperCase())
|
|
27
|
+
.replace(/\s+/g, '')
|
|
28
|
+
.replace(/[_-]/g, '');
|
|
29
|
+
}
|
|
30
|
+
function toSnakeCase(str) {
|
|
31
|
+
if (!str)
|
|
32
|
+
return '';
|
|
33
|
+
return str
|
|
34
|
+
.trim()
|
|
35
|
+
.replace(/([a-z])([A-Z])/g, '$1_$2')
|
|
36
|
+
.replace(/[\s-]+/g, '_')
|
|
37
|
+
.toLowerCase();
|
|
38
|
+
}
|
|
39
|
+
function toKebabCase(str) {
|
|
40
|
+
if (!str)
|
|
41
|
+
return '';
|
|
42
|
+
return str
|
|
43
|
+
.trim()
|
|
44
|
+
.replace(/([a-z])([A-Z])/g, '$1-$2')
|
|
45
|
+
.replace(/[\s_]+/g, '-')
|
|
46
|
+
.toLowerCase();
|
|
47
|
+
}
|
|
48
|
+
function toTitleCase(str) {
|
|
49
|
+
if (!str)
|
|
50
|
+
return '';
|
|
51
|
+
return str
|
|
52
|
+
.toLowerCase()
|
|
53
|
+
.split(' ')
|
|
54
|
+
.map(word => word.charAt(0).toUpperCase() + word.slice(1))
|
|
55
|
+
.join(' ')
|
|
56
|
+
.replace(/([a-z])([A-Z])/g, '$1 $2');
|
|
57
|
+
}
|
|
58
|
+
function toSentenceCase(str) {
|
|
59
|
+
if (!str)
|
|
60
|
+
return '';
|
|
61
|
+
if (str.length === 1)
|
|
62
|
+
return str.toUpperCase();
|
|
63
|
+
return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase();
|
|
64
|
+
}
|
|
65
|
+
function toConstantCase(str) {
|
|
66
|
+
return toSnakeCase(str).toUpperCase();
|
|
67
|
+
}
|
|
68
|
+
function toDotCase(str) {
|
|
69
|
+
if (!str)
|
|
70
|
+
return '';
|
|
71
|
+
return str
|
|
72
|
+
.trim()
|
|
73
|
+
.replace(/([a-z])([A-Z])/g, '$1.$2')
|
|
74
|
+
.replace(/[\s_-]+/g, '.')
|
|
75
|
+
.toLowerCase();
|
|
76
|
+
}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
36
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.getOAuthToken = exports.OauthTokenService = void 0;
|
|
40
|
+
// Export all methods grouped by category
|
|
41
|
+
exports.OauthTokenService = __importStar(require("./oauthTokenService"));
|
|
42
|
+
// Export types
|
|
43
|
+
__exportStar(require("./types"), exports);
|
|
44
|
+
// Export individual popular methods for convenience
|
|
45
|
+
var oauthTokenService_1 = require("./oauthTokenService");
|
|
46
|
+
Object.defineProperty(exports, "getOAuthToken", { enumerable: true, get: function () { return oauthTokenService_1.getOAuthToken; } });
|
|
47
|
+
// Default export with all functionality
|
|
48
|
+
const StringUtils = {
|
|
49
|
+
// Case converters
|
|
50
|
+
getOAuthToken: require('./oauthTokenService').getOAuthToken,
|
|
51
|
+
};
|
|
52
|
+
exports.default = StringUtils;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getOAuthToken(clientId: string, clientSecret: string, instanceUrl: string): Promise<any>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getOAuthToken = getOAuthToken;
|
|
4
|
+
async function getOAuthToken(clientId, clientSecret, instanceUrl) {
|
|
5
|
+
const url = `https://${instanceUrl}.fs.ocs.oraclecloud.com/rest/oauthTokenService/v2/token`;
|
|
6
|
+
const credentials = btoa(`${clientId}:${clientSecret}`);
|
|
7
|
+
const headers = {
|
|
8
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
9
|
+
'Authorization': `Basic ${credentials}`
|
|
10
|
+
};
|
|
11
|
+
const body = new URLSearchParams({
|
|
12
|
+
'grant_type': 'client_credentials'
|
|
13
|
+
});
|
|
14
|
+
try {
|
|
15
|
+
const response = await fetch(url, {
|
|
16
|
+
method: 'POST',
|
|
17
|
+
headers: headers,
|
|
18
|
+
body: body
|
|
19
|
+
});
|
|
20
|
+
if (!response.ok) {
|
|
21
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
|
22
|
+
}
|
|
23
|
+
const data = await response.json();
|
|
24
|
+
return data.access_token;
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
console.error('Error fetching OAuth token:', error);
|
|
28
|
+
throw error;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* String transformation utilities
|
|
3
|
+
*/
|
|
4
|
+
export declare function reverse(str: string): string;
|
|
5
|
+
export declare function shuffle(str: string): string;
|
|
6
|
+
export declare function slugify(str: string): string;
|
|
7
|
+
export declare function htmlEscape(str: string): string;
|
|
8
|
+
export declare function htmlUnescape(str: string): string;
|
|
9
|
+
export declare function capitalizeWords(str: string): string;
|
|
10
|
+
export declare function replaceAll(str: string, search: string, replacement: string): string;
|
|
11
|
+
export declare function removeWhitespace(str: string): string;
|
|
12
|
+
export declare function normalizeSpaces(str: string): string;
|
|
13
|
+
export declare function toBase64(str: string): string;
|
|
14
|
+
export declare function fromBase64(str: string): string;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* String transformation utilities
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.reverse = reverse;
|
|
7
|
+
exports.shuffle = shuffle;
|
|
8
|
+
exports.slugify = slugify;
|
|
9
|
+
exports.htmlEscape = htmlEscape;
|
|
10
|
+
exports.htmlUnescape = htmlUnescape;
|
|
11
|
+
exports.capitalizeWords = capitalizeWords;
|
|
12
|
+
exports.replaceAll = replaceAll;
|
|
13
|
+
exports.removeWhitespace = removeWhitespace;
|
|
14
|
+
exports.normalizeSpaces = normalizeSpaces;
|
|
15
|
+
exports.toBase64 = toBase64;
|
|
16
|
+
exports.fromBase64 = fromBase64;
|
|
17
|
+
function reverse(str) {
|
|
18
|
+
if (!str)
|
|
19
|
+
return '';
|
|
20
|
+
return str.split('').reverse().join('');
|
|
21
|
+
}
|
|
22
|
+
function shuffle(str) {
|
|
23
|
+
if (!str)
|
|
24
|
+
return '';
|
|
25
|
+
const array = str.split('');
|
|
26
|
+
for (let i = array.length - 1; i > 0; i--) {
|
|
27
|
+
const j = Math.floor(Math.random() * (i + 1));
|
|
28
|
+
[array[i], array[j]] = [array[j], array[i]];
|
|
29
|
+
}
|
|
30
|
+
return array.join('');
|
|
31
|
+
}
|
|
32
|
+
function slugify(str) {
|
|
33
|
+
if (!str)
|
|
34
|
+
return '';
|
|
35
|
+
return str
|
|
36
|
+
.toLowerCase()
|
|
37
|
+
.trim()
|
|
38
|
+
.replace(/[^\w\s-]/g, '')
|
|
39
|
+
.replace(/[\s_-]+/g, '-')
|
|
40
|
+
.replace(/^-+|-+$/g, '');
|
|
41
|
+
}
|
|
42
|
+
function htmlEscape(str) {
|
|
43
|
+
if (!str)
|
|
44
|
+
return '';
|
|
45
|
+
const escapeMap = {
|
|
46
|
+
'&': '&',
|
|
47
|
+
'<': '<',
|
|
48
|
+
'>': '>',
|
|
49
|
+
'"': '"',
|
|
50
|
+
"'": ''',
|
|
51
|
+
'/': '/'
|
|
52
|
+
};
|
|
53
|
+
return str.replace(/[&<>"'/]/g, char => escapeMap[char]);
|
|
54
|
+
}
|
|
55
|
+
function htmlUnescape(str) {
|
|
56
|
+
if (!str)
|
|
57
|
+
return '';
|
|
58
|
+
const unescapeMap = {
|
|
59
|
+
'&': '&',
|
|
60
|
+
'<': '<',
|
|
61
|
+
'>': '>',
|
|
62
|
+
'"': '"',
|
|
63
|
+
''': "'",
|
|
64
|
+
'/': '/'
|
|
65
|
+
};
|
|
66
|
+
return str.replace(/&|<|>|"|'|//g, entity => unescapeMap[entity]);
|
|
67
|
+
}
|
|
68
|
+
function capitalizeWords(str) {
|
|
69
|
+
if (!str)
|
|
70
|
+
return '';
|
|
71
|
+
return str.replace(/\b\w/g, char => char.toUpperCase());
|
|
72
|
+
}
|
|
73
|
+
function replaceAll(str, search, replacement) {
|
|
74
|
+
if (!str)
|
|
75
|
+
return '';
|
|
76
|
+
return str.split(search).join(replacement);
|
|
77
|
+
}
|
|
78
|
+
function removeWhitespace(str) {
|
|
79
|
+
if (!str)
|
|
80
|
+
return '';
|
|
81
|
+
return str.replace(/\s+/g, '');
|
|
82
|
+
}
|
|
83
|
+
function normalizeSpaces(str) {
|
|
84
|
+
if (!str)
|
|
85
|
+
return '';
|
|
86
|
+
return str.replace(/\s+/g, ' ').trim();
|
|
87
|
+
}
|
|
88
|
+
function toBase64(str) {
|
|
89
|
+
if (!str)
|
|
90
|
+
return '';
|
|
91
|
+
return Buffer.from(str).toString('base64');
|
|
92
|
+
}
|
|
93
|
+
function fromBase64(str) {
|
|
94
|
+
if (!str)
|
|
95
|
+
return '';
|
|
96
|
+
return Buffer.from(str, 'base64').toString('utf8');
|
|
97
|
+
}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export interface StringValidationResult {
|
|
2
|
+
isValid: boolean;
|
|
3
|
+
message?: string;
|
|
4
|
+
}
|
|
5
|
+
export interface TruncateOptions {
|
|
6
|
+
ellipsis?: string;
|
|
7
|
+
preserveWords?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface CaseConverter {
|
|
10
|
+
toCamelCase: (str: string) => string;
|
|
11
|
+
toPascalCase: (str: string) => string;
|
|
12
|
+
toSnakeCase: (str: string) => string;
|
|
13
|
+
toKebabCase: (str: string) => string;
|
|
14
|
+
toTitleCase: (str: string) => string;
|
|
15
|
+
}
|
|
16
|
+
export interface StringValidator {
|
|
17
|
+
isEmail: (str: string) => boolean;
|
|
18
|
+
isURL: (str: string) => boolean;
|
|
19
|
+
isStrongPassword: (str: string) => StringValidationResult;
|
|
20
|
+
isPalindrome: (str: string) => boolean;
|
|
21
|
+
hasSpecialChars: (str: string) => boolean;
|
|
22
|
+
}
|
|
23
|
+
export interface StringTransformer {
|
|
24
|
+
reverse: (str: string) => string;
|
|
25
|
+
shuffle: (str: string) => string;
|
|
26
|
+
slugify: (str: string) => string;
|
|
27
|
+
htmlEscape: (str: string) => string;
|
|
28
|
+
htmlUnescape: (str: string) => string;
|
|
29
|
+
}
|
|
30
|
+
export interface StringUtility {
|
|
31
|
+
truncate: (str: string, maxLength: number, options?: TruncateOptions) => string;
|
|
32
|
+
countWords: (str: string) => number;
|
|
33
|
+
countCharacters: (str: string, includeSpaces?: boolean) => number;
|
|
34
|
+
extractEmails: (str: string) => string[];
|
|
35
|
+
extractNumbers: (str: string) => number[];
|
|
36
|
+
generateRandom: (length: number, options?: {
|
|
37
|
+
includeNumbers?: boolean;
|
|
38
|
+
includeSpecialChars?: boolean;
|
|
39
|
+
}) => string;
|
|
40
|
+
}
|
package/dist/types.js
ADDED
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { StringValidationResult } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* String validation utilities
|
|
4
|
+
*/
|
|
5
|
+
export declare function isEmail(str: string): boolean;
|
|
6
|
+
export declare function isURL(str: string): boolean;
|
|
7
|
+
export declare function isStrongPassword(str: string): StringValidationResult;
|
|
8
|
+
export declare function isPalindrome(str: string): boolean;
|
|
9
|
+
export declare function hasSpecialChars(str: string): boolean;
|
|
10
|
+
export declare function isNumeric(str: string): boolean;
|
|
11
|
+
export declare function isAlpha(str: string): boolean;
|
|
12
|
+
export declare function isAlphaNumeric(str: string): boolean;
|
|
13
|
+
export declare function isEmpty(str: string): boolean;
|
|
14
|
+
export declare function isCreditCard(str: string): boolean;
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isEmail = isEmail;
|
|
4
|
+
exports.isURL = isURL;
|
|
5
|
+
exports.isStrongPassword = isStrongPassword;
|
|
6
|
+
exports.isPalindrome = isPalindrome;
|
|
7
|
+
exports.hasSpecialChars = hasSpecialChars;
|
|
8
|
+
exports.isNumeric = isNumeric;
|
|
9
|
+
exports.isAlpha = isAlpha;
|
|
10
|
+
exports.isAlphaNumeric = isAlphaNumeric;
|
|
11
|
+
exports.isEmpty = isEmpty;
|
|
12
|
+
exports.isCreditCard = isCreditCard;
|
|
13
|
+
/**
|
|
14
|
+
* String validation utilities
|
|
15
|
+
*/
|
|
16
|
+
function isEmail(str) {
|
|
17
|
+
if (!str)
|
|
18
|
+
return false;
|
|
19
|
+
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
20
|
+
return emailRegex.test(str);
|
|
21
|
+
}
|
|
22
|
+
function isURL(str) {
|
|
23
|
+
if (!str)
|
|
24
|
+
return false;
|
|
25
|
+
try {
|
|
26
|
+
const url = new URL(str);
|
|
27
|
+
return url.protocol === 'http:' || url.protocol === 'https:';
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
function isStrongPassword(str) {
|
|
34
|
+
if (!str) {
|
|
35
|
+
return {
|
|
36
|
+
isValid: false,
|
|
37
|
+
message: 'Password cannot be empty'
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
const minLength = 8;
|
|
41
|
+
const hasUpperCase = /[A-Z]/.test(str);
|
|
42
|
+
const hasLowerCase = /[a-z]/.test(str);
|
|
43
|
+
const hasNumbers = /\d/.test(str);
|
|
44
|
+
const hasSpecialChars = /[!@#$%^&*(),.?":{}|<>]/.test(str);
|
|
45
|
+
if (str.length < minLength) {
|
|
46
|
+
return {
|
|
47
|
+
isValid: false,
|
|
48
|
+
message: `Password must be at least ${minLength} characters long`
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
if (!hasUpperCase) {
|
|
52
|
+
return {
|
|
53
|
+
isValid: false,
|
|
54
|
+
message: 'Password must contain at least one uppercase letter'
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
if (!hasLowerCase) {
|
|
58
|
+
return {
|
|
59
|
+
isValid: false,
|
|
60
|
+
message: 'Password must contain at least one lowercase letter'
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
if (!hasNumbers) {
|
|
64
|
+
return {
|
|
65
|
+
isValid: false,
|
|
66
|
+
message: 'Password must contain at least one number'
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
if (!hasSpecialChars) {
|
|
70
|
+
return {
|
|
71
|
+
isValid: false,
|
|
72
|
+
message: 'Password must contain at least one special character'
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
return { isValid: true };
|
|
76
|
+
}
|
|
77
|
+
function isPalindrome(str) {
|
|
78
|
+
if (!str)
|
|
79
|
+
return true;
|
|
80
|
+
const cleanStr = str.toLowerCase().replace(/[^a-z0-9]/g, '');
|
|
81
|
+
return cleanStr === cleanStr.split('').reverse().join('');
|
|
82
|
+
}
|
|
83
|
+
function hasSpecialChars(str) {
|
|
84
|
+
if (!str)
|
|
85
|
+
return false;
|
|
86
|
+
return /[!@#$%^&*(),.?":{}|<>]/.test(str);
|
|
87
|
+
}
|
|
88
|
+
function isNumeric(str) {
|
|
89
|
+
if (!str)
|
|
90
|
+
return false;
|
|
91
|
+
return /^-?\d*\.?\d+$/.test(str);
|
|
92
|
+
}
|
|
93
|
+
function isAlpha(str) {
|
|
94
|
+
if (!str)
|
|
95
|
+
return false;
|
|
96
|
+
return /^[A-Za-z]+$/.test(str);
|
|
97
|
+
}
|
|
98
|
+
function isAlphaNumeric(str) {
|
|
99
|
+
if (!str)
|
|
100
|
+
return false;
|
|
101
|
+
return /^[A-Za-z0-9]+$/.test(str);
|
|
102
|
+
}
|
|
103
|
+
function isEmpty(str) {
|
|
104
|
+
return !str || str.trim().length === 0;
|
|
105
|
+
}
|
|
106
|
+
function isCreditCard(str) {
|
|
107
|
+
if (!str)
|
|
108
|
+
return false;
|
|
109
|
+
// Simple Luhn algorithm check
|
|
110
|
+
const cleanStr = str.replace(/\s+/g, '');
|
|
111
|
+
if (!/^\d+$/.test(cleanStr))
|
|
112
|
+
return false;
|
|
113
|
+
let sum = 0;
|
|
114
|
+
let isEven = false;
|
|
115
|
+
for (let i = cleanStr.length - 1; i >= 0; i--) {
|
|
116
|
+
let digit = parseInt(cleanStr[i], 10);
|
|
117
|
+
if (isEven) {
|
|
118
|
+
digit *= 2;
|
|
119
|
+
if (digit > 9)
|
|
120
|
+
digit -= 9;
|
|
121
|
+
}
|
|
122
|
+
sum += digit;
|
|
123
|
+
isEven = !isEven;
|
|
124
|
+
}
|
|
125
|
+
return sum % 10 === 0;
|
|
126
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "ofsc-utility",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "A wrapper for Oracle Field Service REST API",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "tsc",
|
|
9
|
+
"prepublishOnly": "npm run build",
|
|
10
|
+
"test": "jest",
|
|
11
|
+
"test:watch": "jest --watch",
|
|
12
|
+
"test:coverage": "jest --coverage",
|
|
13
|
+
"dev": "ts-node src/index.ts"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"ofs",
|
|
17
|
+
"oracle",
|
|
18
|
+
"getOAuthToken"
|
|
19
|
+
],
|
|
20
|
+
"author": "MOHD AHSHAN DANISH <mailtodanish@gmail.com>",
|
|
21
|
+
"license": "MIT",
|
|
22
|
+
"files": [
|
|
23
|
+
"dist",
|
|
24
|
+
"README.md",
|
|
25
|
+
"LICENSE"
|
|
26
|
+
],
|
|
27
|
+
"repository": {
|
|
28
|
+
"type": "git",
|
|
29
|
+
"url": "https://github.com/your-username/enhanced-string-utils"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"typescript": "^5.0.0",
|
|
33
|
+
"@types/node": "^20.0.0",
|
|
34
|
+
"ts-node": "^10.9.0",
|
|
35
|
+
"jest": "^29.0.0",
|
|
36
|
+
"@types/jest": "^29.0.0",
|
|
37
|
+
"ts-jest": "^29.0.0"
|
|
38
|
+
}
|
|
39
|
+
}
|
package/readme.md
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Enhanced ofsc utility
|
|
2
|
+
|
|
3
|
+
A comprehensive TypeScript oracle field service utility library with 40+ methods.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- ๐ **40+ utility methods**
|
|
8
|
+
- ๐ **Written in TypeScript** with full type definitions
|
|
9
|
+
- ๐งช **Completely tested** with Jest
|
|
10
|
+
- ๐ฆ **Zero dependencies**
|
|
11
|
+
- ๐ฏ **Modular architecture** for tree-shaking
|
|
12
|
+
- ๐ง **Multiple import styles** for flexibility
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install ofsc-utility
|
|
18
|
+
```
|