arky-sdk 0.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.
Files changed (79) hide show
  1. package/dist/api/cms.d.ts +19 -0
  2. package/dist/api/cms.d.ts.map +1 -0
  3. package/dist/api/cms.js +41 -0
  4. package/dist/api/eshop.d.ts +89 -0
  5. package/dist/api/eshop.d.ts.map +1 -0
  6. package/dist/api/eshop.js +183 -0
  7. package/dist/api/index.d.ts +6 -0
  8. package/dist/api/index.d.ts.map +1 -0
  9. package/dist/api/index.js +5 -0
  10. package/dist/api/newsletter.d.ts +32 -0
  11. package/dist/api/newsletter.d.ts.map +1 -0
  12. package/dist/api/newsletter.js +70 -0
  13. package/dist/api/reservation.d.ts +84 -0
  14. package/dist/api/reservation.d.ts.map +1 -0
  15. package/dist/api/reservation.js +239 -0
  16. package/dist/config.d.ts +15 -0
  17. package/dist/config.d.ts.map +1 -0
  18. package/dist/config.js +20 -0
  19. package/dist/index.d.ts +26 -0
  20. package/dist/index.d.ts.map +1 -0
  21. package/dist/index.js +57 -0
  22. package/dist/services/auth.d.ts +17 -0
  23. package/dist/services/auth.d.ts.map +1 -0
  24. package/dist/services/auth.js +62 -0
  25. package/dist/services/http.d.ts +20 -0
  26. package/dist/services/http.d.ts.map +1 -0
  27. package/dist/services/http.js +73 -0
  28. package/dist/stores/business.d.ts +28 -0
  29. package/dist/stores/business.d.ts.map +1 -0
  30. package/dist/stores/business.js +122 -0
  31. package/dist/stores/cart.d.ts +8 -0
  32. package/dist/stores/cart.d.ts.map +1 -0
  33. package/dist/stores/cart.js +20 -0
  34. package/dist/stores/eshop.d.ts +121 -0
  35. package/dist/stores/eshop.d.ts.map +1 -0
  36. package/dist/stores/eshop.js +377 -0
  37. package/dist/stores/index.d.ts +7 -0
  38. package/dist/stores/index.d.ts.map +1 -0
  39. package/dist/stores/index.js +19 -0
  40. package/dist/stores/reservation.d.ts +237 -0
  41. package/dist/stores/reservation.d.ts.map +1 -0
  42. package/dist/stores/reservation.js +853 -0
  43. package/dist/types/index.d.ts +244 -0
  44. package/dist/types/index.d.ts.map +1 -0
  45. package/dist/types/index.js +8 -0
  46. package/dist/utils/blocks.d.ts +30 -0
  47. package/dist/utils/blocks.d.ts.map +1 -0
  48. package/dist/utils/blocks.js +237 -0
  49. package/dist/utils/currency.d.ts +9 -0
  50. package/dist/utils/currency.d.ts.map +1 -0
  51. package/dist/utils/currency.js +99 -0
  52. package/dist/utils/errors.d.ts +121 -0
  53. package/dist/utils/errors.d.ts.map +1 -0
  54. package/dist/utils/errors.js +114 -0
  55. package/dist/utils/i18n.d.ts +5 -0
  56. package/dist/utils/i18n.d.ts.map +1 -0
  57. package/dist/utils/i18n.js +37 -0
  58. package/dist/utils/index.d.ts +9 -0
  59. package/dist/utils/index.d.ts.map +1 -0
  60. package/dist/utils/index.js +10 -0
  61. package/dist/utils/price.d.ts +33 -0
  62. package/dist/utils/price.d.ts.map +1 -0
  63. package/dist/utils/price.js +141 -0
  64. package/dist/utils/queryParams.d.ts +21 -0
  65. package/dist/utils/queryParams.d.ts.map +1 -0
  66. package/dist/utils/queryParams.js +47 -0
  67. package/dist/utils/svg.d.ts +17 -0
  68. package/dist/utils/svg.d.ts.map +1 -0
  69. package/dist/utils/svg.js +62 -0
  70. package/dist/utils/text.d.ts +26 -0
  71. package/dist/utils/text.d.ts.map +1 -0
  72. package/dist/utils/text.js +64 -0
  73. package/dist/utils/timezone.d.ts +9 -0
  74. package/dist/utils/timezone.d.ts.map +1 -0
  75. package/dist/utils/timezone.js +49 -0
  76. package/dist/utils/validation.d.ts +9 -0
  77. package/dist/utils/validation.d.ts.map +1 -0
  78. package/dist/utils/validation.js +44 -0
  79. package/package.json +58 -0
@@ -0,0 +1,26 @@
1
+ declare const locales: readonly ["en", "sr-latn"];
2
+ /**
3
+ * * returns "slugified" text.
4
+ * @param text: string - text to slugify
5
+ */
6
+ export declare function slugify(text: string): string;
7
+ /**
8
+ * * returns "humanized" text. runs slugify() and then replaces - with space and upper case first letter of every word, and lower case the rest
9
+ * @param text: string - text to humanize
10
+ */
11
+ export declare function humanize(text: string): string;
12
+ /**
13
+ * * returns "categorified" text. runs slugify() and then replaces - with space and upper cases everything
14
+ * @param text: string - text to categorify
15
+ * @returns string - categorified text
16
+ */
17
+ export declare function categorify(text: string): string;
18
+ /**
19
+ * * returns a nicely formatted string of the date passed
20
+ * @param date: string | number | Date - date to format
21
+ * @param locale: string - locale to format the date in
22
+ * @returns string - formatted date
23
+ */
24
+ export declare function formatDate(date: string | number | Date, locale: (typeof locales)[number]): string;
25
+ export {};
26
+ //# sourceMappingURL=text.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../src/utils/text.ts"],"names":[],"mappings":"AACA,QAAA,MAAM,OAAO,4BAA6B,CAAC;AAM3C;;;GAGG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAS5C;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAY7C;AAGD;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAK/C;AAGD;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,EAAE,MAAM,EAAE,CAAC,OAAO,OAAO,CAAC,CAAC,MAAM,CAAC,GAAG,MAAM,CAajG"}
@@ -0,0 +1,64 @@
1
+ // Define locales inline since we don't have @lib/i18n in SDK
2
+ const locales = ['en', 'sr-latn'];
3
+ const localeMap = {
4
+ 'en': 'en-US',
5
+ 'sr-latn': 'sr-RS'
6
+ };
7
+ /**
8
+ * * returns "slugified" text.
9
+ * @param text: string - text to slugify
10
+ */
11
+ export function slugify(text) {
12
+ return text
13
+ .toString()
14
+ .toLowerCase() // convert to lowercase
15
+ .replace(/\s+/g, "-") // replace spaces with -
16
+ .replace(/[^\w-]+/g, "") // remove all non-word chars
17
+ .replace(/--+/g, "-") // replace multiple dashes with single dash
18
+ .replace(/^-+/, "") // trim dash from start of text
19
+ .replace(/-+$/, ""); // trim dash from end of text
20
+ }
21
+ /**
22
+ * * returns "humanized" text. runs slugify() and then replaces - with space and upper case first letter of every word, and lower case the rest
23
+ * @param text: string - text to humanize
24
+ */
25
+ export function humanize(text) {
26
+ const slugifiedText = slugify(text);
27
+ return (slugifiedText
28
+ .replace(/-/g, " ") // replace "-" with space
29
+ // .toLowerCase();
30
+ .replace(
31
+ // upper case first letter of every word, and lower case the rest
32
+ /\w\S*/g, (w) => w.charAt(0).toUpperCase() + w.slice(1).toLowerCase()));
33
+ }
34
+ // --------------------------------------------------------
35
+ /**
36
+ * * returns "categorified" text. runs slugify() and then replaces - with space and upper cases everything
37
+ * @param text: string - text to categorify
38
+ * @returns string - categorified text
39
+ */
40
+ export function categorify(text) {
41
+ const slugifiedText = slugify(text);
42
+ return slugifiedText
43
+ .replace(/-/g, " ") // replace "-" with space
44
+ .toUpperCase();
45
+ }
46
+ // --------------------------------------------------------
47
+ /**
48
+ * * returns a nicely formatted string of the date passed
49
+ * @param date: string | number | Date - date to format
50
+ * @param locale: string - locale to format the date in
51
+ * @returns string - formatted date
52
+ */
53
+ export function formatDate(date, locale) {
54
+ let localeString = "en-US";
55
+ if (locales.includes(locale)) {
56
+ localeString = localeMap[locale];
57
+ }
58
+ return new Date(date).toLocaleDateString(localeString, {
59
+ timeZone: "UTC",
60
+ year: "numeric",
61
+ month: "short",
62
+ day: "numeric",
63
+ });
64
+ }
@@ -0,0 +1,9 @@
1
+ export declare const tzGroups: {
2
+ label: string;
3
+ zones: {
4
+ label: string;
5
+ value: string;
6
+ }[];
7
+ }[];
8
+ export declare function findTimeZone(groups: typeof tzGroups): string;
9
+ //# sourceMappingURL=timezone.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"timezone.d.ts","sourceRoot":"","sources":["../../src/utils/timezone.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,QAAQ;;;;;;GA4BpB,CAAC;AAEF,wBAAgB,YAAY,CAAC,MAAM,EAAE,OAAO,QAAQ,GAAG,MAAM,CAmB5D"}
@@ -0,0 +1,49 @@
1
+ // Timezone utilities (moved from Reservation folder)
2
+ export const tzGroups = [
3
+ {
4
+ label: "US",
5
+ zones: [
6
+ { label: "Eastern Time", value: "America/New_York" },
7
+ { label: "Central Time", value: "America/Chicago" },
8
+ { label: "Mountain Time", value: "America/Denver" },
9
+ { label: "Pacific Time", value: "America/Los_Angeles" },
10
+ ],
11
+ },
12
+ {
13
+ label: "Europe",
14
+ zones: [
15
+ { label: "London", value: "Europe/London" },
16
+ { label: "Paris", value: "Europe/Paris" },
17
+ { label: "Berlin", value: "Europe/Berlin" },
18
+ { label: "Rome", value: "Europe/Rome" },
19
+ ],
20
+ },
21
+ {
22
+ label: "Asia",
23
+ zones: [
24
+ { label: "Tokyo", value: "Asia/Tokyo" },
25
+ { label: "Shanghai", value: "Asia/Shanghai" },
26
+ { label: "Mumbai", value: "Asia/Kolkata" },
27
+ { label: "Dubai", value: "Asia/Dubai" },
28
+ ],
29
+ },
30
+ ];
31
+ export function findTimeZone(groups) {
32
+ try {
33
+ const detected = Intl.DateTimeFormat().resolvedOptions().timeZone;
34
+ // Check if detected timezone is in our list
35
+ for (const group of groups) {
36
+ for (const zone of group.zones) {
37
+ if (zone.value === detected) {
38
+ return detected;
39
+ }
40
+ }
41
+ }
42
+ // Fallback to UTC if not found
43
+ return "UTC";
44
+ }
45
+ catch (e) {
46
+ // Fallback to UTC if detection fails
47
+ return "UTC";
48
+ }
49
+ }
@@ -0,0 +1,9 @@
1
+ export interface ValidationResult {
2
+ isValid: boolean;
3
+ error?: string;
4
+ }
5
+ export declare function validatePhoneNumber(phone: string): ValidationResult;
6
+ export declare function validateEmail(email: string): ValidationResult;
7
+ export declare function validateVerificationCode(code: string): ValidationResult;
8
+ export declare function validateRequired(value: any, fieldName?: string): ValidationResult;
9
+ //# sourceMappingURL=validation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../src/utils/validation.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,gBAAgB;IAC7B,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB;AAGD,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,gBAAgB,CAgBnE;AAGD,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,gBAAgB,CAY7D;AAGD,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,GAAG,gBAAgB,CAYvE;AAGD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,GAAG,EAAE,SAAS,GAAE,MAAqB,GAAG,gBAAgB,CAM/F"}
@@ -0,0 +1,44 @@
1
+ // Validation utilities
2
+ // Phone number validation
3
+ export function validatePhoneNumber(phone) {
4
+ if (!phone) {
5
+ return { isValid: false, error: 'Phone number is required' };
6
+ }
7
+ const cleaned = phone.replace(/\D/g, '');
8
+ if (cleaned.length < 8) {
9
+ return { isValid: false, error: 'Phone number is too short' };
10
+ }
11
+ if (cleaned.length > 15) {
12
+ return { isValid: false, error: 'Phone number is too long' };
13
+ }
14
+ return { isValid: true };
15
+ }
16
+ // Email validation
17
+ export function validateEmail(email) {
18
+ if (!email) {
19
+ return { isValid: false, error: 'Email is required' };
20
+ }
21
+ const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
22
+ if (!emailRegex.test(email)) {
23
+ return { isValid: false, error: 'Please enter a valid email address' };
24
+ }
25
+ return { isValid: true };
26
+ }
27
+ // Verification code validation (4-digit codes)
28
+ export function validateVerificationCode(code) {
29
+ if (!code) {
30
+ return { isValid: false, error: 'Verification code is required' };
31
+ }
32
+ const cleaned = code.replace(/\D/g, '');
33
+ if (cleaned.length !== 4) {
34
+ return { isValid: false, error: 'Please enter a 4-digit verification code' };
35
+ }
36
+ return { isValid: true };
37
+ }
38
+ // Generic required field validation
39
+ export function validateRequired(value, fieldName = 'This field') {
40
+ if (value === null || value === undefined || value === '') {
41
+ return { isValid: false, error: `${fieldName} is required` };
42
+ }
43
+ return { isValid: true };
44
+ }
package/package.json ADDED
@@ -0,0 +1,58 @@
1
+ {
2
+ "name": "arky-sdk",
3
+ "version": "0.1.0",
4
+ "description": "Official TypeScript SDK for Arky - All-in-one business platform",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ },
13
+ "./stores": {
14
+ "types": "./dist/stores/index.d.ts",
15
+ "import": "./dist/stores/index.js"
16
+ },
17
+ "./utils": {
18
+ "types": "./dist/utils/index.d.ts",
19
+ "import": "./dist/utils/index.js"
20
+ },
21
+ "./types": {
22
+ "types": "./dist/types/index.d.ts",
23
+ "import": "./dist/types/index.js"
24
+ }
25
+ },
26
+ "files": [
27
+ "dist",
28
+ "README.md"
29
+ ],
30
+ "scripts": {
31
+ "build": "tsc",
32
+ "dev": "tsc --watch",
33
+ "clean": "rm -rf dist"
34
+ },
35
+ "keywords": [
36
+ "arky",
37
+ "sdk",
38
+ "cms",
39
+ "ecommerce",
40
+ "reservations",
41
+ "newsletter",
42
+ "analytics",
43
+ "typescript"
44
+ ],
45
+ "author": "0xDjole",
46
+ "license": "MIT",
47
+ "repository": {
48
+ "type": "git",
49
+ "url": "https://github.com/0xDjole/arky-sdk.git"
50
+ },
51
+ "dependencies": {
52
+ "@nanostores/persistent": "^1.0.0",
53
+ "nanostores": "^1.0.1"
54
+ },
55
+ "devDependencies": {
56
+ "typescript": "^5.8.3"
57
+ }
58
+ }