@absolutejs/commerce 0.1.1-beta.0 → 0.2.0-beta.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/client/cartStore.d.ts +11 -0
- package/dist/client/index.d.ts +1 -0
- package/dist/client/index.js +36 -0
- package/dist/core/orders.d.ts +4 -0
- package/dist/drizzle/index.d.ts +2062 -0
- package/dist/drizzle/index.js +88 -0
- package/dist/index.js +3 -0
- package/package.json +20 -2
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type CartStore<T> = {
|
|
2
|
+
read(): T[];
|
|
3
|
+
write(items: T[]): void;
|
|
4
|
+
add(item: T): void;
|
|
5
|
+
clear(): void;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Create a cart store for a localStorage key. Pass `normalize` to migrate or
|
|
9
|
+
* validate persisted items on read (e.g. drop legacy shapes, re-price).
|
|
10
|
+
*/
|
|
11
|
+
export declare const createCartStore: <T>(key: string, normalize?: (raw: unknown) => T[]) => CartStore<T>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './cartStore';
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// src/client/cartStore.ts
|
|
2
|
+
var createCartStore = (key, normalize) => {
|
|
3
|
+
const read = () => {
|
|
4
|
+
if (typeof window === "undefined")
|
|
5
|
+
return [];
|
|
6
|
+
try {
|
|
7
|
+
const raw = window.localStorage.getItem(key);
|
|
8
|
+
const parsed = raw ? JSON.parse(raw) : [];
|
|
9
|
+
if (normalize)
|
|
10
|
+
return normalize(parsed);
|
|
11
|
+
return Array.isArray(parsed) ? parsed : [];
|
|
12
|
+
} catch {
|
|
13
|
+
return [];
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
const write = (items) => {
|
|
17
|
+
if (typeof window === "undefined")
|
|
18
|
+
return;
|
|
19
|
+
window.localStorage.setItem(key, JSON.stringify(items));
|
|
20
|
+
};
|
|
21
|
+
return {
|
|
22
|
+
add(item) {
|
|
23
|
+
write([...read(), item]);
|
|
24
|
+
},
|
|
25
|
+
clear() {
|
|
26
|
+
if (typeof window === "undefined")
|
|
27
|
+
return;
|
|
28
|
+
window.localStorage.removeItem(key);
|
|
29
|
+
},
|
|
30
|
+
read,
|
|
31
|
+
write
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
export {
|
|
35
|
+
createCartStore
|
|
36
|
+
};
|
package/dist/core/orders.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
export type OrderStatus = 'paid' | 'shipped' | 'rejected' | 'failed' | 'refunded';
|
|
2
|
+
export type QuoteStatus = 'new' | 'priced' | 'won' | 'lost';
|
|
3
|
+
export type ProofStatus = 'none' | 'sent' | 'approved' | 'changes';
|
|
4
|
+
/** Deposit owed (minor units) for a total at a given percent (0 if percent≤0). */
|
|
5
|
+
export declare const depositCents: (totalCents: number, percent: number) => number;
|
|
2
6
|
export declare const PRODUCTION_STAGES: readonly ["queued", "digitizing", "production", "ready"];
|
|
3
7
|
export type ProductionStage = (typeof PRODUCTION_STAGES)[number];
|
|
4
8
|
/** Normalize an unknown stage to a valid one (defaults to the first). */
|