@tallyui/connector-vendure 1.0.0 → 2.0.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Paul Kilmurray and TallyUI contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/dist/index.d.ts CHANGED
@@ -1,6 +1,9 @@
1
- import { ProductTraits, CollectionSync, ReplicationAdapter, TallyConnector } from '@tallyui/core';
1
+ import { ConnectorAuth, ProductTraits, CollectionSync, ReplicationAdapter, StockReconcileAdapter, SyncContext, StoreSettingsChoice, StoreSettings, TallyConnector } from '@tallyui/core';
2
2
  import { RxJsonSchema } from 'rxdb';
3
3
 
4
+ declare const vendureSignIn: NonNullable<ConnectorAuth['signIn']>;
5
+ declare const vendureAuth: ConnectorAuth;
6
+
4
7
  /**
5
8
  * RxDB schema for Vendure products.
6
9
  *
@@ -14,41 +17,76 @@ import { RxJsonSchema } from 'rxdb';
14
17
  */
15
18
  declare const vendureProductSchema: RxJsonSchema<any>;
16
19
 
17
- /**
18
- * Vendure product trait implementations.
19
- *
20
- * Key differences from other connectors:
21
- * - Product name is `name` (same as WooCommerce, unlike Medusa's `title`)
22
- * - Price is on `variants[].priceWithTax` (integer cents, like Medusa)
23
- * - Images use `featuredAsset.preview` and `assets[].preview`
24
- * - Stock status is a string from the Shop API: 'IN_STOCK', 'OUT_OF_STOCK', 'LOW_STOCK'
25
- * - Categories are `collections[].name` (Vendure's equivalent of categories)
26
- * - No native sale price — Vendure handles sales via promotions at checkout
27
- * - No native barcode field — uses custom fields if configured
28
- */
29
- declare const vendureProductTraits: ProductTraits;
20
+ declare const vendureProductTraits: ProductTraits<any>;
30
21
 
31
- /**
32
- * Vendure product sync implementation.
33
- *
34
- * Uses the Admin GraphQL API. Vendure uses offset-based pagination
35
- * with `take` and `skip` options.
36
- */
37
- declare const vendureProductSync: CollectionSync;
22
+ declare const vendureProductSync: CollectionSync<any>;
38
23
 
39
24
  type VendureProductCheckpoint = {
40
25
  skip: number;
41
26
  updatedAt: string;
27
+ passMax?: string;
28
+ passHighWater?: string;
29
+ passTotal?: number;
42
30
  };
43
31
  /**
44
32
  * Replication adapter for Vendure products.
45
33
  *
46
- * Implements pull (GraphQL query with offset pagination and updatedAt
47
- * filtering) and push (GraphQL updateProduct mutation). Designed for
48
- * use with RxDB's replicateRxCollection.
34
+ * Pull-only (GraphQL query with offset pagination and updatedAt filtering)
35
+ * for RxDB's replicateRxCollection. Catalogue data is server-owned; the
36
+ * POS never writes products.
49
37
  */
38
+ declare const createVendureProductReplication: (barcodeField?: string, updatedAtSkewMs?: number) => ReplicationAdapter<any, VendureProductCheckpoint>;
50
39
  declare const vendureProductReplication: ReplicationAdapter<any, VendureProductCheckpoint>;
51
40
 
41
+ /**
42
+ * Variant feed for Vendure products (ADR-060, decision 3).
43
+ *
44
+ * A variant price or stock edit bumps `ProductVariant.updatedAt` but not
45
+ * `Product.updatedAt`, so the product feed never sees it. This pull adapter
46
+ * pages changed variants with the same pass and high-water design as
47
+ * `createVendureProductReplication` and re-delivers their parent products,
48
+ * in the same document shape, into the `products` collection. It runs as a
49
+ * sub-adapter of the connector's combined `replication.products` adapter
50
+ * (`combinePullAdapters`), not as its own replication. Parents that no longer
51
+ * exist are skipped; deletions are the id reconcile's job.
52
+ *
53
+ * On a fresh install `seedCheckpoint` starts the cursor at the variant high
54
+ * water, read before the product feed's first pass, so the catalogue downloads
55
+ * once. An upgrade (a stored product checkpoint, none for this feed) is not
56
+ * seeded: its first pass re-delivers every product that has variants, once.
57
+ * That is deliberate: it heals any price or stock change the product feed
58
+ * missed before this feed existed.
59
+ *
60
+ * `variantPageSize` (the variant page `take`) is for tests and tuning.
61
+ */
62
+ declare const createVendureVariantFeedReplication: (barcodeField?: string, updatedAtSkewMs?: number, variantPageSize?: number) => ReplicationAdapter<any, VendureProductCheckpoint>;
63
+
64
+ /**
65
+ * Stock reconciler for Vendure products (ADR-060). Stock edits bump only the
66
+ * variant's updatedAt and allocations bump nothing, so replication misses them.
67
+ * Pages are keyed by variant id; each value is the variant's stockLevels.
68
+ */
69
+ declare const vendureStockReconcile: StockReconcileAdapter;
70
+
71
+ /**
72
+ * Reads the active channel's currency and tax-inclusivity (ADR-049), and the
73
+ * default tax zone's enabled, non-customer-group rates keyed by tax category
74
+ * id, in integer ppm rounded once. Read-only (ADR-048). Ignores `choice`:
75
+ * Vendure's channel is already chosen by the `vendure-token` header sent
76
+ * with every request, so there is no `pricingContext` either.
77
+ */
78
+ declare const vendureStoreSettings: (context: SyncContext, _choice?: StoreSettingsChoice) => Promise<StoreSettings>;
79
+
80
+ /**
81
+ * The channel-wide stock defaults an `INHERIT` variant falls back to
82
+ * (backlog 28). Read with `vendureGlobalStockSettings` after sign-in, like
83
+ * `pricesIncludeTax` from `storeSettings`.
84
+ */
85
+ declare function vendureGlobalStockSettings(context: SyncContext): Promise<{
86
+ trackInventory: boolean;
87
+ outOfStockThreshold: number;
88
+ }>;
89
+
52
90
  /**
53
91
  * Vendure connector for Tally UI.
54
92
  *
@@ -63,7 +101,21 @@ declare const vendureProductReplication: ReplicationAdapter<any, VendureProductC
63
101
  * <App />
64
102
  * </ConnectorProvider>
65
103
  * ```
104
+ *
105
+ * `pricesIncludeTax` must equal the POS tax setting (`TaxContext.pricesIncludeTax`);
106
+ * pass `settings.pricesIncludeTax` from `storeSettings`. `globalTrackInventory`
107
+ * and `globalOutOfStockThreshold` are the channel's stock defaults; read them
108
+ * with `vendureGlobalStockSettings` after sign-in, like `pricesIncludeTax`
109
+ * from `storeSettings`.
66
110
  */
111
+ declare const createVendureConnector: (options?: {
112
+ barcodeField?: string;
113
+ stockLocationId?: string;
114
+ pricesIncludeTax?: boolean;
115
+ updatedAtSkewMs?: number;
116
+ globalTrackInventory?: boolean;
117
+ globalOutOfStockThreshold?: number;
118
+ }) => TallyConnector;
67
119
  declare const vendureConnector: TallyConnector;
68
120
 
69
- export { vendureConnector, vendureProductReplication, vendureProductSchema, vendureProductSync, vendureProductTraits };
121
+ export { createVendureConnector, createVendureProductReplication, createVendureVariantFeedReplication, vendureAuth, vendureConnector, vendureGlobalStockSettings, vendureProductReplication, vendureProductSchema, vendureProductSync, vendureProductTraits, vendureSignIn, vendureStockReconcile, vendureStoreSettings };