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 +114 -0
- package/dist/{validation-C9UAYKke.d.cts → index-DEmVFs0E.d.ts} +20 -9
- package/dist/{validation-DIvAzYjG.d.ts → index-DOEos-hV.d.cts} +20 -9
- package/dist/index.cjs +1173 -815
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +394 -250
- package/dist/index.d.ts +394 -250
- package/dist/index.js +1152 -803
- package/dist/index.js.map +1 -1
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +736 -2
- package/dist/types.d.ts +736 -2
- package/dist/types.js.map +1 -1
- package/dist/utils.cjs +17 -34
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +1 -8
- package/dist/utils.d.ts +1 -8
- package/dist/utils.js +18 -34
- package/dist/utils.js.map +1 -1
- package/package.json +2 -10
- package/dist/config-B7Oy_bdX.d.cts +0 -13
- package/dist/config-B7Oy_bdX.d.ts +0 -13
- package/dist/stores.cjs +0 -2165
- package/dist/stores.cjs.map +0 -1
- package/dist/stores.d.cts +0 -214
- package/dist/stores.d.ts +0 -214
- package/dist/stores.js +0 -2128
- package/dist/stores.js.map +0 -1
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 {
|
|
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
|
-
|
|
119
|
+
error: string;
|
|
108
120
|
}[];
|
|
109
121
|
};
|
|
110
122
|
type ValidationError = {
|
|
111
123
|
field: string;
|
|
112
|
-
|
|
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 {
|
|
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 {
|
|
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
|
-
|
|
119
|
+
error: string;
|
|
108
120
|
}[];
|
|
109
121
|
};
|
|
110
122
|
type ValidationError = {
|
|
111
123
|
field: string;
|
|
112
|
-
|
|
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 {
|
|
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 };
|