@doswiftly/storefront-operations 8.0.0 → 10.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/mutations.graphql CHANGED
@@ -67,9 +67,9 @@ mutation CartRemoveLines($id: ID!, $lineIds: [ID!]!) {
67
67
  }
68
68
  }
69
69
 
70
- # Replaces (NOT appends) the cart's discount codes with the given list. Pass `[]` to clear all codes. Each code is validated against `discounts` table (existence, active status); invalid codes appear in `userErrors[]` as `DISCOUNT_CODE_INVALID`. Triggers cart re-pricing — discount allocations are recomputed and stored in `cart.discountAmount`.
71
- mutation CartApplyDiscountCodes($id: ID!, $discountCodes: [String!]!) {
72
- cartApplyDiscountCodes(id: $id, discountCodes: $discountCodes) {
70
+ # Replaces (NOT appends) the cart's discount codes with the given list. Pass `[]` to clear all codes. Each code is validated against the discounts table (existence, active status); invalid codes appear in `userErrors[]` as `DISCOUNT_CODE_INVALID`. Triggers cart re-pricing — discount allocations are recomputed and stored in `cart.discountAmount`. Single canonical replace-all entry point — prior append/single-remove variants were removed in favor of this explicit caller-controlled list semantics.
71
+ mutation CartDiscountCodesUpdate($id: ID!, $discountCodes: [String!]!) {
72
+ cartDiscountCodesUpdate(id: $id, discountCodes: $discountCodes) {
73
73
  cart {
74
74
  ...Cart
75
75
  }
@@ -276,183 +276,133 @@ mutation CustomerResetPassword($token: String!, $newPassword: String!) {
276
276
  }
277
277
 
278
278
  # ============================================
279
- # Checkout Mutations
279
+ # Cart Completion Mutations
280
280
  # ============================================
281
-
282
- # Creates a new checkout session for the given cart (or a fresh cart if `cartId` is omitted). Inherits applied discounts and gift cards from the cart by reference (not snapshot). Errors: `CART_NOT_FOUND`, `EMPTY_CART`, `ALREADY_COMPLETED` (cart already converted to order). NOT idempotent — multiple calls create multiple checkouts.
283
- mutation CheckoutCreate($input: CheckoutCreateInput!) {
284
- checkoutCreate(input: $input) {
285
- checkout {
286
- ...Checkout
281
+ #
282
+ # Phase 3 unify-cart-graphql-surface: wszystkie fulfillment + payment + completion
283
+ # operations teraz na Cart aggregate (zamiast Checkout dual-aggregate). Klient
284
+ # robi typowy checkout flow: cart create/add items → setShipping/Billing/Method
285
+ # → selectPayment → (optional) applyGiftCard → cartComplete → Order created.
286
+
287
+ # Sets the shipping address on the cart (full replace, not patch). Triggers cart re-pricing (tax recalculation per address country/region). Address format validated against `CartAddressInput` constraints (firstName/lastName/streetLine1/city/country/postalCode required). Errors: `INVALID_ADDRESS`, `CART_NOT_FOUND`.
288
+ mutation CartSetShippingAddress($input: CartSetShippingAddressInput!) {
289
+ cartSetShippingAddress(input: $input) {
290
+ cart {
291
+ ...Cart
287
292
  }
288
293
  userErrors {
289
294
  ...UserError
290
295
  }
291
- }
292
- }
293
-
294
- # Sets the shipping address (full replace, not patch). Triggers cart re-pricing. Address format is NOT validated here — full validation runs at `checkoutComplete`.
295
- mutation CheckoutUpdateShippingAddress($id: ID!, $shippingAddress: CheckoutAddressInput!) {
296
- checkoutUpdateShippingAddress(id: $id, shippingAddress: $shippingAddress) {
297
- checkout {
298
- ...Checkout
299
- }
300
- userErrors {
301
- ...UserError
296
+ warnings {
297
+ ...CartWarning
302
298
  }
303
299
  }
304
300
  }
305
301
 
306
- # Sets the billing address (full replace). Independent of shipping address — pass it explicitly even when "billing same as shipping".
307
- mutation CheckoutUpdateBillingAddress($id: ID!, $billingAddress: CheckoutAddressInput!) {
308
- checkoutUpdateBillingAddress(id: $id, billingAddress: $billingAddress) {
309
- checkout {
310
- ...Checkout
302
+ # Sets the billing address on the cart (full replace). Independent of shipping address — pass it explicitly even when "billing same as shipping". Errors: `INVALID_ADDRESS`, `CART_NOT_FOUND`.
303
+ mutation CartSetBillingAddress($input: CartSetBillingAddressInput!) {
304
+ cartSetBillingAddress(input: $input) {
305
+ cart {
306
+ ...Cart
311
307
  }
312
308
  userErrors {
313
309
  ...UserError
314
310
  }
315
- }
316
- }
317
-
318
- # Sets or updates the contact email on the checkout (used for guest checkout, order confirmation, and tracking emails). Validated against a regex; returns `INVALID` for malformed format.
319
- mutation CheckoutUpdateEmail($id: ID!, $email: String!) {
320
- checkoutUpdateEmail(id: $id, email: $email) {
321
- checkout {
322
- ...Checkout
323
- }
324
- userErrors {
325
- ...UserError
311
+ warnings {
312
+ ...CartWarning
326
313
  }
327
314
  }
328
315
  }
329
316
 
330
- # Selects a shipping method by `rateId` (a stable shipping-method UUID, NOT an opaque per-request token). The id comes from `availableShippingMethods` query, computed for the current address + cart subtotal at request time.
331
- mutation CheckoutSelectShippingRate($id: ID!, $rateId: String!) {
332
- checkoutSelectShippingRate(id: $id, rateId: $rateId) {
333
- checkout {
334
- ...Checkout
317
+ # Selects a shipping method by `shippingMethodId` (typed `ID!`, a stable shipping-method UUID NOT a per-request token). The id comes from a list of methods available for the current address + cart subtotal (queryable separately). Errors: `SHIPPING_METHOD_REQUIRED`, `ZIP_CODE_NOT_SUPPORTED`, `CART_NOT_FOUND`.
318
+ mutation CartSelectShippingMethod($input: CartSelectShippingMethodInput!) {
319
+ cartSelectShippingMethod(input: $input) {
320
+ cart {
321
+ ...Cart
335
322
  }
336
323
  userErrors {
337
324
  ...UserError
338
325
  }
326
+ warnings {
327
+ ...CartWarning
328
+ }
339
329
  }
340
330
  }
341
331
 
342
- # Appends a discount code to the cart's `discount_codes` array. Note: while multiple codes can be stored, the pricing engine currently uses **only the first applied code** — codes do not stack. Validated for existence, active status, and customer usage limits.
343
- mutation CheckoutApplyDiscountCode($id: ID!, $discountCode: String!) {
344
- checkoutApplyDiscountCode(id: $id, discountCode: $discountCode) {
345
- checkout {
346
- ...Checkout
332
+ # Selects a payment method by `paymentMethodId` (UUID from `availablePaymentMethods` query). Validates existence + active status; no pre-authorization performed here. Errors: `PAYMENT_METHOD_REQUIRED`, `INVALID_PAYMENT`, `CART_NOT_FOUND`.
333
+ mutation CartSelectPaymentMethod($input: CartSelectPaymentMethodInput!) {
334
+ cartSelectPaymentMethod(input: $input) {
335
+ cart {
336
+ ...Cart
347
337
  }
348
338
  userErrors {
349
339
  ...UserError
350
340
  }
341
+ warnings {
342
+ ...CartWarning
343
+ }
351
344
  }
352
345
  }
353
346
 
354
- # Removes a code from the cart's `discount_codes` array (filters by exact match). Triggers re-pricing.
355
- mutation CheckoutRemoveDiscountCode($id: ID!, $discountCode: String!) {
356
- checkoutRemoveDiscountCode(id: $id, discountCode: $discountCode) {
357
- checkout {
358
- ...Checkout
347
+ # Applies a gift card to the cart, stackable with discount codes. Consumption is FIFO: each card consumes `min(remainingBalance, paymentDue)` against the current cart total in the order they were applied. The gift card balance is NOT debited yet — actual deduction happens atomically at `cartComplete`. Errors: `GIFT_CARD_NOT_FOUND`, `GIFT_CARD_DEPLETED`, `GIFT_CARD_UNUSABLE`.
348
+ mutation CartApplyGiftCard($input: CartApplyGiftCardInput!) {
349
+ cartApplyGiftCard(input: $input) {
350
+ cart {
351
+ ...Cart
359
352
  }
360
353
  userErrors {
361
354
  ...UserError
362
355
  }
356
+ warnings {
357
+ ...CartWarning
358
+ }
363
359
  }
364
360
  }
365
361
 
366
- # READ-ONLY validation of a discount code against the current checkout does NOT modify state. Returns `{ isValid, discount, error }` for previewing the effect (e.g. inline UI feedback as the user types).
367
- mutation CheckoutValidateDiscountCode($id: ID!, $discountCode: String!) {
368
- checkoutValidateDiscountCode(id: $id, discountCode: $discountCode) {
369
- result {
370
- isValid
371
- discount {
372
- code
373
- title
374
- type
375
- value
376
- discountAmount {
377
- amount
378
- currencyCode
379
- }
380
- }
381
- error {
382
- code
383
- message
384
- }
362
+ # Removes a gift card from the applied list and recalculates FIFO `appliedAmount` for the remaining cards. Since gift card balances are only debited at `cartComplete`, removing before completion has no effect on the underlying gift card balance.
363
+ mutation CartRemoveGiftCard($input: CartRemoveGiftCardInput!) {
364
+ cartRemoveGiftCard(input: $input) {
365
+ cart {
366
+ ...Cart
385
367
  }
386
368
  userErrors {
387
369
  ...UserError
388
370
  }
371
+ warnings {
372
+ ...CartWarning
373
+ }
389
374
  }
390
375
  }
391
376
 
392
- # Selects a payment method by `paymentMethodId` (UUID from `availablePaymentMethods` query). Validates existence and active status; no pre-authorization is performed here.
393
- mutation CheckoutSelectPaymentMethod($id: ID!, $paymentMethodId: ID!) {
394
- checkoutSelectPaymentMethod(id: $id, paymentMethodId: $paymentMethodId) {
395
- checkout {
396
- ...Checkout
377
+ # Sets per-line-item recipient details (name, email, message) for digital gift card products in the cart (line items where the variant represents a gift-card SKU). Required before `cartComplete` for any line item with a gift-card variant. Recipient details propagated to the resulting order.
378
+ mutation CartUpdateGiftCardRecipient($input: CartUpdateGiftCardRecipientInput!) {
379
+ cartUpdateGiftCardRecipient(input: $input) {
380
+ cart {
381
+ ...Cart
397
382
  }
398
383
  userErrors {
399
384
  ...UserError
400
385
  }
386
+ warnings {
387
+ ...CartWarning
388
+ }
401
389
  }
402
390
  }
403
391
 
404
- # Finalizes the checkout: creates the `Order`, deducts gift cards, sends order-created confirmation — all atomically. **Idempotent on `idempotencyKey`** (NOT on the checkout `id`); auto-generated if the caller omits it. The `paymentUrl` field is reserved but is NOT populated here — for hosted gateways (PayU, P24) the storefront calls a separate `paymentCreate` mutation after this returns.
405
- mutation CheckoutComplete($id: ID!, $input: CheckoutCompleteInput) {
406
- checkoutComplete(id: $id, input: $input) {
407
- checkout {
408
- ...Checkout
392
+ # Finalizes the cart creates the `Order`, deducts gift cards, sends order-created confirmation — all atomically. **Idempotent on `idempotencyKey`** (auto-generated from cartId + minute timestamp if caller omits it). Returns `order` field after completion. Note: `paymentUrl` is intentionally NOT in payload — for hosted gateways (online providers) the storefront calls a separate `paymentCreate` mutation after this returns (check `order.canCreatePayment` first). Errors: `EMAIL_REQUIRED`, `SHIPPING_ADDRESS_REQUIRED`, `SHIPPING_METHOD_REQUIRED`, `PAYMENT_METHOD_REQUIRED`, `INSUFFICIENT_STOCK`, `ALREADY_COMPLETED`.
393
+ mutation CartComplete($input: CartCompleteInput!) {
394
+ cartComplete(input: $input) {
395
+ cart {
396
+ ...Cart
409
397
  }
410
398
  order {
411
399
  ...Order
412
400
  }
413
- paymentUrl
414
- userErrors {
415
- ...UserError
416
- }
417
- }
418
- }
419
-
420
- # ============================================
421
- # Gift Card Checkout Mutations
422
- # ============================================
423
-
424
- # Applies a gift card to the cart, stackable with discount codes. Consumption is FIFO: each card consumes `min(remainingBalance, paymentDue)` against the current cart total in the order they were applied. The gift card balance is NOT debited yet — actual deduction happens atomically at `checkoutComplete`. Errors: `GIFT_CARD_NOT_FOUND`, `GIFT_CARD_DEPLETED`, `GIFT_CARD_UNUSABLE`, `GIFT_CARD_ALREADY_APPLIED`.
425
- mutation CheckoutApplyGiftCard($id: ID!, $giftCardCode: String!) {
426
- checkoutApplyGiftCard(id: $id, giftCardCode: $giftCardCode) {
427
- checkout {
428
- ...Checkout
429
- }
430
- userErrors {
431
- ...UserError
432
- }
433
- }
434
- }
435
-
436
- # Removes a gift card from the applied list and recalculates FIFO `appliedAmount` for the remaining cards. Since gift card balances are only debited at `checkoutComplete`, removing before completion has no effect on the underlying gift card balance.
437
- mutation CheckoutRemoveGiftCard($id: ID!, $giftCardCode: String!) {
438
- checkoutRemoveGiftCard(id: $id, giftCardCode: $giftCardCode) {
439
- checkout {
440
- ...Checkout
441
- }
442
401
  userErrors {
443
402
  ...UserError
444
403
  }
445
- }
446
- }
447
-
448
- # Sets per-line-item recipient details (name, email, message, delivery date) for digital gift card products in the cart (variants with `type: GIFT_CARD`). Required before `checkoutComplete` for any line item with a gift-card variant. Recipient details are associated with each gift-card line item and propagated to the resulting order.
449
- mutation CheckoutUpdateGiftCardRecipient($input: CheckoutGiftCardRecipientInput!) {
450
- checkoutUpdateGiftCardRecipient(input: $input) {
451
- checkout {
452
- ...Checkout
453
- }
454
- userErrors {
455
- ...UserError
404
+ warnings {
405
+ ...CartWarning
456
406
  }
457
407
  }
458
408
  }