@yangsaiyam/helper 1.12.6 → 1.12.7

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.
Files changed (52) hide show
  1. package/dist/index.cjs +56 -30
  2. package/dist/index.d.cts +23 -1
  3. package/dist/index.d.ts +677 -17
  4. package/dist/index.js +729 -17
  5. package/package.json +1 -1
  6. package/dist/addressess/index.d.ts +0 -137
  7. package/dist/addressess/index.js +0 -24
  8. package/dist/addressess/index.test.d.ts +0 -1
  9. package/dist/addressess/index.test.js +0 -16
  10. package/dist/assessment-question/index.d.ts +0 -19
  11. package/dist/assessment-question/index.js +0 -22
  12. package/dist/assessment-question/index.test.d.ts +0 -1
  13. package/dist/assessment-question/index.test.js +0 -27
  14. package/dist/career/index.d.ts +0 -132
  15. package/dist/career/index.js +0 -40
  16. package/dist/contact-form/index.d.ts +0 -13
  17. package/dist/contact-form/index.js +0 -13
  18. package/dist/email-history/index.d.ts +0 -17
  19. package/dist/email-history/index.js +0 -6
  20. package/dist/email-template/index.d.ts +0 -13
  21. package/dist/email-template/index.js +0 -5
  22. package/dist/files/index.d.ts +0 -18
  23. package/dist/files/index.js +0 -8
  24. package/dist/job-applications/index.d.ts +0 -33
  25. package/dist/job-applications/index.js +0 -10
  26. package/dist/locale/index.d.ts +0 -9
  27. package/dist/locale/index.js +0 -4
  28. package/dist/roles/index.d.ts +0 -61
  29. package/dist/roles/index.js +0 -170
  30. package/dist/roles/index.test.d.ts +0 -1
  31. package/dist/roles/index.test.js +0 -80
  32. package/dist/routes/index.d.ts +0 -80
  33. package/dist/routes/index.js +0 -106
  34. package/dist/routes/index.test.d.ts +0 -1
  35. package/dist/routes/index.test.js +0 -92
  36. package/dist/shared/helpers.d.ts +0 -5
  37. package/dist/shared/helpers.js +0 -15
  38. package/dist/shared/types.d.ts +0 -5
  39. package/dist/shared/types.js +0 -1
  40. package/dist/time/index.d.ts +0 -73
  41. package/dist/time/index.js +0 -161
  42. package/dist/time/index.test.d.ts +0 -1
  43. package/dist/time/index.test.js +0 -35
  44. package/dist/track/index.d.ts +0 -17
  45. package/dist/track/index.js +0 -14
  46. package/dist/track/index.test.d.ts +0 -1
  47. package/dist/track/index.test.js +0 -7
  48. package/dist/tsconfig.json +0 -6
  49. package/dist/url-prefix/index.d.ts +0 -8
  50. package/dist/url-prefix/index.js +0 -9
  51. package/dist/website/index.d.ts +0 -16
  52. package/dist/website/index.js +0 -17
@@ -1,161 +0,0 @@
1
- import dayjs from "dayjs";
2
- import timezone from "dayjs/plugin/timezone.js";
3
- import utc from "dayjs/plugin/utc.js";
4
- dayjs.extend(utc);
5
- dayjs.extend(timezone);
6
- export const TIMEZONE = [
7
- { key: 1, value: "UTC", i18nKey: "time.timezone.utc" },
8
- {
9
- key: 2,
10
- value: "Asia/Kuala_Lumpur",
11
- i18nKey: "time.timezone.asiaKualaLumpur",
12
- },
13
- {
14
- key: 3,
15
- value: "Asia/Singapore",
16
- i18nKey: "time.timezone.asiaSingapore",
17
- },
18
- {
19
- key: 4,
20
- value: "Asia/Bangkok",
21
- i18nKey: "time.timezone.asiaBangkok",
22
- },
23
- {
24
- key: 5,
25
- value: "Asia/Jakarta",
26
- i18nKey: "time.timezone.asiaJakarta",
27
- },
28
- {
29
- key: 6,
30
- value: "Asia/Manila",
31
- i18nKey: "time.timezone.asiaManila",
32
- },
33
- {
34
- key: 7,
35
- value: "Asia/Hong_Kong",
36
- i18nKey: "time.timezone.asiaHongKong",
37
- },
38
- {
39
- key: 8,
40
- value: "Asia/Shanghai",
41
- i18nKey: "time.timezone.asiaShanghai",
42
- },
43
- {
44
- key: 9,
45
- value: "Asia/Tokyo",
46
- i18nKey: "time.timezone.asiaTokyo",
47
- },
48
- {
49
- key: 10,
50
- value: "Australia/Sydney",
51
- i18nKey: "time.timezone.australiaSydney",
52
- },
53
- {
54
- key: 11,
55
- value: "Europe/London",
56
- i18nKey: "time.timezone.europeLondon",
57
- },
58
- {
59
- key: 12,
60
- value: "Europe/Berlin",
61
- i18nKey: "time.timezone.europeBerlin",
62
- },
63
- {
64
- key: 13,
65
- value: "America/New_York",
66
- i18nKey: "time.timezone.americaNewYork",
67
- },
68
- {
69
- key: 14,
70
- value: "America/Chicago",
71
- i18nKey: "time.timezone.americaChicago",
72
- },
73
- {
74
- key: 15,
75
- value: "America/Denver",
76
- i18nKey: "time.timezone.americaDenver",
77
- },
78
- {
79
- key: 16,
80
- value: "America/Los_Angeles",
81
- i18nKey: "time.timezone.americaLosAngeles",
82
- },
83
- ];
84
- const TIMEZONE_ALIAS_TO_CANONICAL = {
85
- utc: "UTC",
86
- "etc/utc": "UTC",
87
- "asia/kuala_lumpur": "Asia/Kuala_Lumpur",
88
- "asia/kuala lumpur": "Asia/Kuala_Lumpur",
89
- "kuala_lumpur": "Asia/Kuala_Lumpur",
90
- "kuala lumpur": "Asia/Kuala_Lumpur",
91
- "asia/singapore": "Asia/Singapore",
92
- singapore: "Asia/Singapore",
93
- "asia/bangkok": "Asia/Bangkok",
94
- bangkok: "Asia/Bangkok",
95
- "asia/jakarta": "Asia/Jakarta",
96
- jakarta: "Asia/Jakarta",
97
- "asia/manila": "Asia/Manila",
98
- manila: "Asia/Manila",
99
- "asia/hong_kong": "Asia/Hong_Kong",
100
- "asia/hong kong": "Asia/Hong_Kong",
101
- "hong_kong": "Asia/Hong_Kong",
102
- "hong kong": "Asia/Hong_Kong",
103
- "asia/shanghai": "Asia/Shanghai",
104
- shanghai: "Asia/Shanghai",
105
- "asia/tokyo": "Asia/Tokyo",
106
- tokyo: "Asia/Tokyo",
107
- "australia/sydney": "Australia/Sydney",
108
- sydney: "Australia/Sydney",
109
- "europe/london": "Europe/London",
110
- london: "Europe/London",
111
- "europe/berlin": "Europe/Berlin",
112
- berlin: "Europe/Berlin",
113
- "america/new_york": "America/New_York",
114
- "america/new york": "America/New_York",
115
- "new_york": "America/New_York",
116
- "new york": "America/New_York",
117
- "america/chicago": "America/Chicago",
118
- chicago: "America/Chicago",
119
- "america/denver": "America/Denver",
120
- denver: "America/Denver",
121
- "america/los_angeles": "America/Los_Angeles",
122
- "america/los angeles": "America/Los_Angeles",
123
- "los_angeles": "America/Los_Angeles",
124
- "los angeles": "America/Los_Angeles",
125
- };
126
- const TIMEZONE_I18N_KEY = Object.fromEntries(TIMEZONE.map(({ value, i18nKey }) => [value, i18nKey]));
127
- function toTimezoneAlias(timezone) {
128
- return timezone.trim().toLowerCase().replace(/-/g, "_");
129
- }
130
- export function normalizeTimezone(timezone) {
131
- if (!timezone) {
132
- return undefined;
133
- }
134
- return TIMEZONE_ALIAS_TO_CANONICAL[toTimezoneAlias(timezone)];
135
- }
136
- export function timezoneToUtc(timezone, timestamp = Date.now()) {
137
- const normalizedTimezone = normalizeTimezone(timezone);
138
- if (!normalizedTimezone) {
139
- return undefined;
140
- }
141
- return `UTC${dayjs(timestamp).tz(normalizedTimezone).format("Z")}`;
142
- }
143
- export const TIMEZONE_CURRENT_UTC_OFFSET = Object.fromEntries(TIMEZONE.map(({ value }) => [value, timezoneToUtc(value)]));
144
- export const TIMEZONE_TO_UTC = TIMEZONE_CURRENT_UTC_OFFSET;
145
- export function timezoneLabelKey(timezone) {
146
- const normalizedTimezone = normalizeTimezone(timezone);
147
- if (!normalizedTimezone) {
148
- return "time.timezone.utc";
149
- }
150
- return TIMEZONE_I18N_KEY[normalizedTimezone];
151
- }
152
- export function convertTimestampToTimezone(timestamp, sourceTimezone, targetTimezone) {
153
- const normalizedSourceTimezone = normalizeTimezone(sourceTimezone);
154
- const normalizedTargetTimezone = normalizeTimezone(targetTimezone);
155
- if (!normalizedSourceTimezone || !normalizedTargetTimezone) {
156
- return undefined;
157
- }
158
- const sourceDateTime = dayjs(timestamp).tz(normalizedSourceTimezone);
159
- const preservedWallClock = sourceDateTime.format("YYYY-MM-DDTHH:mm:ss.SSS");
160
- return dayjs.tz(preservedWallClock, normalizedTargetTimezone).valueOf();
161
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,35 +0,0 @@
1
- import assert from "node:assert/strict";
2
- import { convertTimestampToTimezone, TIMEZONE, TIMEZONE_CURRENT_UTC_OFFSET, TIMEZONE_TO_UTC, normalizeTimezone, timezoneLabelKey, timezoneToUtc, } from "./index.js";
3
- assert.equal(normalizeTimezone("UTC"), "UTC");
4
- assert.equal(normalizeTimezone("utc"), "UTC");
5
- assert.equal(normalizeTimezone("Etc/UTC"), "UTC");
6
- assert.equal(normalizeTimezone("Asia/Kuala_Lumpur"), "Asia/Kuala_Lumpur");
7
- assert.equal(normalizeTimezone("asia/kuala lumpur"), "Asia/Kuala_Lumpur");
8
- assert.equal(normalizeTimezone("singapore"), "Asia/Singapore");
9
- assert.equal(normalizeTimezone("unknown"), undefined);
10
- assert.equal(normalizeTimezone(undefined), undefined);
11
- assert.equal(timezoneToUtc("UTC"), "UTC+00:00");
12
- assert.equal(timezoneToUtc("Etc/UTC"), "UTC+00:00");
13
- assert.equal(timezoneToUtc("Asia/Kuala_Lumpur"), "UTC+08:00");
14
- assert.equal(timezoneToUtc("kuala lumpur"), "UTC+08:00");
15
- assert.equal(timezoneToUtc("America/New_York", Date.UTC(2024, 0, 1, 12, 0, 0)), "UTC-05:00");
16
- assert.equal(timezoneToUtc("America/New_York", Date.UTC(2024, 6, 1, 12, 0, 0)), "UTC-04:00");
17
- assert.equal(timezoneToUtc("unknown"), undefined);
18
- assert.equal(timezoneLabelKey("UTC"), "time.timezone.utc");
19
- assert.equal(timezoneLabelKey("Asia/Singapore"), "time.timezone.asiaSingapore");
20
- assert.equal(timezoneLabelKey(undefined), "time.timezone.utc");
21
- assert.deepEqual(TIMEZONE[0], {
22
- key: 1,
23
- value: "UTC",
24
- i18nKey: "time.timezone.utc",
25
- });
26
- assert.equal(TIMEZONE[2]?.value, "Asia/Singapore");
27
- assert.equal(TIMEZONE_CURRENT_UTC_OFFSET.UTC, "UTC+00:00");
28
- assert.equal(TIMEZONE_CURRENT_UTC_OFFSET["Asia/Kuala_Lumpur"], "UTC+08:00");
29
- assert.equal(TIMEZONE_TO_UTC, TIMEZONE_CURRENT_UTC_OFFSET);
30
- const utcNineAm = Date.UTC(2024, 0, 1, 9, 0, 0);
31
- const klNineAm = Date.UTC(2024, 0, 1, 1, 0, 0);
32
- assert.equal(convertTimestampToTimezone(utcNineAm, "UTC", "Asia/Kuala_Lumpur"), Date.UTC(2024, 0, 1, 1, 0, 0));
33
- assert.equal(convertTimestampToTimezone(klNineAm, "Asia/Kuala_Lumpur", "America/New_York"), Date.UTC(2024, 0, 1, 14, 0, 0));
34
- assert.equal(convertTimestampToTimezone(utcNineAm, "unknown", "Asia/Kuala_Lumpur"), undefined);
35
- assert.equal(convertTimestampToTimezone(utcNineAm, "UTC", "unknown"), undefined);
@@ -1,17 +0,0 @@
1
- export declare const ORIGIN: readonly [{
2
- readonly key: 0;
3
- readonly value: "Website";
4
- readonly i18nKey: "track.origin.0";
5
- }, {
6
- readonly key: 1;
7
- readonly value: "Linkedin";
8
- readonly i18nKey: "track.origin.1";
9
- }, {
10
- readonly key: 2;
11
- readonly value: "Jobstreet";
12
- readonly i18nKey: "track.origin.2";
13
- }, {
14
- readonly key: 3;
15
- readonly value: "Maukerja";
16
- readonly i18nKey: "track.origin.3";
17
- }];
@@ -1,14 +0,0 @@
1
- export const ORIGIN = [
2
- {
3
- key: 0,
4
- value: "Website",
5
- i18nKey: "track.origin.0",
6
- },
7
- {
8
- key: 1,
9
- value: "Linkedin",
10
- i18nKey: "track.origin.1",
11
- },
12
- { key: 2, value: "Jobstreet", i18nKey: "track.origin.2" },
13
- { key: 3, value: "Maukerja", i18nKey: "track.origin.3" },
14
- ];
@@ -1 +0,0 @@
1
- export {};
@@ -1,7 +0,0 @@
1
- import assert from "node:assert/strict";
2
- import { ORIGIN } from "./index.js";
3
- assert.deepEqual(ORIGIN[0], {
4
- key: 0,
5
- value: "Website",
6
- i18nKey: "track.origin.0",
7
- });
@@ -1,6 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "outDir": "./dist",
4
- "declaration": true
5
- }
6
- }
@@ -1,8 +0,0 @@
1
- export declare const URL_PREFIXES: {
2
- 1: {
3
- contact: string;
4
- careerDetail: string;
5
- careerApply: string;
6
- };
7
- 2: {};
8
- };
@@ -1,9 +0,0 @@
1
- import { Website } from "../website/index.js";
2
- export const URL_PREFIXES = {
3
- [Website.KORRE]: {
4
- contact: "https://www.korre.site/contact",
5
- careerDetail: "https://www.korre.site/career/[id]",
6
- careerApply: "https://www.korre.site/career/[id]/apply",
7
- },
8
- [Website.KORRE_LABS]: {},
9
- };
@@ -1,16 +0,0 @@
1
- export declare enum Website {
2
- KORRE = 1,
3
- KORRE_LABS = 2
4
- }
5
- export declare const WEBSITES: {
6
- 1: {
7
- id: Website;
8
- name: string;
9
- url: string;
10
- };
11
- 2: {
12
- id: Website;
13
- name: string;
14
- url: string;
15
- };
16
- };
@@ -1,17 +0,0 @@
1
- export var Website;
2
- (function (Website) {
3
- Website[Website["KORRE"] = 1] = "KORRE";
4
- Website[Website["KORRE_LABS"] = 2] = "KORRE_LABS";
5
- })(Website || (Website = {}));
6
- export const WEBSITES = {
7
- [Website.KORRE]: {
8
- id: Website.KORRE,
9
- name: "Korre Evolution",
10
- url: "https://public.korre.site/images/korre-evo.png",
11
- },
12
- [Website.KORRE_LABS]: {
13
- id: Website.KORRE_LABS,
14
- name: "Korre Labs",
15
- url: "https://public.korre.site/images/korre-labs.png",
16
- },
17
- };