@doswiftly/storefront-operations 1.0.5 → 1.0.6

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 CHANGED
@@ -1,6 +1,8 @@
1
1
  # @doswiftly/storefront-operations
2
2
 
3
- Pre-built GraphQL operations for DoSwiftly e-commerce storefronts. Contains ready-to-use queries, mutations, and fragments for products, collections, cart, checkout, and customer management.
3
+ Pre-built GraphQL operations and schema for DoSwiftly e-commerce storefronts. Contains the GraphQL schema file, ready-to-use queries, mutations, and fragments for products, collections, cart, checkout, and customer management.
4
+
5
+ **No running backend needed for codegen** — the schema is included as a file.
4
6
 
5
7
  ## Installation
6
8
 
@@ -24,13 +26,8 @@ npm install @doswiftly/storefront-operations @graphql-codegen/cli @graphql-codeg
24
26
  import { CodegenConfig } from "@graphql-codegen/cli";
25
27
 
26
28
  const config: CodegenConfig = {
27
- schema: {
28
- [process.env.NEXT_PUBLIC_STOREFRONT_API_URL!]: {
29
- headers: {
30
- "X-Shop-Slug": process.env.NEXT_PUBLIC_SHOP_SLUG!,
31
- },
32
- },
33
- },
29
+ // Schema from package — no running backend needed!
30
+ schema: "node_modules/@doswiftly/storefront-operations/schema.graphql",
34
31
  documents: [
35
32
  "node_modules/@doswiftly/storefront-operations/**/*.graphql",
36
33
  "src/**/*.{ts,tsx}", // Your custom operations (optional)
@@ -137,11 +134,16 @@ export function ProductList() {
137
134
  - `CustomerPasswordRecover` - Request password reset email
138
135
  - `CustomerPasswordReset` - Reset password with token
139
136
 
140
- ## Environment Variables
137
+ ## Schema
141
138
 
142
- ```env
143
- NEXT_PUBLIC_STOREFRONT_API_URL=https://api.doswiftly.pl/storefront/graphql
144
- NEXT_PUBLIC_SHOP_SLUG=your-shop-slug
139
+ The package includes `schema.graphql` — the full GraphQL schema auto-generated from the backend (NestJS code-first). This enables **offline codegen** without a running backend.
140
+
141
+ To update the schema after backend changes:
142
+
143
+ ```bash
144
+ # From monorepo root (requires backend to have been started at least once)
145
+ cd packages/@doswiftly/storefront-operations
146
+ pnpm run sync
145
147
  ```
146
148
 
147
149
  ## TypeScript Support
package/fragments.graphql CHANGED
@@ -34,10 +34,15 @@ fragment Money on Money {
34
34
  currencyCode
35
35
  }
36
36
 
37
- # Full price with conversion transparency (for price fields that support currency conversion)
38
- fragment PriceMoney on PriceMoney {
37
+ # Lightweight price for listing views (cards, grids, search results)
38
+ fragment Price on PriceMoney {
39
39
  amount
40
40
  currencyCode
41
+ }
42
+
43
+ # Full price with conversion transparency (for price fields that support currency conversion)
44
+ fragment PriceMoney on PriceMoney {
45
+ ...Price
41
46
  baseAmount
42
47
  baseCurrencyCode
43
48
  exchangeRate
@@ -84,37 +89,50 @@ fragment ProductVariant on ProductVariant {
84
89
  position
85
90
  }
86
91
 
87
- fragment ProductBase on Product {
92
+ # Minimal product data for listing views (cards, grids, search results).
93
+ # Matches template-local ProductCardFields for consistent typing.
94
+ fragment ProductCard on Product {
88
95
  id
89
96
  handle
90
97
  title
91
- description
92
- descriptionHtml
98
+ vendor
99
+ productType
100
+ availableForSale
101
+ averageRating
102
+ reviewCount
103
+ tags
93
104
  featuredImage {
94
105
  ...Image
95
106
  }
96
107
  priceRange {
97
108
  minVariantPrice {
98
- ...PriceMoney
109
+ ...Price
99
110
  }
100
111
  maxVariantPrice {
101
- ...PriceMoney
112
+ ...Price
102
113
  }
103
114
  }
104
- originalPriceRange {
115
+ compareAtPriceRange {
105
116
  minVariantPrice {
106
- ...Money
117
+ ...Price
107
118
  }
108
119
  maxVariantPrice {
109
- ...Money
120
+ ...Price
110
121
  }
111
122
  }
112
- compareAtPriceRange {
123
+ }
124
+
125
+ # Full product data for detail views and pages that need all fields.
126
+ fragment ProductBase on Product {
127
+ ...ProductCard
128
+ description
129
+ descriptionHtml
130
+ originalPriceRange {
113
131
  minVariantPrice {
114
- ...PriceMoney
132
+ ...Money
115
133
  }
116
134
  maxVariantPrice {
117
- ...PriceMoney
135
+ ...Money
118
136
  }
119
137
  }
120
138
  originalCompareAtPriceRange {
@@ -126,16 +144,10 @@ fragment ProductBase on Product {
126
144
  }
127
145
  }
128
146
  totalInventory
129
- vendor
130
- productType
131
147
  type
132
148
  collectRecipientInfo
133
- tags
134
149
  createdAt
135
150
  updatedAt
136
- averageRating
137
- reviewCount
138
- availableForSale
139
151
  }
140
152
 
141
153
  fragment ProductFull on Product {
@@ -225,7 +237,7 @@ fragment Customer on Customer {
225
237
  displayName
226
238
  phone
227
239
  emailVerified
228
- acceptsMarketing
240
+ emailMarketingState
229
241
  defaultAddress {
230
242
  ...MailingAddress
231
243
  }
@@ -252,43 +264,19 @@ fragment Order on Order {
252
264
  totalShipping {
253
265
  ...Money
254
266
  }
267
+ status
255
268
  financialStatus
256
269
  fulfillmentStatus
257
270
  processedAt
271
+ confirmedAt
272
+ cancelledAt
273
+ expiredAt
258
274
  shippingAddress {
259
275
  ...MailingAddress
260
276
  }
261
277
  lineItemsCount
262
278
  }
263
279
 
264
- # Order with shipments for tracking pages
265
- fragment OrderWithShipments on Order {
266
- id
267
- orderNumber
268
- totalPrice {
269
- ...Money
270
- }
271
- subtotalPrice {
272
- ...Money
273
- }
274
- totalTax {
275
- ...Money
276
- }
277
- totalShipping {
278
- ...Money
279
- }
280
- financialStatus
281
- fulfillmentStatus
282
- processedAt
283
- shippingAddress {
284
- ...MailingAddress
285
- }
286
- lineItemsCount
287
- shipments {
288
- ...Shipment
289
- }
290
- }
291
-
292
280
  # ============================================
293
281
  # Cart Fragments
294
282
  # ============================================
@@ -449,6 +437,22 @@ fragment ShopBranding on ShopBranding {
449
437
  }
450
438
  }
451
439
 
440
+ fragment BotProtectionProvider on BotProtectionProviderInfo {
441
+ provider
442
+ siteKey
443
+ scriptUrl
444
+ }
445
+
446
+ fragment BotProtection on BotProtectionInfo {
447
+ primary {
448
+ ...BotProtectionProvider
449
+ }
450
+ fallback {
451
+ ...BotProtectionProvider
452
+ }
453
+ protectedOperations
454
+ }
455
+
452
456
  fragment Shop on Shop {
453
457
  id
454
458
  name
@@ -457,6 +461,8 @@ fragment Shop on Shop {
457
461
  currencyCode
458
462
  supportedCurrencies
459
463
  paymentCurrencies
464
+ defaultLanguage
465
+ supportedLanguages
460
466
  logo {
461
467
  ...Image
462
468
  }
@@ -471,6 +477,9 @@ fragment Shop on Shop {
471
477
  branding {
472
478
  ...ShopBranding
473
479
  }
480
+ botProtection {
481
+ ...BotProtection
482
+ }
474
483
  }
475
484
 
476
485
  # ============================================
@@ -577,6 +586,9 @@ fragment CheckoutLineItem on CheckoutLineItem {
577
586
  variantId
578
587
  productId
579
588
  sku
589
+ image {
590
+ ...Image
591
+ }
580
592
  }
581
593
 
582
594
  # GAP-001: Gift Card Checkout Integration
@@ -797,17 +809,6 @@ fragment Return on Return {
797
809
  updatedAt
798
810
  }
799
811
 
800
- fragment ReturnBasic on Return {
801
- id
802
- returnNumber
803
- orderId
804
- orderNumber
805
- status
806
- reason
807
- createdAt
808
- updatedAt
809
- }
810
-
811
812
  fragment ReturnReasonOption on ReturnReasonOption {
812
813
  value
813
814
  label
@@ -1150,3 +1151,26 @@ fragment GenerateReferralCodePayload on GenerateReferralCodePayload {
1150
1151
  shareUrl
1151
1152
  userErrors
1152
1153
  }
1154
+
1155
+ # ============================================
1156
+ # Inventory Level Fragments (Multi-Warehouse)
1157
+ # ============================================
1158
+
1159
+ fragment InventoryLevel on InventoryLevel {
1160
+ locationId
1161
+ locationName
1162
+ locationType
1163
+ available
1164
+ onHand
1165
+ }
1166
+
1167
+ fragment VariantInventoryLevels on ProductVariant {
1168
+ id
1169
+ title
1170
+ sku
1171
+ available
1172
+ quantityAvailable
1173
+ inventoryLevels {
1174
+ ...InventoryLevel
1175
+ }
1176
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@doswiftly/storefront-operations",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "description": "GraphQL operations for DoSwiftly Storefront - SSOT from backend",
5
5
  "homepage": "https://doswiftly.pl",
6
6
  "publishConfig": {
@@ -8,6 +8,7 @@
8
8
  },
9
9
  "main": "index.js",
10
10
  "exports": {
11
+ "./schema.graphql": "./schema.graphql",
11
12
  "./queries.graphql": "./queries.graphql",
12
13
  "./mutations.graphql": "./mutations.graphql",
13
14
  "./fragments.graphql": "./fragments.graphql",
@@ -27,6 +28,7 @@
27
28
  "author": "DoSwiftly Team",
28
29
  "license": "MIT",
29
30
  "files": [
31
+ "schema.graphql",
30
32
  "queries.graphql",
31
33
  "mutations.graphql",
32
34
  "fragments.graphql",
package/queries.graphql CHANGED
@@ -34,7 +34,7 @@ query Products(
34
34
  products(first: $first, after: $after, query: $query, sortKey: $sortKey, reverse: $reverse, filters: $filters) {
35
35
  edges {
36
36
  node {
37
- ...ProductBase
37
+ ...ProductCard
38
38
  }
39
39
  cursor
40
40
  }
@@ -49,7 +49,7 @@ query ProductSearch($query: String!, $first: Int = 20, $after: String, $filters:
49
49
  products(query: $query, first: $first, after: $after, filters: $filters) {
50
50
  edges {
51
51
  node {
52
- ...ProductBase
52
+ ...ProductCard
53
53
  }
54
54
  cursor
55
55
  }
@@ -70,7 +70,7 @@ query Collection($id: ID, $handle: String, $productsFirst: Int = 20, $productsAf
70
70
  products(first: $productsFirst, after: $productsAfter) {
71
71
  edges {
72
72
  node {
73
- ...ProductBase
73
+ ...ProductCard
74
74
  }
75
75
  cursor
76
76
  }
@@ -82,8 +82,8 @@ query Collection($id: ID, $handle: String, $productsFirst: Int = 20, $productsAf
82
82
  }
83
83
  }
84
84
 
85
- query Collections($first: Int = 20, $after: String, $sortKey: CollectionSortKeys = TITLE, $reverse: Boolean = false) {
86
- collections(first: $first, after: $after, sortKey: $sortKey, reverse: $reverse) {
85
+ query Collections($first: Int = 20, $after: String, $query: String, $sortKey: CollectionSortKeys = TITLE, $reverse: Boolean = false) {
86
+ collections(first: $first, after: $after, query: $query, sortKey: $sortKey, reverse: $reverse) {
87
87
  edges {
88
88
  node {
89
89
  ...Collection
@@ -163,6 +163,21 @@ query Customer($customerAccessToken: String!) {
163
163
  }
164
164
  }
165
165
 
166
+ # Lightweight customer profile query (no orders, no addresses list)
167
+ # Use for settings/profile pages that only need basic customer info.
168
+ query CustomerProfile($customerAccessToken: String!) {
169
+ customer(customerAccessToken: $customerAccessToken) {
170
+ ...Customer
171
+ }
172
+ }
173
+
174
+ # Single order query — more efficient than fetching all customer data
175
+ query CustomerOrder($orderId: ID!, $customerAccessToken: String!) {
176
+ customerOrder(orderId: $orderId, customerAccessToken: $customerAccessToken) {
177
+ ...Order
178
+ }
179
+ }
180
+
166
181
  # ============================================
167
182
  # Checkout
168
183
  # ============================================