arky-sdk 0.2.0 → 0.3.1

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/README.md ADDED
@@ -0,0 +1,114 @@
1
+ # @arky/sdk
2
+
3
+ Official TypeScript SDK for Arky - All-in-one business platform
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @arky/sdk
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ### API Client (No State)
14
+
15
+ ```typescript
16
+ import { initArky } from '@arky/sdk'
17
+
18
+ initArky({
19
+ apiUrl: 'https://api.arky.io',
20
+ businessId: 'your-business-id',
21
+ storageUrl: 'https://storage.arky.io'
22
+ })
23
+
24
+ // Now use the API
25
+ import { cmsApi } from '@arky/sdk'
26
+
27
+ const { getCollection } = cmsApi();
28
+ const collection = await getCollection('website');
29
+ ```
30
+
31
+ ### With Reactive Stores
32
+
33
+ ```typescript
34
+ import { initArky } from '@arky/sdk/stores'
35
+ import { cartItems, eshopActions } from '@arky/sdk/stores'
36
+
37
+ initArky({
38
+ apiUrl: 'https://api.arky.io',
39
+ businessId: 'your-business-id'
40
+ })
41
+
42
+ // Use stores (framework-agnostic)
43
+ cartItems.subscribe(items => console.log('Cart:', items))
44
+ await eshopActions.addToCart({ productId: 'x', variantId: 'y', quantity: 1 })
45
+ ```
46
+
47
+ ## Framework Integration
48
+
49
+ ### Svelte (No adapter needed!)
50
+
51
+ ```svelte
52
+ <script>
53
+ import { cartItems, eshopActions } from '@arky/sdk/stores'
54
+ </script>
55
+
56
+ <button on:click={() => eshopActions.addToCart(...)}>
57
+ Cart ({$cartItems.length})
58
+ </button>
59
+ ```
60
+
61
+ ### React
62
+
63
+ ```bash
64
+ npm install @nanostores/react
65
+ ```
66
+
67
+ ```typescript
68
+ import { useStore } from '@nanostores/react'
69
+ import { cartItems } from '@arky/sdk/stores'
70
+
71
+ function Cart() {
72
+ const items = useStore(cartItems)
73
+ return <div>Cart ({items.length})</div>
74
+ }
75
+ ```
76
+
77
+ ### Vue
78
+
79
+ ```bash
80
+ npm install @nanostores/vue
81
+ ```
82
+
83
+ ```vue
84
+ <script setup>
85
+ import { useStore } from '@nanostores/vue'
86
+ import { cartItems } from '@arky/sdk/stores'
87
+
88
+ const items = useStore(cartItems)
89
+ </script>
90
+
91
+ <template>
92
+ <div>Cart ({{ items.length }})</div>
93
+ </template>
94
+ ```
95
+
96
+ ## Features
97
+
98
+ - 🚀 TypeScript-first
99
+ - 🎯 Framework-agnostic
100
+ - 📦 Tree-shakeable
101
+ - 🔄 Optional reactive stores (nanostores)
102
+ - ⚡ Tiny bundle size
103
+
104
+ ## Modules
105
+
106
+ - **CMS** - Headless content management
107
+ - **E-shop** - E-commerce & orders
108
+ - **Reservations** - Booking system
109
+ - **Newsletter** - Email campaigns
110
+ - **Analytics** - Business insights
111
+
112
+ ## License
113
+
114
+ MIT
@@ -1,4 +1,4 @@
1
- import { Payment, Price } from './types.cjs';
1
+ import { Price, Payment } from './types.js';
2
2
 
3
3
  interface Block {
4
4
  id: string;
@@ -25,11 +25,24 @@ declare const getBlockValue: (entry: any, blockKey: string) => any;
25
25
  declare const getBlockValues: (entry: any, blockKey: string) => any;
26
26
  declare const getBlockObjectValues: (entry: any, blockKey: string, locale?: string) => any;
27
27
  declare const getBlockFromArray: (entry: any, blockKey: string, locale?: string) => any;
28
- declare const getImageUrl: (imageBlock: any, isBlock?: boolean) => any;
28
+ declare const getImageUrl: (imageBlock: any, isBlock?: boolean, storageUrl?: string) => any;
29
29
  declare function getGalleryThumbnail(gallery: any): any;
30
- declare function thumbnailUrl(service: any): string;
30
+ declare function thumbnailUrl(service: any, storageUrl?: string): string;
31
31
  declare const translateMap: (labels: any, lang: string, fallback?: string) => any;
32
32
 
33
+ /**
34
+ * Maps currency codes to their display symbols
35
+ */
36
+ declare function getCurrencySymbol(currency: string): string;
37
+ /**
38
+ * List of currencies where the symbol appears after the amount
39
+ */
40
+ declare const SYMBOL_AFTER_CURRENCIES: string[];
41
+ /**
42
+ * Check if currency symbol should be placed after the amount
43
+ */
44
+ declare function isSymbolAfterCurrency(currency: string): boolean;
45
+
33
46
  declare const ERROR_CODES: {
34
47
  "GENERAL.001": string;
35
48
  "GENERAL.002": string;
@@ -98,18 +111,17 @@ declare const ERROR_CONSTANTS: {
98
111
  };
99
112
  };
100
113
  type ServerError = {
114
+ message: string;
101
115
  error: string;
102
- reason: string;
103
- code: string;
104
116
  statusCode: number;
105
117
  validationErrors: {
106
118
  field: string;
107
- code: string;
119
+ error: string;
108
120
  }[];
109
121
  };
110
122
  type ValidationError = {
111
123
  field: string;
112
- message: string;
124
+ error: string;
113
125
  };
114
126
  type RequestError = {
115
127
  validationErrors: ValidationError[];
@@ -152,7 +164,6 @@ declare const errors: {
152
164
 
153
165
  declare function convertToMajor(minorAmount: number): number;
154
166
  declare function convertToMinor(majorAmount: number): number;
155
- declare function getSymbol(currency: string): string;
156
167
  declare function getCurrencyFromMarket(marketId: string): string;
157
168
  declare function formatCurrencyAmount(amount: number, currency: string, options?: {
158
169
  showSymbols?: boolean;
@@ -242,4 +253,4 @@ declare function validateEmail(email: string): ValidationResult;
242
253
  declare function validateVerificationCode(code: string): ValidationResult;
243
254
  declare function validateRequired(value: any, fieldName?: string): ValidationResult;
244
255
 
245
- export { getBlockObjectValues as A, getBlockFromArray as B, type Collection as C, getGalleryThumbnail as D, ERROR_CODES as E, translateMap as F, transformErrors as G, convertServerErrorToRequestError as H, errors as I, convertToMajor as J, convertToMinor as K, getSymbol as L, getCurrencyFromMarket as M, formatCurrencyAmount as N, formatMinor as O, formatPayment as P, getMarketPrice as Q, type RequestError as R, type ServerError as S, getPriceAmount as T, createPaymentForCheckout as U, type ValidationError as V, type ValidationResult as W, type Block as X, validateEmail as a, validateVerificationCode as b, validateRequired as c, getBlockTextValue as d, getBlockValue as e, getBlockValues as f, getBlockLabel as g, getImageUrl as h, fetchSvgContent as i, getSvgContentForAstro as j, injectSvgIntoElement as k, humanize as l, categorify as m, formatDate as n, findTimeZone as o, tzGroups as p, getErrorMessage as q, isErrorCode as r, slugify as s, thumbnailUrl as t, ERROR_CONSTANTS as u, validatePhoneNumber as v, type CollectionEntry as w, formatBlockValue as x, prepareBlocksForSubmission as y, extractBlockValues as z };
256
+ export { isErrorCode as A, transformErrors as B, type Collection as C, convertServerErrorToRequestError as D, ERROR_CODES as E, errors as F, convertToMajor as G, convertToMinor as H, getCurrencyFromMarket as I, formatCurrencyAmount as J, fetchSvgContent as K, getSvgContentForAstro as L, injectSvgIntoElement as M, slugify as N, humanize as O, categorify as P, formatDate as Q, type RequestError as R, SYMBOL_AFTER_CURRENCIES as S, tzGroups as T, type ValidationResult as U, type ValidationError as V, validateEmail as W, validateVerificationCode as X, validateRequired as Y, type Block as Z, getMarketPrice as a, getPriceAmount as b, formatMinor as c, createPaymentForCheckout as d, getCurrencySymbol as e, formatPayment as f, getGalleryThumbnail as g, findTimeZone as h, type CollectionEntry as i, getBlockLabel as j, formatBlockValue as k, extractBlockValues as l, getBlockTextValue as m, getBlockValue as n, getBlockValues as o, prepareBlocksForSubmission as p, getBlockObjectValues as q, getBlockFromArray as r, getImageUrl as s, thumbnailUrl as t, translateMap as u, validatePhoneNumber as v, isSymbolAfterCurrency as w, ERROR_CONSTANTS as x, type ServerError as y, getErrorMessage as z };
@@ -1,4 +1,4 @@
1
- import { Payment, Price } from './types.js';
1
+ import { Price, Payment } from './types.cjs';
2
2
 
3
3
  interface Block {
4
4
  id: string;
@@ -25,11 +25,24 @@ declare const getBlockValue: (entry: any, blockKey: string) => any;
25
25
  declare const getBlockValues: (entry: any, blockKey: string) => any;
26
26
  declare const getBlockObjectValues: (entry: any, blockKey: string, locale?: string) => any;
27
27
  declare const getBlockFromArray: (entry: any, blockKey: string, locale?: string) => any;
28
- declare const getImageUrl: (imageBlock: any, isBlock?: boolean) => any;
28
+ declare const getImageUrl: (imageBlock: any, isBlock?: boolean, storageUrl?: string) => any;
29
29
  declare function getGalleryThumbnail(gallery: any): any;
30
- declare function thumbnailUrl(service: any): string;
30
+ declare function thumbnailUrl(service: any, storageUrl?: string): string;
31
31
  declare const translateMap: (labels: any, lang: string, fallback?: string) => any;
32
32
 
33
+ /**
34
+ * Maps currency codes to their display symbols
35
+ */
36
+ declare function getCurrencySymbol(currency: string): string;
37
+ /**
38
+ * List of currencies where the symbol appears after the amount
39
+ */
40
+ declare const SYMBOL_AFTER_CURRENCIES: string[];
41
+ /**
42
+ * Check if currency symbol should be placed after the amount
43
+ */
44
+ declare function isSymbolAfterCurrency(currency: string): boolean;
45
+
33
46
  declare const ERROR_CODES: {
34
47
  "GENERAL.001": string;
35
48
  "GENERAL.002": string;
@@ -98,18 +111,17 @@ declare const ERROR_CONSTANTS: {
98
111
  };
99
112
  };
100
113
  type ServerError = {
114
+ message: string;
101
115
  error: string;
102
- reason: string;
103
- code: string;
104
116
  statusCode: number;
105
117
  validationErrors: {
106
118
  field: string;
107
- code: string;
119
+ error: string;
108
120
  }[];
109
121
  };
110
122
  type ValidationError = {
111
123
  field: string;
112
- message: string;
124
+ error: string;
113
125
  };
114
126
  type RequestError = {
115
127
  validationErrors: ValidationError[];
@@ -152,7 +164,6 @@ declare const errors: {
152
164
 
153
165
  declare function convertToMajor(minorAmount: number): number;
154
166
  declare function convertToMinor(majorAmount: number): number;
155
- declare function getSymbol(currency: string): string;
156
167
  declare function getCurrencyFromMarket(marketId: string): string;
157
168
  declare function formatCurrencyAmount(amount: number, currency: string, options?: {
158
169
  showSymbols?: boolean;
@@ -242,4 +253,4 @@ declare function validateEmail(email: string): ValidationResult;
242
253
  declare function validateVerificationCode(code: string): ValidationResult;
243
254
  declare function validateRequired(value: any, fieldName?: string): ValidationResult;
244
255
 
245
- export { getBlockObjectValues as A, getBlockFromArray as B, type Collection as C, getGalleryThumbnail as D, ERROR_CODES as E, translateMap as F, transformErrors as G, convertServerErrorToRequestError as H, errors as I, convertToMajor as J, convertToMinor as K, getSymbol as L, getCurrencyFromMarket as M, formatCurrencyAmount as N, formatMinor as O, formatPayment as P, getMarketPrice as Q, type RequestError as R, type ServerError as S, getPriceAmount as T, createPaymentForCheckout as U, type ValidationError as V, type ValidationResult as W, type Block as X, validateEmail as a, validateVerificationCode as b, validateRequired as c, getBlockTextValue as d, getBlockValue as e, getBlockValues as f, getBlockLabel as g, getImageUrl as h, fetchSvgContent as i, getSvgContentForAstro as j, injectSvgIntoElement as k, humanize as l, categorify as m, formatDate as n, findTimeZone as o, tzGroups as p, getErrorMessage as q, isErrorCode as r, slugify as s, thumbnailUrl as t, ERROR_CONSTANTS as u, validatePhoneNumber as v, type CollectionEntry as w, formatBlockValue as x, prepareBlocksForSubmission as y, extractBlockValues as z };
256
+ export { isErrorCode as A, transformErrors as B, type Collection as C, convertServerErrorToRequestError as D, ERROR_CODES as E, errors as F, convertToMajor as G, convertToMinor as H, getCurrencyFromMarket as I, formatCurrencyAmount as J, fetchSvgContent as K, getSvgContentForAstro as L, injectSvgIntoElement as M, slugify as N, humanize as O, categorify as P, formatDate as Q, type RequestError as R, SYMBOL_AFTER_CURRENCIES as S, tzGroups as T, type ValidationResult as U, type ValidationError as V, validateEmail as W, validateVerificationCode as X, validateRequired as Y, type Block as Z, getMarketPrice as a, getPriceAmount as b, formatMinor as c, createPaymentForCheckout as d, getCurrencySymbol as e, formatPayment as f, getGalleryThumbnail as g, findTimeZone as h, type CollectionEntry as i, getBlockLabel as j, formatBlockValue as k, extractBlockValues as l, getBlockTextValue as m, getBlockValue as n, getBlockValues as o, prepareBlocksForSubmission as p, getBlockObjectValues as q, getBlockFromArray as r, getImageUrl as s, thumbnailUrl as t, translateMap as u, validatePhoneNumber as v, isSymbolAfterCurrency as w, ERROR_CONSTANTS as x, type ServerError as y, getErrorMessage as z };