@fayz-ai/shop 0.9.0 → 0.10.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/README.md +18 -1
- package/dist/admin.d.ts +2 -0
- package/dist/admin.d.ts.map +1 -0
- package/dist/catalog.d.ts +1 -3
- package/dist/catalog.d.ts.map +1 -1
- package/dist/catalog.js +2 -2
- package/dist/chunk-3GERSY5F.js +526 -0
- package/dist/chunk-3GERSY5F.js.map +1 -0
- package/dist/chunk-FQPGE3YN.js +3 -0
- package/dist/{chunk-JR25TISO.js.map → chunk-FQPGE3YN.js.map} +1 -1
- package/dist/{chunk-CTKZ6O2J.js → chunk-IKNGCRUM.js} +41 -15
- package/dist/chunk-IKNGCRUM.js.map +1 -0
- package/dist/{chunk-IYQHKMLB.js → chunk-IL6GA4ER.js} +4 -4
- package/dist/chunk-IL6GA4ER.js.map +1 -0
- package/dist/chunk-KLDS7IPU.js +17 -0
- package/dist/chunk-KLDS7IPU.js.map +1 -0
- package/dist/chunk-RGTIJQJL.js +93 -0
- package/dist/chunk-RGTIJQJL.js.map +1 -0
- package/dist/{chunk-SVTCJ6HP.js → chunk-U3O2I3RM.js} +395 -27
- package/dist/chunk-U3O2I3RM.js.map +1 -0
- package/dist/chunk-XERLK5LD.js +1415 -0
- package/dist/chunk-XERLK5LD.js.map +1 -0
- package/dist/chunk-XOP6SHPB.js +142 -0
- package/dist/chunk-XOP6SHPB.js.map +1 -0
- package/dist/client.d.ts +2 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/{mock-catalog.d.ts → data/mock-catalog.d.ts} +21 -1
- package/dist/data/mock-catalog.d.ts.map +1 -0
- package/dist/data/mock-provider.d.ts +133 -0
- package/dist/data/mock-provider.d.ts.map +1 -0
- package/dist/data/mock.d.ts +3 -0
- package/dist/data/mock.d.ts.map +1 -0
- package/dist/data/provider.d.ts +142 -0
- package/dist/data/provider.d.ts.map +1 -0
- package/dist/data/supabase-provider.d.ts +100 -0
- package/dist/data/supabase-provider.d.ts.map +1 -0
- package/dist/data/tables.d.ts +35 -0
- package/dist/data/tables.d.ts.map +1 -0
- package/dist/data/tenant.d.ts.map +1 -0
- package/dist/entities/entity-reconcile.d.ts +32 -0
- package/dist/entities/entity-reconcile.d.ts.map +1 -0
- package/dist/entities/entity-sql.d.ts +50 -0
- package/dist/entities/entity-sql.d.ts.map +1 -0
- package/dist/entities/entity-store.d.ts +58 -0
- package/dist/entities/entity-store.d.ts.map +1 -0
- package/dist/entities/index.d.ts +11 -0
- package/dist/entities/index.d.ts.map +1 -0
- package/dist/entities/mock-entity-store.d.ts +17 -0
- package/dist/entities/mock-entity-store.d.ts.map +1 -0
- package/dist/entities/sidecar.d.ts +9 -0
- package/dist/entities/sidecar.d.ts.map +1 -0
- package/dist/entities/supabase-entity-store.d.ts +8 -0
- package/dist/entities/supabase-entity-store.d.ts.map +1 -0
- package/dist/entities.js +159 -0
- package/dist/entities.js.map +1 -0
- package/dist/index.d.ts +17 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +728 -41
- package/dist/index.js.map +1 -1
- package/dist/inventory/allocation.d.ts +98 -0
- package/dist/inventory/allocation.d.ts.map +1 -0
- package/dist/inventory/index.d.ts +13 -0
- package/dist/inventory/index.d.ts.map +1 -0
- package/dist/inventory/mock-stock-store.d.ts +89 -0
- package/dist/inventory/mock-stock-store.d.ts.map +1 -0
- package/dist/inventory/postgrest-double.d.ts +65 -0
- package/dist/inventory/postgrest-double.d.ts.map +1 -0
- package/dist/inventory/shopify-mapping.d.ts +67 -0
- package/dist/inventory/shopify-mapping.d.ts.map +1 -0
- package/dist/inventory/stock-contract.d.ts +46 -0
- package/dist/inventory/stock-contract.d.ts.map +1 -0
- package/dist/inventory/stock-store.d.ts +96 -0
- package/dist/inventory/stock-store.d.ts.map +1 -0
- package/dist/inventory/stock-types.d.ts +292 -0
- package/dist/inventory/stock-types.d.ts.map +1 -0
- package/dist/inventory/supabase-stock-store.d.ts +59 -0
- package/dist/inventory/supabase-stock-store.d.ts.map +1 -0
- package/dist/inventory/vocabulary.d.ts +86 -0
- package/dist/inventory/vocabulary.d.ts.map +1 -0
- package/dist/inventory.js +4 -0
- package/dist/inventory.js.map +1 -0
- package/dist/lib/catalog.d.ts +4 -0
- package/dist/lib/catalog.d.ts.map +1 -0
- package/dist/{commerce.d.ts → lib/commerce.d.ts} +2 -2
- package/dist/lib/commerce.d.ts.map +1 -0
- package/dist/lib/emails.d.ts +50 -0
- package/dist/lib/emails.d.ts.map +1 -0
- package/dist/lib/message-events.d.ts +4 -0
- package/dist/lib/message-events.d.ts.map +1 -0
- package/dist/lib/runtime.d.ts +5 -0
- package/dist/lib/runtime.d.ts.map +1 -0
- package/dist/mock.d.ts +1 -2
- package/dist/mock.d.ts.map +1 -1
- package/dist/mock.js +4 -2
- package/dist/provider.d.ts +1 -88
- package/dist/provider.d.ts.map +1 -1
- package/dist/rules/adapter.d.ts +36 -0
- package/dist/rules/adapter.d.ts.map +1 -0
- package/dist/rules/attributes.d.ts +64 -0
- package/dist/rules/attributes.d.ts.map +1 -0
- package/dist/rules/context.d.ts +43 -0
- package/dist/rules/context.d.ts.map +1 -0
- package/dist/rules/evaluator.d.ts +37 -0
- package/dist/rules/evaluator.d.ts.map +1 -0
- package/dist/rules/index.d.ts +13 -0
- package/dist/rules/index.d.ts.map +1 -0
- package/dist/rules/prices.d.ts +25 -0
- package/dist/rules/prices.d.ts.map +1 -0
- package/dist/rules/rule-types.d.ts +160 -0
- package/dist/rules/rule-types.d.ts.map +1 -0
- package/dist/rules.js +22 -0
- package/dist/rules.js.map +1 -0
- package/dist/runtime.d.ts +1 -4
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +5 -3
- package/dist/types.d.ts +231 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +26 -20
- package/dist/chunk-CTKZ6O2J.js.map +0 -1
- package/dist/chunk-IYQHKMLB.js.map +0 -1
- package/dist/chunk-JR25TISO.js +0 -3
- package/dist/chunk-SVTCJ6HP.js.map +0 -1
- package/dist/commerce.d.ts.map +0 -1
- package/dist/mock-catalog.d.ts.map +0 -1
- package/dist/mock-provider.d.ts +0 -60
- package/dist/mock-provider.d.ts.map +0 -1
- package/dist/supabase-provider.d.ts +0 -56
- package/dist/supabase-provider.d.ts.map +0 -1
- package/dist/tables.d.ts +0 -12
- package/dist/tables.d.ts.map +0 -1
- package/dist/tenant.d.ts.map +0 -1
- package/src/catalog.ts +0 -3
- package/src/commerce.ts +0 -120
- package/src/index.ts +0 -40
- package/src/mock-catalog.ts +0 -266
- package/src/mock-provider.ts +0 -480
- package/src/mock.ts +0 -2
- package/src/provider.ts +0 -117
- package/src/runtime.ts +0 -20
- package/src/supabase-provider.ts +0 -754
- package/src/tables.ts +0 -17
- package/src/tenant.ts +0 -21
- package/src/types.ts +0 -623
- /package/dist/{tenant.d.ts → data/tenant.d.ts} +0 -0
|
@@ -1,16 +1,26 @@
|
|
|
1
|
-
import type { Product, Category, Discount } from '
|
|
1
|
+
import type { Product, ProductVariantSet, Category, Discount } from '../types';
|
|
2
2
|
/** 600x600 gradient SVG with product initials — no network, e2e-stable. */
|
|
3
3
|
export declare function svgPlaceholder(label: string, hueA: number, hueB: number): string;
|
|
4
4
|
export declare const MOCK_CATEGORIES: Category[];
|
|
5
5
|
export declare const MOCK_PRODUCTS: Product[];
|
|
6
6
|
export declare const MOCK_DISCOUNTS: Discount[];
|
|
7
|
+
export declare const MOCK_VARIANTS: Record<string, ProductVariantSet>;
|
|
7
8
|
export interface CatalogCategoryInput {
|
|
8
9
|
name: string;
|
|
10
|
+
/** URL slug. Defaults to a slugified name — see CatalogProductInput.slug. */
|
|
11
|
+
slug?: string;
|
|
9
12
|
description?: string;
|
|
10
13
|
image?: string;
|
|
11
14
|
}
|
|
12
15
|
export interface CatalogProductInput {
|
|
13
16
|
name: string;
|
|
17
|
+
/**
|
|
18
|
+
* URL slug. Defaults to a slugified name, but a store with live URLs must pin
|
|
19
|
+
* it: the slug IS the product's address, so deriving it from the name means
|
|
20
|
+
* renaming a product silently breaks every link to it. `metadata.slug` is
|
|
21
|
+
* honoured too, for stores written that way before this field existed.
|
|
22
|
+
*/
|
|
23
|
+
slug?: string;
|
|
14
24
|
description: string;
|
|
15
25
|
price: number;
|
|
16
26
|
compareAtPrice?: number;
|
|
@@ -21,6 +31,16 @@ export interface CatalogProductInput {
|
|
|
21
31
|
hues?: [number, number];
|
|
22
32
|
weight?: number;
|
|
23
33
|
image?: string;
|
|
34
|
+
/**
|
|
35
|
+
* Full gallery, primary first. `image` stays as the single-shot shorthand;
|
|
36
|
+
* when both are set `images` wins, so a store can move to a real gallery
|
|
37
|
+
* without rewriting its catalog module.
|
|
38
|
+
*
|
|
39
|
+
* Without this a mock catalog could only ever describe one photo per
|
|
40
|
+
* product, which made the gallery's thumbnail strip and arrows unreachable
|
|
41
|
+
* for every store that had not migrated to a live backend yet.
|
|
42
|
+
*/
|
|
43
|
+
images?: readonly string[];
|
|
24
44
|
metadata?: Record<string, unknown>;
|
|
25
45
|
}
|
|
26
46
|
export interface CatalogInput {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mock-catalog.d.ts","sourceRoot":"","sources":["../../src/data/mock-catalog.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAgB,iBAAiB,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAW5F,2EAA2E;AAC3E,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAkBhF;AAcD,eAAO,MAAM,eAAe,EAAE,QAAQ,EAKrC,CAAA;AA8CD,eAAO,MAAM,aAAa,EAAE,OAAO,EAuBhC,CAAA;AAEH,eAAO,MAAM,cAAc,EAAE,QAAQ,EAsBpC,CAAA;AAgBD,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAqB3D,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,EAAE,CAAA;CAAE,CAmF5H"}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import type { ShopProvider } from './provider';
|
|
2
|
+
import type { Product, ProductImage, ProductVariantSet, Category, Order, ShopCustomer, Discount, ProductEnquiry, CreateProductInput, UpdateProductInput, ListProductsOptions, CreateProductEnquiryInput, ListProductEnquiriesOptions, CreateCategoryInput, UpdateCategoryInput, CreateOrderInput, UpdateOrderInput, ListOrdersOptions, PlaceOrderInput, CreateCustomerInput, UpdateCustomerInput, ListCustomersOptions, ResolveCustomerInput, CreateDiscountInput, UpdateDiscountInput, ListDiscountsOptions, SalesChannel, CreateSalesChannelInput, UpdateSalesChannelInput, Collection, CreateCollectionInput, UpdateCollectionInput, CustomerGroup, CreateCustomerGroupInput, UpdateCustomerGroupInput, CustomerSegment, CreateCustomerSegmentInput, UpdateCustomerSegmentInput, GiftCard, CreateGiftCardInput, UpdateGiftCardInput, EmailTemplate, UpsertEmailTemplateInput } from '../types';
|
|
3
|
+
import type { EntityRecord, EntityRecordInput, ListEntityRecordsOptions } from '../entities/entity-store';
|
|
4
|
+
import type { ComputeAction, Promotion, RuleCartSnapshot } from '../rules/rule-types';
|
|
5
|
+
export interface MockShopSeed {
|
|
6
|
+
products?: Product[];
|
|
7
|
+
categories?: Category[];
|
|
8
|
+
discounts?: Discount[];
|
|
9
|
+
/** Option axes + variants per product id (spine M5, mirrors 0028). Absent
|
|
10
|
+
* with the default catalog → the MOCK_VARIANTS fixtures; absent with a
|
|
11
|
+
* custom product seed → no variants (a store's own catalog stays as
|
|
12
|
+
* declared). */
|
|
13
|
+
variants?: Record<string, ProductVariantSet>;
|
|
14
|
+
/** Rule-engine promotions (spine M6) — the serializable Promotion shape the
|
|
15
|
+
* Store Document's `promotions` section carries. Evaluated by
|
|
16
|
+
* evaluatePromotions alongside the legacy discounts (adapter-translated). */
|
|
17
|
+
promotions?: Promotion[];
|
|
18
|
+
/** Custom entity records, keyed by defineEntity key. Each seed's `data` is
|
|
19
|
+
* validated against the declaration when the entity's store is built. */
|
|
20
|
+
entities?: Record<string, Array<{
|
|
21
|
+
id?: string;
|
|
22
|
+
slug?: string | null;
|
|
23
|
+
data: Record<string, unknown>;
|
|
24
|
+
}>>;
|
|
25
|
+
/** Sidecar fields on core records, keyed `<reference>:<referenceId>`. */
|
|
26
|
+
entityFields?: Record<string, Record<string, unknown>>;
|
|
27
|
+
}
|
|
28
|
+
export declare class MockShopProvider implements ShopProvider {
|
|
29
|
+
private collections;
|
|
30
|
+
private giftCards;
|
|
31
|
+
private emailTemplates;
|
|
32
|
+
private customerGroups;
|
|
33
|
+
private customerSegments;
|
|
34
|
+
private products;
|
|
35
|
+
private categories;
|
|
36
|
+
private discounts;
|
|
37
|
+
private orders;
|
|
38
|
+
private customers;
|
|
39
|
+
private enquiries;
|
|
40
|
+
private channels;
|
|
41
|
+
private entitySeed;
|
|
42
|
+
private entityStores;
|
|
43
|
+
private sidecars;
|
|
44
|
+
private promotions;
|
|
45
|
+
private variantSets;
|
|
46
|
+
constructor(seed?: MockShopSeed);
|
|
47
|
+
/** The I5 indirection: a promoted (registered) store wins; otherwise the
|
|
48
|
+
* entity gets a lazily-built in-memory store seeded from the mock seed.
|
|
49
|
+
* Lazy on purpose — the seed is validated against the declaration, which
|
|
50
|
+
* the app may register after constructing the provider. */
|
|
51
|
+
private entityStore;
|
|
52
|
+
private syncOrders;
|
|
53
|
+
private syncCustomers;
|
|
54
|
+
private syncEnquiries;
|
|
55
|
+
private syncChannels;
|
|
56
|
+
private persistOrders;
|
|
57
|
+
private persistCustomers;
|
|
58
|
+
private persistEnquiries;
|
|
59
|
+
private persistChannels;
|
|
60
|
+
listProducts(opts?: ListProductsOptions): Promise<Product[]>;
|
|
61
|
+
getProduct(id: string): Promise<Product | null>;
|
|
62
|
+
/** Option axes + variants (spine M5) — active variants only, like the 0028
|
|
63
|
+
* storefront RLS. Answers empty sets for a variantless product. */
|
|
64
|
+
getProductVariants(productId: string): Promise<ProductVariantSet>;
|
|
65
|
+
createProduct(input: CreateProductInput): Promise<Product>;
|
|
66
|
+
updateProduct(id: string, input: UpdateProductInput): Promise<Product>;
|
|
67
|
+
deleteProduct(id: string): Promise<void>;
|
|
68
|
+
uploadProductImage(_productId: string, _file: File): Promise<ProductImage>;
|
|
69
|
+
deleteProductImage(_imageId: string): Promise<void>;
|
|
70
|
+
createProductEnquiry(input: CreateProductEnquiryInput): Promise<ProductEnquiry>;
|
|
71
|
+
listProductEnquiries(opts?: ListProductEnquiriesOptions): Promise<ProductEnquiry[]>;
|
|
72
|
+
listCategories(): Promise<Category[]>;
|
|
73
|
+
createCategory(input: CreateCategoryInput): Promise<Category>;
|
|
74
|
+
updateCategory(id: string, input: UpdateCategoryInput): Promise<Category>;
|
|
75
|
+
deleteCategory(id: string): Promise<void>;
|
|
76
|
+
listOrders(opts?: ListOrdersOptions): Promise<Order[]>;
|
|
77
|
+
getOrder(id: string): Promise<Order | null>;
|
|
78
|
+
createOrder(input: CreateOrderInput): Promise<Order>;
|
|
79
|
+
updateOrder(id: string, input: UpdateOrderInput): Promise<Order>;
|
|
80
|
+
placeOrder(input: PlaceOrderInput): Promise<Order>;
|
|
81
|
+
listCustomers(opts?: ListCustomersOptions): Promise<ShopCustomer[]>;
|
|
82
|
+
getCustomer(id: string): Promise<ShopCustomer | null>;
|
|
83
|
+
createCustomer(input: CreateCustomerInput): Promise<ShopCustomer>;
|
|
84
|
+
updateCustomer(id: string, input: UpdateCustomerInput): Promise<ShopCustomer>;
|
|
85
|
+
deleteCustomer(id: string): Promise<void>;
|
|
86
|
+
resolveCustomer(input: ResolveCustomerInput): Promise<ShopCustomer>;
|
|
87
|
+
evaluatePromotions(input: {
|
|
88
|
+
cart: RuleCartSnapshot;
|
|
89
|
+
}): Promise<ComputeAction[]>;
|
|
90
|
+
listDiscounts(opts?: ListDiscountsOptions): Promise<Discount[]>;
|
|
91
|
+
getDiscount(id: string): Promise<Discount | null>;
|
|
92
|
+
createDiscount(input: CreateDiscountInput): Promise<Discount>;
|
|
93
|
+
updateDiscount(id: string, input: UpdateDiscountInput): Promise<Discount>;
|
|
94
|
+
deleteDiscount(id: string): Promise<void>;
|
|
95
|
+
listSalesChannels(): Promise<SalesChannel[]>;
|
|
96
|
+
createSalesChannel(input: CreateSalesChannelInput): Promise<SalesChannel>;
|
|
97
|
+
updateSalesChannel(id: string, input: UpdateSalesChannelInput): Promise<SalesChannel>;
|
|
98
|
+
deleteSalesChannel(id: string): Promise<void>;
|
|
99
|
+
listEntityRecords(entity: string, options?: ListEntityRecordsOptions): Promise<EntityRecord[]>;
|
|
100
|
+
getEntityRecord(entity: string, id: string): Promise<EntityRecord | null>;
|
|
101
|
+
getEntityRecordBySlug(entity: string, slug: string): Promise<EntityRecord | null>;
|
|
102
|
+
createEntityRecord(entity: string, input: EntityRecordInput): Promise<EntityRecord>;
|
|
103
|
+
updateEntityRecord(entity: string, id: string, input: Partial<EntityRecordInput>): Promise<EntityRecord>;
|
|
104
|
+
deleteEntityRecord(entity: string, id: string): Promise<void>;
|
|
105
|
+
getEntityFields(reference: string, referenceId: string): Promise<Record<string, unknown> | null>;
|
|
106
|
+
setEntityFields(reference: string, referenceId: string, fields: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
107
|
+
listCollections(): Promise<Collection[]>;
|
|
108
|
+
getCollection(id: string): Promise<Collection | null>;
|
|
109
|
+
createCollection(input: CreateCollectionInput): Promise<Collection>;
|
|
110
|
+
updateCollection(id: string, input: UpdateCollectionInput): Promise<Collection>;
|
|
111
|
+
deleteCollection(id: string): Promise<void>;
|
|
112
|
+
listCustomerGroups(): Promise<CustomerGroup[]>;
|
|
113
|
+
createCustomerGroup(input: CreateCustomerGroupInput): Promise<CustomerGroup>;
|
|
114
|
+
updateCustomerGroup(id: string, input: UpdateCustomerGroupInput): Promise<CustomerGroup>;
|
|
115
|
+
deleteCustomerGroup(id: string): Promise<void>;
|
|
116
|
+
listCustomerSegments(): Promise<CustomerSegment[]>;
|
|
117
|
+
createCustomerSegment(input: CreateCustomerSegmentInput): Promise<CustomerSegment>;
|
|
118
|
+
updateCustomerSegment(id: string, input: UpdateCustomerSegmentInput): Promise<CustomerSegment>;
|
|
119
|
+
deleteCustomerSegment(id: string): Promise<void>;
|
|
120
|
+
listGiftCards(): Promise<GiftCard[]>;
|
|
121
|
+
createGiftCard(input: CreateGiftCardInput): Promise<GiftCard>;
|
|
122
|
+
updateGiftCard(id: string, input: UpdateGiftCardInput): Promise<GiftCard>;
|
|
123
|
+
deleteGiftCard(id: string): Promise<void>;
|
|
124
|
+
listEmailTemplates(): Promise<EmailTemplate[]>;
|
|
125
|
+
upsertEmailTemplate(input: UpsertEmailTemplateInput): Promise<EmailTemplate>;
|
|
126
|
+
private syncCollections;
|
|
127
|
+
private persistCollections;
|
|
128
|
+
private syncGiftCards;
|
|
129
|
+
private persistGiftCards;
|
|
130
|
+
private syncEmailTemplates;
|
|
131
|
+
}
|
|
132
|
+
export declare function createMockShopProvider(seed?: MockShopSeed): ShopProvider;
|
|
133
|
+
//# sourceMappingURL=mock-provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mock-provider.d.ts","sourceRoot":"","sources":["../../src/data/mock-provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAC9C,OAAO,KAAK,EACV,OAAO,EAAE,YAAY,EAAkB,iBAAiB,EAAE,QAAQ,EAAE,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,cAAc,EACjH,kBAAkB,EAAE,kBAAkB,EAAE,mBAAmB,EAC3D,yBAAyB,EAAE,2BAA2B,EACtD,mBAAmB,EAAE,mBAAmB,EACxC,gBAAgB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,eAAe,EACtE,mBAAmB,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,oBAAoB,EACpF,mBAAmB,EAAE,mBAAmB,EAAE,oBAAoB,EAC9D,YAAY,EAAE,uBAAuB,EAAE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AAC,QAAQ,EAAE,CAAC;IAKpC,cAAc,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAC,QAAQ,CAAC;IAoB7D,cAAc,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAC,QAAQ,CAAC;IASzE,cAAc,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAMzC,kBAAkB,IAAI,OAAO,CAAC,aAAa,EAAE,CAAC;IAK9C,mBAAmB,CAAC,KAAK,EAAE,wBAAwB,GAAG,OAAO,CAAC,aAAa,CAAC;IAcpF,OAAO,CAAC,eAAe;IAKrB,OAAO,CAAC,kBAAkB;IAE1B,OAAO,CAAC,aAAa;IAKrB,OAAO,CAAC,gBAAgB;IAExB,OAAO,CAAC,kBAAkB;CAI3B;AAED,wBAAgB,sBAAsB,CAAC,IAAI,CAAC,EAAE,YAAY,GAAG,YAAY,CAExE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mock.d.ts","sourceRoot":"","sources":["../../src/data/mock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAA;AAC1E,YAAY,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA"}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import type { EntityRecord, EntityRecordInput, ListEntityRecordsOptions } from '../entities/entity-store';
|
|
2
|
+
import type { ComputeAction, RuleCartSnapshot } from '../rules/rule-types';
|
|
3
|
+
import type { Product, ProductImage, ProductVariantSet, Category, Order, ShopCustomer, Discount, ProductEnquiry, CreateProductInput, UpdateProductInput, ListProductsOptions, CreateProductEnquiryInput, ListProductEnquiriesOptions, CreateCategoryInput, UpdateCategoryInput, CreateOrderInput, UpdateOrderInput, ListOrdersOptions, PlaceOrderInput, CreateCustomerInput, UpdateCustomerInput, ListCustomersOptions, ResolveCustomerInput, CustomerAddress, ShippingQuoteOption, ShippingZone, CreateShippingZoneInput, UpdateShippingZoneInput, CreateDiscountInput, UpdateDiscountInput, ListDiscountsOptions, SalesChannel, CreateSalesChannelInput, UpdateSalesChannelInput, Collection, CreateCollectionInput, UpdateCollectionInput, CustomerGroup, CreateCustomerGroupInput, UpdateCustomerGroupInput, CustomerSegment, CreateCustomerSegmentInput, UpdateCustomerSegmentInput, GiftCard, CreateGiftCardInput, UpdateGiftCardInput, EmailTemplate, UpsertEmailTemplateInput, MediaFile } from '../types';
|
|
4
|
+
export interface ShopProvider {
|
|
5
|
+
listProducts(options?: ListProductsOptions): Promise<Product[]>;
|
|
6
|
+
getProduct(id: string): Promise<Product | null>;
|
|
7
|
+
createProduct(input: CreateProductInput): Promise<Product>;
|
|
8
|
+
updateProduct(id: string, input: UpdateProductInput): Promise<Product>;
|
|
9
|
+
deleteProduct(id: string): Promise<void>;
|
|
10
|
+
uploadProductImage(productId: string, file: File): Promise<ProductImage>;
|
|
11
|
+
deleteProductImage(imageId: string): Promise<void>;
|
|
12
|
+
/**
|
|
13
|
+
* Reorder a gallery or promote a photo to primary. Optional so a provider
|
|
14
|
+
* that only ever holds one image per product need not implement it.
|
|
15
|
+
*
|
|
16
|
+
* Setting `isPrimary` is exclusive: the previous primary is demoted in the
|
|
17
|
+
* same call, because two primaries make "the product photo" ambiguous
|
|
18
|
+
* everywhere it is read (card, cart line, order item, admin table).
|
|
19
|
+
*/
|
|
20
|
+
updateProductImage?(imageId: string, input: {
|
|
21
|
+
isPrimary?: boolean;
|
|
22
|
+
sortOrder?: number;
|
|
23
|
+
altText?: string | null;
|
|
24
|
+
}): Promise<ProductImage>;
|
|
25
|
+
/**
|
|
26
|
+
* Option axes + variants of one product (spine M5, tables from 0028). The
|
|
27
|
+
* product-detail read path: products.bySlug attaches the result onto the
|
|
28
|
+
* Product it returns, which is where the option picker sources from — the
|
|
29
|
+
* DB, never the productMetadata overlay. Optional: a provider without it
|
|
30
|
+
* yields option-less products (list reads skip variants either way).
|
|
31
|
+
*/
|
|
32
|
+
getProductVariants?(productId: string): Promise<ProductVariantSet>;
|
|
33
|
+
createProductEnquiry?(input: CreateProductEnquiryInput): Promise<ProductEnquiry>;
|
|
34
|
+
listProductEnquiries?(options?: ListProductEnquiriesOptions): Promise<ProductEnquiry[]>;
|
|
35
|
+
listCategories(): Promise<Category[]>;
|
|
36
|
+
createCategory(input: CreateCategoryInput): Promise<Category>;
|
|
37
|
+
updateCategory(id: string, input: UpdateCategoryInput): Promise<Category>;
|
|
38
|
+
deleteCategory(id: string): Promise<void>;
|
|
39
|
+
listOrders(options?: ListOrdersOptions): Promise<Order[]>;
|
|
40
|
+
getOrder(id: string): Promise<Order | null>;
|
|
41
|
+
createOrder(input: CreateOrderInput): Promise<Order>;
|
|
42
|
+
updateOrder(id: string, input: UpdateOrderInput): Promise<Order>;
|
|
43
|
+
/**
|
|
44
|
+
* Mock/dev payment seam: pending->paid transition via a whitelisted RPC
|
|
45
|
+
* (anon storefronts have no UPDATE grant on the orders table). Real PSPs
|
|
46
|
+
* confirm via webhook with service_role instead.
|
|
47
|
+
*/
|
|
48
|
+
confirmPayment?(id: string, reference?: string): Promise<Order | null>;
|
|
49
|
+
/**
|
|
50
|
+
* Trusted order placement: the server re-reads product prices + stock,
|
|
51
|
+
* validates the discount, computes totals, and decrements inventory
|
|
52
|
+
* atomically. Storefront checkout MUST use this instead of createOrder so the
|
|
53
|
+
* browser cannot tamper with prices. createOrder remains for trusted admin entry.
|
|
54
|
+
*/
|
|
55
|
+
placeOrder(input: PlaceOrderInput): Promise<Order>;
|
|
56
|
+
listCustomers(options?: ListCustomersOptions): Promise<ShopCustomer[]>;
|
|
57
|
+
getCustomer(id: string): Promise<ShopCustomer | null>;
|
|
58
|
+
createCustomer(input: CreateCustomerInput): Promise<ShopCustomer>;
|
|
59
|
+
updateCustomer(id: string, input: UpdateCustomerInput): Promise<ShopCustomer>;
|
|
60
|
+
deleteCustomer(id: string): Promise<void>;
|
|
61
|
+
/**
|
|
62
|
+
* Find-or-create the customer for a storefront shopper and (on Supabase) link
|
|
63
|
+
* it to auth.uid server-side, so order reads can be scoped to the owner by RLS.
|
|
64
|
+
* Optional: providers without it fall back to listCustomers+createCustomer.
|
|
65
|
+
*/
|
|
66
|
+
resolveCustomer?(input: ResolveCustomerInput): Promise<ShopCustomer>;
|
|
67
|
+
/**
|
|
68
|
+
* The signed-in shopper's saved delivery addresses, so checkout can offer
|
|
69
|
+
* them instead of inventing a placeholder. Optional: a provider without it
|
|
70
|
+
* (or an anonymous request) yields an empty book and a blank form.
|
|
71
|
+
*/
|
|
72
|
+
listCustomerAddresses?(customerId: string): Promise<CustomerAddress[]>;
|
|
73
|
+
/**
|
|
74
|
+
* Delivery options for a postal code at a given subtotal. An empty array
|
|
75
|
+
* means the store does not deliver there — shown before the buyer commits to
|
|
76
|
+
* a cart, which is the whole point of quoting on the product page.
|
|
77
|
+
*
|
|
78
|
+
* This is for DISPLAY. shop_place_order recomputes the freight from the same
|
|
79
|
+
* zones and ignores whatever the client sends, so a tampered quote changes
|
|
80
|
+
* what the shopper sees and nothing about what they are charged.
|
|
81
|
+
*/
|
|
82
|
+
quoteShipping?(postalCode: string, subtotal: number): Promise<ShippingQuoteOption[]>;
|
|
83
|
+
/** Delivery zones the merchant maintains. Admin-only: the storefront reads
|
|
84
|
+
* quotes, never the ranges themselves. */
|
|
85
|
+
listShippingZones?(): Promise<ShippingZone[]>;
|
|
86
|
+
createShippingZone?(input: CreateShippingZoneInput): Promise<ShippingZone>;
|
|
87
|
+
updateShippingZone?(id: string, input: UpdateShippingZoneInput): Promise<ShippingZone>;
|
|
88
|
+
deleteShippingZone?(id: string): Promise<void>;
|
|
89
|
+
/**
|
|
90
|
+
* Evaluate the store's promotions against a cart snapshot → the ordered
|
|
91
|
+
* compute-actions the cart applies (addItemDiscount, addShippingDiscount,
|
|
92
|
+
* addFreeItem). ADVISORY in the browser — a preview of what the trust
|
|
93
|
+
* boundary will conclude; shop_place_order revalidates server-side with the
|
|
94
|
+
* same semantics (migrations/0033 mirrors the TS evaluator).
|
|
95
|
+
*
|
|
96
|
+
* Optional: describeStore keys `capabilities.ruleEngine` off it, and the
|
|
97
|
+
* coupon surface falls back to the legacy percent path without it.
|
|
98
|
+
*/
|
|
99
|
+
evaluatePromotions?(input: {
|
|
100
|
+
cart: RuleCartSnapshot;
|
|
101
|
+
}): Promise<ComputeAction[]>;
|
|
102
|
+
listDiscounts(options?: ListDiscountsOptions): Promise<Discount[]>;
|
|
103
|
+
getDiscount(id: string): Promise<Discount | null>;
|
|
104
|
+
createDiscount(input: CreateDiscountInput): Promise<Discount>;
|
|
105
|
+
updateDiscount(id: string, input: UpdateDiscountInput): Promise<Discount>;
|
|
106
|
+
deleteDiscount(id: string): Promise<void>;
|
|
107
|
+
listSalesChannels?(): Promise<SalesChannel[]>;
|
|
108
|
+
createSalesChannel?(input: CreateSalesChannelInput): Promise<SalesChannel>;
|
|
109
|
+
updateSalesChannel?(id: string, input: UpdateSalesChannelInput): Promise<SalesChannel>;
|
|
110
|
+
deleteSalesChannel?(id: string): Promise<void>;
|
|
111
|
+
listEntityRecords?(entity: string, options?: ListEntityRecordsOptions): Promise<EntityRecord[]>;
|
|
112
|
+
getEntityRecord?(entity: string, id: string): Promise<EntityRecord | null>;
|
|
113
|
+
getEntityRecordBySlug?(entity: string, slug: string): Promise<EntityRecord | null>;
|
|
114
|
+
createEntityRecord?(entity: string, input: EntityRecordInput): Promise<EntityRecord>;
|
|
115
|
+
updateEntityRecord?(entity: string, id: string, input: Partial<EntityRecordInput>): Promise<EntityRecord>;
|
|
116
|
+
deleteEntityRecord?(entity: string, id: string): Promise<void>;
|
|
117
|
+
getEntityFields?(reference: string, referenceId: string): Promise<Record<string, unknown> | null>;
|
|
118
|
+
setEntityFields?(reference: string, referenceId: string, fields: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
119
|
+
listCollections?(): Promise<Collection[]>;
|
|
120
|
+
getCollection?(id: string): Promise<Collection | null>;
|
|
121
|
+
createCollection?(input: CreateCollectionInput): Promise<Collection>;
|
|
122
|
+
updateCollection?(id: string, input: UpdateCollectionInput): Promise<Collection>;
|
|
123
|
+
deleteCollection?(id: string): Promise<void>;
|
|
124
|
+
listCustomerGroups?(): Promise<CustomerGroup[]>;
|
|
125
|
+
createCustomerGroup?(input: CreateCustomerGroupInput): Promise<CustomerGroup>;
|
|
126
|
+
updateCustomerGroup?(id: string, input: UpdateCustomerGroupInput): Promise<CustomerGroup>;
|
|
127
|
+
deleteCustomerGroup?(id: string): Promise<void>;
|
|
128
|
+
listCustomerSegments?(): Promise<CustomerSegment[]>;
|
|
129
|
+
createCustomerSegment?(input: CreateCustomerSegmentInput): Promise<CustomerSegment>;
|
|
130
|
+
updateCustomerSegment?(id: string, input: UpdateCustomerSegmentInput): Promise<CustomerSegment>;
|
|
131
|
+
deleteCustomerSegment?(id: string): Promise<void>;
|
|
132
|
+
listGiftCards?(): Promise<GiftCard[]>;
|
|
133
|
+
createGiftCard?(input: CreateGiftCardInput): Promise<GiftCard>;
|
|
134
|
+
updateGiftCard?(id: string, input: UpdateGiftCardInput): Promise<GiftCard>;
|
|
135
|
+
deleteGiftCard?(id: string): Promise<void>;
|
|
136
|
+
listEmailTemplates?(): Promise<EmailTemplate[]>;
|
|
137
|
+
upsertEmailTemplate?(input: UpsertEmailTemplateInput): Promise<EmailTemplate>;
|
|
138
|
+
listMediaFiles?(): Promise<MediaFile[]>;
|
|
139
|
+
uploadMediaFile?(file: File): Promise<MediaFile>;
|
|
140
|
+
deleteMediaFile?(id: string): Promise<void>;
|
|
141
|
+
}
|
|
142
|
+
//# sourceMappingURL=provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../src/data/provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAA;AACzG,OAAO,KAAK,EAAE,aAA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,CAAA;IAC7E,cAAc,CAAC,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC,CAAA;IACvC,eAAe,CAAC,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,SAAS,CAAC,CAAA;IAChD,eAAe,CAAC,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CAC5C"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import type { EntityRecord, EntityRecordInput, ListEntityRecordsOptions } from '../entities/entity-store';
|
|
2
|
+
import type { ShopProvider } from './provider';
|
|
3
|
+
import type { ComputeAction, RuleCartSnapshot } from '../rules/rule-types';
|
|
4
|
+
import type { Product, ProductImage, ProductVariantSet, Category, Order, ShopCustomer, Discount, CreateProductInput, UpdateProductInput, ListProductsOptions, CreateCategoryInput, UpdateCategoryInput, CreateOrderInput, UpdateOrderInput, ListOrdersOptions, PlaceOrderInput, CreateCustomerInput, UpdateCustomerInput, ListCustomersOptions, ResolveCustomerInput, CreateDiscountInput, UpdateDiscountInput, ListDiscountsOptions, SalesChannel, CreateSalesChannelInput, UpdateSalesChannelInput, ShippingZone, CreateShippingZoneInput, UpdateShippingZoneInput, Collection, CreateCollectionInput, UpdateCollectionInput, CustomerGroup, CreateCustomerGroupInput, UpdateCustomerGroupInput, CustomerSegment, CreateCustomerSegmentInput, UpdateCustomerSegmentInput, GiftCard, CreateGiftCardInput, UpdateGiftCardInput, EmailTemplate, UpsertEmailTemplateInput, MediaFile } from '../types';
|
|
5
|
+
export declare function mediaKindOf(name: string, mime?: string | null): MediaFile['kind'];
|
|
6
|
+
export declare class SupabaseShopProvider implements ShopProvider {
|
|
7
|
+
listProducts(options?: ListProductsOptions): Promise<Product[]>;
|
|
8
|
+
getProduct(id: string): Promise<Product | null>;
|
|
9
|
+
/** Option axes + variants from the 0028 tables (spine M5). The storefront
|
|
10
|
+
* RLS on both tables already restricts anon reads to active variants of
|
|
11
|
+
* publicly readable products; the status filter here keeps the admin path
|
|
12
|
+
* (authenticated tenant member, who CAN see archived rows) consistent. */
|
|
13
|
+
getProductVariants(productId: string): Promise<ProductVariantSet>;
|
|
14
|
+
createProduct(input: CreateProductInput): Promise<Product>;
|
|
15
|
+
updateProduct(id: string, input: UpdateProductInput): Promise<Product>;
|
|
16
|
+
deleteProduct(id: string): Promise<void>;
|
|
17
|
+
uploadProductImage(productId: string, file: File): Promise<ProductImage>;
|
|
18
|
+
updateProductImage(imageId: string, input: {
|
|
19
|
+
isPrimary?: boolean;
|
|
20
|
+
sortOrder?: number;
|
|
21
|
+
altText?: string | null;
|
|
22
|
+
}): Promise<ProductImage>;
|
|
23
|
+
deleteProductImage(imageId: string): Promise<void>;
|
|
24
|
+
listCategories(): Promise<Category[]>;
|
|
25
|
+
createCategory(input: CreateCategoryInput): Promise<Category>;
|
|
26
|
+
updateCategory(id: string, input: UpdateCategoryInput): Promise<Category>;
|
|
27
|
+
deleteCategory(id: string): Promise<void>;
|
|
28
|
+
listOrders(options?: ListOrdersOptions): Promise<Order[]>;
|
|
29
|
+
getOrder(id: string): Promise<Order | null>;
|
|
30
|
+
createOrder(input: CreateOrderInput): Promise<Order>;
|
|
31
|
+
updateOrder(id: string, input: UpdateOrderInput): Promise<Order>;
|
|
32
|
+
listShippingZones(): Promise<ShippingZone[]>;
|
|
33
|
+
createShippingZone(input: CreateShippingZoneInput): Promise<ShippingZone>;
|
|
34
|
+
updateShippingZone(id: string, input: UpdateShippingZoneInput): Promise<ShippingZone>;
|
|
35
|
+
deleteShippingZone(id: string): Promise<void>;
|
|
36
|
+
/**
|
|
37
|
+
* Settle a pending order: the merchant confirming that the money arrived.
|
|
38
|
+
*
|
|
39
|
+
* Goes through the RPC rather than an UPDATE so the payment ledger row in
|
|
40
|
+
* public.transactions closes in the same transaction as the order — set
|
|
41
|
+
* financial_status by hand and the order says paid while the ledger still
|
|
42
|
+
* says pending. Since 0019 the RPC also enforces who may call it: a member of
|
|
43
|
+
* the owning tenant, or a PSP webhook with the service role.
|
|
44
|
+
*/
|
|
45
|
+
confirmPayment(id: string, reference?: string): Promise<Order | null>;
|
|
46
|
+
placeOrder(input: PlaceOrderInput): Promise<Order>;
|
|
47
|
+
listCustomers(options?: ListCustomersOptions): Promise<ShopCustomer[]>;
|
|
48
|
+
getCustomer(id: string): Promise<ShopCustomer | null>;
|
|
49
|
+
createCustomer(input: CreateCustomerInput): Promise<ShopCustomer>;
|
|
50
|
+
updateCustomer(id: string, input: UpdateCustomerInput): Promise<ShopCustomer>;
|
|
51
|
+
deleteCustomer(id: string): Promise<void>;
|
|
52
|
+
resolveCustomer(input: ResolveCustomerInput): Promise<ShopCustomer>;
|
|
53
|
+
evaluatePromotions(input: {
|
|
54
|
+
cart: RuleCartSnapshot;
|
|
55
|
+
}): Promise<ComputeAction[]>;
|
|
56
|
+
listDiscounts(options?: ListDiscountsOptions): Promise<Discount[]>;
|
|
57
|
+
getDiscount(id: string): Promise<Discount | null>;
|
|
58
|
+
createDiscount(input: CreateDiscountInput): Promise<Discount>;
|
|
59
|
+
updateDiscount(id: string, input: UpdateDiscountInput): Promise<Discount>;
|
|
60
|
+
deleteDiscount(id: string): Promise<void>;
|
|
61
|
+
listSalesChannels(): Promise<SalesChannel[]>;
|
|
62
|
+
createSalesChannel(input: CreateSalesChannelInput): Promise<SalesChannel>;
|
|
63
|
+
updateSalesChannel(id: string, input: UpdateSalesChannelInput): Promise<SalesChannel>;
|
|
64
|
+
deleteSalesChannel(id: string): Promise<void>;
|
|
65
|
+
private entityStore;
|
|
66
|
+
listEntityRecords(entity: string, options?: ListEntityRecordsOptions): Promise<EntityRecord[]>;
|
|
67
|
+
getEntityRecord(entity: string, id: string): Promise<EntityRecord | null>;
|
|
68
|
+
getEntityRecordBySlug(entity: string, slug: string): Promise<EntityRecord | null>;
|
|
69
|
+
createEntityRecord(entity: string, input: EntityRecordInput): Promise<EntityRecord>;
|
|
70
|
+
updateEntityRecord(entity: string, id: string, input: Partial<EntityRecordInput>): Promise<EntityRecord>;
|
|
71
|
+
deleteEntityRecord(entity: string, id: string): Promise<void>;
|
|
72
|
+
getEntityFields(reference: string, referenceId: string): Promise<Record<string, unknown> | null>;
|
|
73
|
+
setEntityFields(reference: string, referenceId: string, fields: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
74
|
+
listCollections(): Promise<Collection[]>;
|
|
75
|
+
getCollection(id: string): Promise<Collection | null>;
|
|
76
|
+
createCollection(input: CreateCollectionInput): Promise<Collection>;
|
|
77
|
+
updateCollection(id: string, input: UpdateCollectionInput): Promise<Collection>;
|
|
78
|
+
deleteCollection(id: string): Promise<void>;
|
|
79
|
+
listCustomerGroups(): Promise<CustomerGroup[]>;
|
|
80
|
+
createCustomerGroup(input: CreateCustomerGroupInput): Promise<CustomerGroup>;
|
|
81
|
+
updateCustomerGroup(id: string, input: UpdateCustomerGroupInput): Promise<CustomerGroup>;
|
|
82
|
+
deleteCustomerGroup(id: string): Promise<void>;
|
|
83
|
+
listCustomerSegments(): Promise<CustomerSegment[]>;
|
|
84
|
+
createCustomerSegment(input: CreateCustomerSegmentInput): Promise<CustomerSegment>;
|
|
85
|
+
updateCustomerSegment(id: string, input: UpdateCustomerSegmentInput): Promise<CustomerSegment>;
|
|
86
|
+
deleteCustomerSegment(id: string): Promise<void>;
|
|
87
|
+
listGiftCards(): Promise<GiftCard[]>;
|
|
88
|
+
createGiftCard(input: CreateGiftCardInput): Promise<GiftCard>;
|
|
89
|
+
updateGiftCard(id: string, input: UpdateGiftCardInput): Promise<GiftCard>;
|
|
90
|
+
deleteGiftCard(id: string): Promise<void>;
|
|
91
|
+
listEmailTemplates(): Promise<EmailTemplate[]>;
|
|
92
|
+
upsertEmailTemplate(input: UpsertEmailTemplateInput): Promise<EmailTemplate>;
|
|
93
|
+
listMediaFiles(): Promise<MediaFile[]>;
|
|
94
|
+
uploadMediaFile(file: File): Promise<MediaFile>;
|
|
95
|
+
deleteMediaFile(id: string): Promise<void>;
|
|
96
|
+
private syncCollectionProducts;
|
|
97
|
+
private syncGroupMembers;
|
|
98
|
+
}
|
|
99
|
+
export declare function createSupabaseShopProvider(): ShopProvider;
|
|
100
|
+
//# sourceMappingURL=supabase-provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"supabase-provider.d.ts","sourceRoot":"","sources":["../../src/data/supabase-provider.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAA;AAGzG,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAC9C,OAAO,KAAK,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AAG1E,OAAO,KAAK,EACV,OAAO,EAAE,YAAY,EAAiC,iBAAiB,EAAE,QAAQ,EACjF,KAAK,EAAE,YAAY,EAAE,QAAQ,EAC7B,kBAAkB,EAAE,kBAAkB,EAAE,mBAAmB,EAC3D,mBAAmB,EAAE,mBAAmB,EACxC,gBAAgB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,eAAe,EACtE,mBAAmB,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,oBAAoB,EACpF,mBAAmB,EAAE,mBAAmB,EAAE,oBAAoB,EAC9D,YAAY,EAAE,uBAAuB,EAAE,uBAAuB,EAC9D,YAAY,EAAE,uBAAuB,EAAE,uBAAuB,EAC9D,UAAU,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,aAAa,EAAE,wBAAwB,EAAE,wBAAwB,EAAE,eAAe,EAAE,0BAA0B,EAAE,0BAA0B,EAAE,QAAQ,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,aAAa,EAAE,wBAAwB,EAAE,SAAS,EAC7S,MAAM,UAAU,CAAA;AA4OjB,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,MAAM,CAAC,CAOjF;AA2GD,qBAAa,oBAA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IAUlD,qBAAqB,CAAC,KAAK,EAAE,0BAA0B,GAAG,OAAO,CAAC,eAAe,CAAC;IASlF,qBAAqB,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,0BAA0B,GAAG,OAAO,CAAC,eAAe,CAAC;IAO9F,qBAAqB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAKhD,aAAa,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;IAUpC,cAAc,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAC,QAAQ,CAAC;IAuB7D,cAAc,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAC,QAAQ,CAAC;IAczE,cAAc,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAKzC,kBAAkB,IAAI,OAAO,CAAC,aAAa,EAAE,CAAC;IAe9C,mBAAmB,CAAC,KAAK,EAAE,wBAAwB,GAAG,OAAO,CAAC,aAAa,CAAC;IAmB5E,cAAc,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;IA2CtC,eAAe,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,SAAS,CAAC;IAsB/C,eAAe,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;YAKpC,sBAAsB;YAkBpB,gBAAgB;CAiB/B;AAED,wBAAgB,0BAA0B,IAAI,YAAY,CAEzD"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export declare const T: {
|
|
2
|
+
readonly products: "plg_shop_products";
|
|
3
|
+
readonly productImages: "plg_shop_product_images";
|
|
4
|
+
readonly productOptions: "plg_shop_product_options";
|
|
5
|
+
readonly productVariants: "plg_shop_product_variants";
|
|
6
|
+
readonly categories: "plg_shop_categories";
|
|
7
|
+
readonly orders: "plg_shop_orders";
|
|
8
|
+
readonly orderItems: "plg_shop_order_items";
|
|
9
|
+
readonly customers: "plg_shop_customers";
|
|
10
|
+
readonly discounts: "plg_shop_discounts";
|
|
11
|
+
readonly salesChannels: "plg_shop_channels";
|
|
12
|
+
readonly collections: "plg_shop_collections";
|
|
13
|
+
readonly collectionProducts: "plg_shop_collection_products";
|
|
14
|
+
readonly giftCards: "plg_shop_gift_cards";
|
|
15
|
+
readonly messageTemplates: "plg_automations_templates";
|
|
16
|
+
readonly customerGroups: "plg_shop_customer_groups";
|
|
17
|
+
readonly customerGroupMembers: "plg_shop_customer_group_members";
|
|
18
|
+
readonly customerSegments: "plg_shop_customer_segments";
|
|
19
|
+
/** Public bucket the media library and product photos both live in. */
|
|
20
|
+
readonly mediaBucket: "shop-images";
|
|
21
|
+
readonly stockMovementKinds: "plg_shop_stock_movement_kinds";
|
|
22
|
+
readonly stockReasonCodes: "plg_shop_stock_reason_codes";
|
|
23
|
+
readonly stockLocations: "plg_shop_stock_locations";
|
|
24
|
+
readonly stockLots: "plg_shop_stock_lots";
|
|
25
|
+
readonly stockMovements: "plg_shop_stock_movements";
|
|
26
|
+
readonly stockReservations: "plg_shop_stock_reservations";
|
|
27
|
+
readonly stockBalances: "plg_shop_stock_balances";
|
|
28
|
+
readonly stockAllocationStrategies: "plg_shop_stock_allocation_strategies";
|
|
29
|
+
readonly stockReservationTtls: "plg_shop_stock_reservation_ttls";
|
|
30
|
+
readonly stockLevels: "plg_shop_stock_levels";
|
|
31
|
+
readonly orderItemLots: "plg_shop_order_item_lots";
|
|
32
|
+
readonly settings: "plg_shop_settings";
|
|
33
|
+
readonly shippingZones: "shipping_zones";
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=tables.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tables.d.ts","sourceRoot":"","sources":["../../src/data/tables.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,CAAC;;;;;;;;;;;;;;;;;;IAwBZ,uEAAuE;;;;;;;;;;;;;;;CA+B/D,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tenant.d.ts","sourceRoot":"","sources":["../../src/data/tenant.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,cAAc,GAAG,MAAM,MAAM,GAAG,SAAS,CAAA;AAIrD,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,cAAc,GAAG,IAAI,CAEpE;AAED,wBAAgB,eAAe,IAAI,MAAM,GAAG,SAAS,CAOpD"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { EntityDeclaration } from '@fayz-ai/core';
|
|
2
|
+
/** What the pipeline observed in the database for ONE entity, as a value. */
|
|
3
|
+
export interface ObservedEntitySchema {
|
|
4
|
+
/** The plg_entity_types definition previously reconciled, or null the first
|
|
5
|
+
* time. The shape serializeEntityDeclaration wrote (an EntityDeclaration). */
|
|
6
|
+
descriptor: EntityDeclaration | null;
|
|
7
|
+
/** Index names present on the entity's storage table. */
|
|
8
|
+
indexes: readonly string[];
|
|
9
|
+
/** Policy names present on the entity's storage table. */
|
|
10
|
+
policies: readonly string[];
|
|
11
|
+
}
|
|
12
|
+
export interface QuarantinedDdl {
|
|
13
|
+
sql: string;
|
|
14
|
+
/** Why this cannot run unattended — shown to whoever reviews the plan. */
|
|
15
|
+
reason: string;
|
|
16
|
+
}
|
|
17
|
+
export interface EntityReconcilePlan {
|
|
18
|
+
/** Additive, idempotent statements, in application order. */
|
|
19
|
+
safe: string[];
|
|
20
|
+
/** Destructive or narrowing statements. NEVER applied automatically. */
|
|
21
|
+
quarantined: QuarantinedDdl[];
|
|
22
|
+
}
|
|
23
|
+
export interface ReconcileEntityOptions {
|
|
24
|
+
/** Tenant the descriptor upsert is scoped to. */
|
|
25
|
+
tenantId: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Diff one declaration against what the database was observed to hold and
|
|
29
|
+
* produce the plan. Deterministic and total — same inputs, same plan.
|
|
30
|
+
*/
|
|
31
|
+
export declare function reconcileEntity(declaration: EntityDeclaration, observed: ObservedEntitySchema, options: ReconcileEntityOptions): EntityReconcilePlan;
|
|
32
|
+
//# sourceMappingURL=entity-reconcile.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entity-reconcile.d.ts","sourceRoot":"","sources":["../../src/entities/entity-reconcile.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAe,MAAM,eAAe,CAAA;AAqBnE,6EAA6E;AAC7E,MAAM,WAAW,oBAAoB;IACnC;mFAC+E;IAC/E,UAAU,EAAE,iBAAiB,GAAG,IAAI,CAAA;IACpC,yDAAyD;IACzD,OAAO,EAAE,SAAS,MAAM,EAAE,CAAA;IAC1B,0DAA0D;IAC1D,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAA;CAC5B;AAED,MAAM,WAAW,cAAc;IAC7B,GAAG,EAAE,MAAM,CAAA;IACX,0EAA0E;IAC1E,MAAM,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,mBAAmB;IAClC,6DAA6D;IAC7D,IAAI,EAAE,MAAM,EAAE,CAAA;IACd,wEAAwE;IACxE,WAAW,EAAE,cAAc,EAAE,CAAA;CAC9B;AAED,MAAM,WAAW,sBAAsB;IACrC,iDAAiD;IACjD,QAAQ,EAAE,MAAM,CAAA;CACjB;AAqCD;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,WAAW,EAAE,iBAAiB,EAC9B,QAAQ,EAAE,oBAAoB,EAC9B,OAAO,EAAE,sBAAsB,GAC9B,mBAAmB,CA0DrB"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { EntityDeclaration } from '@fayz-ai/core';
|
|
2
|
+
/** The declaration-mirror table (migration 0030): what the reconciler diffs
|
|
3
|
+
* against, Medusa link_module_migrations-style. */
|
|
4
|
+
export declare const ENTITY_TYPES_TABLE = "plg_entity_types";
|
|
5
|
+
/** Stable JSON for embedding a declaration: sorted keys, so the same
|
|
6
|
+
* declaration always serializes to the same text and diffs stay quiet. */
|
|
7
|
+
export declare function serializeEntityDeclaration(declaration: EntityDeclaration): string;
|
|
8
|
+
export interface GeneratedPolicy {
|
|
9
|
+
name: string;
|
|
10
|
+
sql: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* The RLS policies one entity requires on its storage table, generated from
|
|
14
|
+
* the declaration:
|
|
15
|
+
*
|
|
16
|
+
* - `<staff>`: tenant members read and write their own rows — the
|
|
17
|
+
* access.write='staff' rule plus tenant scoping, mirroring the plg_shop_*
|
|
18
|
+
* tenant policies (user_tenant_ids()).
|
|
19
|
+
* - `<public_read>` (only when access.read='public'): anonymous storefront
|
|
20
|
+
* read, gated by the SAME published/strict-tenant functions the catalog
|
|
21
|
+
* tables use (0020/0028), so a custom entity is never MORE visible than
|
|
22
|
+
* the store's own products.
|
|
23
|
+
*
|
|
24
|
+
* On the shared generic table every predicate is additionally pinned to
|
|
25
|
+
* `entity = '<key>'`, so one entity's policy can never widen another's rows.
|
|
26
|
+
* A promoted entity (dedicated table) drops the pin: the table IS the entity.
|
|
27
|
+
*/
|
|
28
|
+
export declare function generateEntityPolicies(declaration: EntityDeclaration): GeneratedPolicy[];
|
|
29
|
+
/** The full generated RLS block for one entity, ready to apply or to diff. */
|
|
30
|
+
export declare function generateEntityRlsSql(declaration: EntityDeclaration): string;
|
|
31
|
+
export interface GeneratedIndex {
|
|
32
|
+
name: string;
|
|
33
|
+
sql: string;
|
|
34
|
+
}
|
|
35
|
+
/** Name prefix under which one entity's generated indexes live — how the
|
|
36
|
+
* reconciler tells its own indexes from everyone else's. */
|
|
37
|
+
export declare function entityIndexPrefix(declaration: EntityDeclaration): string;
|
|
38
|
+
/**
|
|
39
|
+
* One expression index per declared index tuple, over the jsonb payload,
|
|
40
|
+
* partial to the entity's rows on the shared table. `data->>'field'` matches
|
|
41
|
+
* how the generic store filters, so the index serves the queries that exist.
|
|
42
|
+
*/
|
|
43
|
+
export declare function generateEntityIndexes(declaration: EntityDeclaration): GeneratedIndex[];
|
|
44
|
+
/**
|
|
45
|
+
* Mirror the declaration into plg_entity_types for the given tenant — the row
|
|
46
|
+
* the NEXT reconciliation diffs against. jsonb comparison in the ON CONFLICT
|
|
47
|
+
* keeps re-applying an unchanged declaration a true no-op.
|
|
48
|
+
*/
|
|
49
|
+
export declare function generateEntityDescriptorUpsertSql(declaration: EntityDeclaration, tenantId: string): string;
|
|
50
|
+
//# sourceMappingURL=entity-sql.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entity-sql.d.ts","sourceRoot":"","sources":["../../src/entities/entity-sql.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAA;AAqBtD;oDACoD;AACpD,eAAO,MAAM,kBAAkB,qBAAqB,CAAA;AAIpD;2EAC2E;AAC3E,wBAAgB,0BAA0B,CAAC,WAAW,EAAE,iBAAiB,GAAG,MAAM,CAejF;AAID,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAA;IACZ,GAAG,EAAE,MAAM,CAAA;CACZ;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,sBAAsB,CAAC,WAAW,EAAE,iBAAiB,GAAG,eAAe,EAAE,CAiCxF;AAED,8EAA8E;AAC9E,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,iBAAiB,GAAG,MAAM,CAG3E;AAID,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAA;IACZ,GAAG,EAAE,MAAM,CAAA;CACZ;AAED;6DAC6D;AAC7D,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,iBAAiB,GAAG,MAAM,CAExE;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,WAAW,EAAE,iBAAiB,GAAG,cAAc,EAAE,CAYtF;AAID;;;;GAIG;AACH,wBAAgB,iCAAiC,CAAC,WAAW,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAS1G"}
|