@zoxllc/shopify-checkout-extensions 0.0.4 → 0.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zoxllc/shopify-checkout-extensions",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "description": "ZOX helper lib for shopify checkout extensions",
5
5
  "main": "src/index.ts",
6
6
  "directories": {
@@ -9,11 +9,7 @@ import type {
9
9
  StringComparisonType,
10
10
  } from './Qualifier';
11
11
  import type { MatchType, Selector } from './Selector';
12
- import { ConditionalDiscount } from '../lineItem/ConditionalDiscount';
13
- import { FixedItemDiscount } from '../lineItem/FixedItemDiscount';
14
- import { PercentageDiscount } from '../lineItem/PercentageDiscount';
15
12
  import { AndSelector } from './AndSelector';
16
- import { BuyXGetY } from '../lineItem/BuyXGetY';
17
13
  import {
18
14
  type CartAmountBehavior,
19
15
  CartAmountQualifier,
@@ -33,11 +29,17 @@ import {
33
29
  SaleItemSelector,
34
30
  type SaleItemSelectorMatchType,
35
31
  } from './SaleItemSelector';
32
+
33
+ import { ConditionalDiscount } from '../lineItem/ConditionalDiscount';
34
+ import { FixedItemDiscount } from '../lineItem/FixedItemDiscount';
35
+ import { PercentageDiscount } from '../lineItem/PercentageDiscount';
36
+ import { BuyXGetY } from '../lineItem/BuyXGetY';
37
+
36
38
  import { SubscriptionItemSelector } from './SubscriptionItemSelector';
37
- import { RateNameSelector } from '~/shipping/RateNameSelector';
38
- import { FixedDiscount } from '~/shipping/FixedDiscount';
39
- import { ShippingDiscount } from '~/shipping/ShippingDiscount';
40
39
  import { CountryCodeQualifier } from './CountryCodeQualifier';
40
+ import { RateNameSelector } from '../shipping/RateNameSelector';
41
+ import { FixedDiscount } from '../shipping/FixedDiscount';
42
+ import { ShippingDiscount } from '../shipping/ShippingDiscount';
41
43
 
42
44
  export type InputConfig = {
43
45
  __type: string;
@@ -32,8 +32,8 @@ export class CountryCodeQualifier extends Qualifier {
32
32
  discountCart.cart.deliveryGroups.filter(
33
33
  (deliveryGroup) => {
34
34
  const countryCode =
35
- // @ts-ignore
36
- deliveryGroup.deliveryAddress.countryCode.toLowerCase();
35
+ deliveryGroup?.deliveryAddress?.countryCode?.toLowerCase() ||
36
+ '';
37
37
 
38
38
  return this.countryCodes.includes(countryCode);
39
39
  }
@@ -1,15 +1,8 @@
1
1
  export type Maybe<T> = T | null;
2
2
  export type InputMaybe<T> = Maybe<T>;
3
- export type Exact<T extends { [key: string]: unknown }> = {
4
- [K in keyof T]: T[K];
5
- };
6
- export type MakeOptional<T, K extends keyof T> = Omit<
7
- T,
8
- K
9
- > & { [SubKey in K]?: Maybe<T[SubKey]> };
10
- export type MakeMaybe<T, K extends keyof T> = Omit<T, K> & {
11
- [SubKey in K]: Maybe<T[SubKey]>;
12
- };
3
+ export type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };
4
+ export type MakeOptional<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]?: Maybe<T[SubKey]> };
5
+ export type MakeMaybe<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]: Maybe<T[SubKey]> };
13
6
  /** All built-in and custom scalars, mapped to their actual values */
14
7
  export type Scalars = {
15
8
  ID: string;
@@ -98,6 +91,7 @@ export type Cart = {
98
91
  lines: Array<CartLine>;
99
92
  };
100
93
 
94
+
101
95
  /** A cart represents the merchandise that a buyer intends to purchase, and the cost associated with the cart. */
102
96
  export type CartAttributeArgs = {
103
97
  key?: InputMaybe<Scalars['String']>;
@@ -172,6 +166,7 @@ export type CartLine = {
172
166
  sellingPlanAllocation?: Maybe<SellingPlanAllocation>;
173
167
  };
174
168
 
169
+
175
170
  /** Represents information about the merchandise in the cart. */
176
171
  export type CartLineAttributeArgs = {
177
172
  key?: InputMaybe<Scalars['String']>;
@@ -216,6 +211,7 @@ export type Company = HasMetafields & {
216
211
  updatedAt: Scalars['DateTime'];
217
212
  };
218
213
 
214
+
219
215
  /** Represents information about a company which is also a customer of the shop. */
220
216
  export type CompanyMetafieldArgs = {
221
217
  key: Scalars['String'];
@@ -268,6 +264,7 @@ export type CompanyLocation = HasMetafields & {
268
264
  updatedAt: Scalars['DateTime'];
269
265
  };
270
266
 
267
+
271
268
  /** A company's location. */
272
269
  export type CompanyLocationMetafieldArgs = {
273
270
  key: Scalars['String'];
@@ -777,7 +774,7 @@ export enum CountryCode {
777
774
  /** Zimbabwe. */
778
775
  Zw = 'ZW',
779
776
  /** Unknown Region. */
780
- Zz = 'ZZ',
777
+ Zz = 'ZZ'
781
778
  }
782
779
 
783
780
  /**
@@ -1116,7 +1113,7 @@ export enum CurrencyCode {
1116
1113
  /** South African Rand (ZAR). */
1117
1114
  Zar = 'ZAR',
1118
1115
  /** Zambian Kwacha (ZMW). */
1119
- Zmw = 'ZMW',
1116
+ Zmw = 'ZMW'
1120
1117
  }
1121
1118
 
1122
1119
  /** A custom product. */
@@ -1162,16 +1159,19 @@ export type Customer = HasMetafields & {
1162
1159
  numberOfOrders: Scalars['Int'];
1163
1160
  };
1164
1161
 
1162
+
1165
1163
  /** Represents a customer with the shop. */
1166
1164
  export type CustomerHasAnyTagArgs = {
1167
1165
  tags?: Array<Scalars['String']>;
1168
1166
  };
1169
1167
 
1168
+
1170
1169
  /** Represents a customer with the shop. */
1171
1170
  export type CustomerHasTagsArgs = {
1172
1171
  tags?: Array<Scalars['String']>;
1173
1172
  };
1174
1173
 
1174
+
1175
1175
  /** Represents a customer with the shop. */
1176
1176
  export type CustomerMetafieldArgs = {
1177
1177
  key: Scalars['String'];
@@ -1195,6 +1195,7 @@ export type DeliverableCartLine = {
1195
1195
  quantity: Scalars['Int'];
1196
1196
  };
1197
1197
 
1198
+
1198
1199
  /** Represents information about the merchandise in the cart. */
1199
1200
  export type DeliverableCartLineAttributeArgs = {
1200
1201
  key?: InputMaybe<Scalars['String']>;
@@ -1219,7 +1220,7 @@ export enum DeliveryMethod {
1219
1220
  /** Retail. */
1220
1221
  Retail = 'RETAIL',
1221
1222
  /** Shipping. */
1222
- Shipping = 'SHIPPING',
1223
+ Shipping = 'SHIPPING'
1223
1224
  }
1224
1225
 
1225
1226
  /** The target delivery option. */
@@ -1245,6 +1246,7 @@ export type DiscountNode = HasMetafields & {
1245
1246
  metafield?: Maybe<Metafield>;
1246
1247
  };
1247
1248
 
1249
+
1248
1250
  /** A discount wrapper node. */
1249
1251
  export type DiscountNodeMetafieldArgs = {
1250
1252
  key: Scalars['String'];
@@ -1279,6 +1281,7 @@ export type HasMetafields = {
1279
1281
  metafield?: Maybe<Metafield>;
1280
1282
  };
1281
1283
 
1284
+
1282
1285
  /** Represents information about the metafields associated to the specified resource. */
1283
1286
  export type HasMetafieldsMetafieldArgs = {
1284
1287
  key: Scalars['String'];
@@ -1591,7 +1594,7 @@ export enum LanguageCode {
1591
1594
  /** Chinese (Traditional). */
1592
1595
  ZhTw = 'ZH_TW',
1593
1596
  /** Zulu. */
1594
- Zu = 'ZU',
1597
+ Zu = 'ZU'
1595
1598
  }
1596
1599
 
1597
1600
  /** Represents limited information about the current time relative to the parent object. */
@@ -1613,32 +1616,38 @@ export type LocalTime = {
1613
1616
  timeBetween: Scalars['Boolean'];
1614
1617
  };
1615
1618
 
1619
+
1616
1620
  /** Represents limited information about the current time relative to the parent object. */
1617
1621
  export type LocalTimeDateTimeAfterArgs = {
1618
1622
  dateTime: Scalars['DateTimeWithoutTimezone'];
1619
1623
  };
1620
1624
 
1625
+
1621
1626
  /** Represents limited information about the current time relative to the parent object. */
1622
1627
  export type LocalTimeDateTimeBeforeArgs = {
1623
1628
  dateTime: Scalars['DateTimeWithoutTimezone'];
1624
1629
  };
1625
1630
 
1631
+
1626
1632
  /** Represents limited information about the current time relative to the parent object. */
1627
1633
  export type LocalTimeDateTimeBetweenArgs = {
1628
1634
  endDateTime: Scalars['DateTimeWithoutTimezone'];
1629
1635
  startDateTime: Scalars['DateTimeWithoutTimezone'];
1630
1636
  };
1631
1637
 
1638
+
1632
1639
  /** Represents limited information about the current time relative to the parent object. */
1633
1640
  export type LocalTimeTimeAfterArgs = {
1634
1641
  time: Scalars['TimeWithoutTimezone'];
1635
1642
  };
1636
1643
 
1644
+
1637
1645
  /** Represents limited information about the current time relative to the parent object. */
1638
1646
  export type LocalTimeTimeBeforeArgs = {
1639
1647
  time: Scalars['TimeWithoutTimezone'];
1640
1648
  };
1641
1649
 
1650
+
1642
1651
  /** Represents limited information about the current time relative to the parent object. */
1643
1652
  export type LocalTimeTimeBetweenArgs = {
1644
1653
  endTime: Scalars['TimeWithoutTimezone'];
@@ -1709,6 +1718,7 @@ export type Market = HasMetafields & {
1709
1718
  regions: Array<MarketRegion>;
1710
1719
  };
1711
1720
 
1721
+
1712
1722
  /**
1713
1723
  * A market is a group of one or more regions that you want to target for international sales.
1714
1724
  * By creating a market, you can configure a distinct, localized shopping experience for
@@ -1780,11 +1790,13 @@ export type MutationRoot = {
1780
1790
  run: Scalars['Void'];
1781
1791
  };
1782
1792
 
1793
+
1783
1794
  /** The root mutation for the API. */
1784
1795
  export type MutationRootHandleResultArgs = {
1785
1796
  result: FunctionResult;
1786
1797
  };
1787
1798
 
1799
+
1788
1800
  /** The root mutation for the API. */
1789
1801
  export type MutationRootRunArgs = {
1790
1802
  result: FunctionRunResult;
@@ -1827,26 +1839,31 @@ export type Product = HasMetafields & {
1827
1839
  vendor?: Maybe<Scalars['String']>;
1828
1840
  };
1829
1841
 
1842
+
1830
1843
  /** Represents a product. */
1831
1844
  export type ProductHasAnyTagArgs = {
1832
1845
  tags?: Array<Scalars['String']>;
1833
1846
  };
1834
1847
 
1848
+
1835
1849
  /** Represents a product. */
1836
1850
  export type ProductHasTagsArgs = {
1837
1851
  tags?: Array<Scalars['String']>;
1838
1852
  };
1839
1853
 
1854
+
1840
1855
  /** Represents a product. */
1841
1856
  export type ProductInAnyCollectionArgs = {
1842
1857
  ids?: Array<Scalars['ID']>;
1843
1858
  };
1844
1859
 
1860
+
1845
1861
  /** Represents a product. */
1846
1862
  export type ProductInCollectionsArgs = {
1847
1863
  ids?: Array<Scalars['ID']>;
1848
1864
  };
1849
1865
 
1866
+
1850
1867
  /** Represents a product. */
1851
1868
  export type ProductMetafieldArgs = {
1852
1869
  key: Scalars['String'];
@@ -1874,6 +1891,7 @@ export type ProductVariant = HasMetafields & {
1874
1891
  weightUnit: WeightUnit;
1875
1892
  };
1876
1893
 
1894
+
1877
1895
  /** Represents a product variant. */
1878
1896
  export type ProductVariantMetafieldArgs = {
1879
1897
  key: Scalars['String'];
@@ -1954,6 +1972,7 @@ export type Shop = HasMetafields & {
1954
1972
  metafield?: Maybe<Metafield>;
1955
1973
  };
1956
1974
 
1975
+
1957
1976
  /** Information about the shop. */
1958
1977
  export type ShopMetafieldArgs = {
1959
1978
  key: Scalars['String'];
@@ -1963,23 +1982,16 @@ export type ShopMetafieldArgs = {
1963
1982
  /** The target of the discount. */
1964
1983
  export type Target =
1965
1984
  /** The target delivery group. */
1966
- | {
1967
- deliveryGroup: DeliveryGroupTarget;
1968
- deliveryOption?: never;
1969
- } /** The target delivery option. */
1970
- | {
1971
- deliveryGroup?: never;
1972
- deliveryOption: DeliveryOptionTarget;
1973
- };
1985
+ { deliveryGroup: DeliveryGroupTarget; deliveryOption?: never; }
1986
+ | /** The target delivery option. */
1987
+ { deliveryGroup?: never; deliveryOption: DeliveryOptionTarget; };
1974
1988
 
1975
1989
  /** The discount value. */
1976
1990
  export type Value =
1977
1991
  /** A fixed amount value. */
1978
- | {
1979
- fixedAmount: FixedAmount;
1980
- percentage?: never;
1981
- } /** A percentage value. */
1982
- | { fixedAmount?: never; percentage: Percentage };
1992
+ { fixedAmount: FixedAmount; percentage?: never; }
1993
+ | /** A percentage value. */
1994
+ { fixedAmount?: never; percentage: Percentage; };
1983
1995
 
1984
1996
  /** Units of measurement for weight. */
1985
1997
  export enum WeightUnit {
@@ -1990,108 +2002,13 @@ export enum WeightUnit {
1990
2002
  /** Imperial system unit of mass. */
1991
2003
  Ounces = 'OUNCES',
1992
2004
  /** 1 pound equals 16 ounces. */
1993
- Pounds = 'POUNDS',
2005
+ Pounds = 'POUNDS'
1994
2006
  }
1995
2007
 
1996
2008
  export type RunInputVariables = Exact<{
1997
- customerTags?: InputMaybe<
1998
- Array<Scalars['String']> | Scalars['String']
1999
- >;
2000
- productCollectionIds?: InputMaybe<
2001
- Array<Scalars['ID']> | Scalars['ID']
2002
- >;
2009
+ customerTags?: InputMaybe<Array<Scalars['String']> | Scalars['String']>;
2010
+ productCollectionIds?: InputMaybe<Array<Scalars['ID']> | Scalars['ID']>;
2003
2011
  }>;
2004
2012
 
2005
- export type RunInput = {
2006
- __typename?: 'Input';
2007
- cart: {
2008
- __typename?: 'Cart';
2009
- buyerIdentity?: {
2010
- __typename?: 'BuyerIdentity';
2011
- customer?: {
2012
- __typename?: 'Customer';
2013
- email?: string | null;
2014
- hasTags: Array<{
2015
- __typename?: 'HasTagResponse';
2016
- tag: string;
2017
- hasTag: boolean;
2018
- }>;
2019
- } | null;
2020
- } | null;
2021
- cost: {
2022
- __typename?: 'CartCost';
2023
- subtotalAmount: {
2024
- __typename?: 'MoneyV2';
2025
- amount: any;
2026
- };
2027
- };
2028
- lines: Array<{
2029
- __typename?: 'CartLine';
2030
- quantity: number;
2031
- cost: {
2032
- __typename?: 'CartLineCost';
2033
- amountPerQuantity: {
2034
- __typename?: 'MoneyV2';
2035
- amount: any;
2036
- };
2037
- subtotalAmount: {
2038
- __typename?: 'MoneyV2';
2039
- amount: any;
2040
- };
2041
- totalAmount: {
2042
- __typename?: 'MoneyV2';
2043
- amount: any;
2044
- };
2045
- compareAtAmountPerQuantity?: {
2046
- __typename?: 'MoneyV2';
2047
- amount: any;
2048
- } | null;
2049
- };
2050
- sellingPlanAllocation?: {
2051
- __typename?: 'SellingPlanAllocation';
2052
- sellingPlan: {
2053
- __typename?: 'SellingPlan';
2054
- id: string;
2055
- };
2056
- } | null;
2057
- merchandise:
2058
- | { __typename: 'CustomProduct' }
2059
- | {
2060
- __typename: 'ProductVariant';
2061
- id: string;
2062
- product: {
2063
- __typename?: 'Product';
2064
- id: string;
2065
- productType?: string | null;
2066
- inAnyCollection: boolean;
2067
- hasTags: Array<{
2068
- __typename?: 'HasTagResponse';
2069
- tag: string;
2070
- hasTag: boolean;
2071
- }>;
2072
- };
2073
- };
2074
- }>;
2075
- deliveryGroups: Array<{
2076
- __typename?: 'CartDeliveryGroup';
2077
- deliveryOptions: Array<{
2078
- __typename?: 'CartDeliveryOption';
2079
- title?: string | null;
2080
- handle: any;
2081
- code?: string | null;
2082
- cost: {
2083
- __typename?: 'MoneyV2';
2084
- amount: any;
2085
- currencyCode: CurrencyCode;
2086
- };
2087
- }>;
2088
- }>;
2089
- };
2090
- discountNode: {
2091
- __typename?: 'DiscountNode';
2092
- metafield?: {
2093
- __typename?: 'Metafield';
2094
- value: string;
2095
- } | null;
2096
- };
2097
- };
2013
+
2014
+ export type RunInput = { __typename?: 'Input', cart: { __typename?: 'Cart', buyerIdentity?: { __typename?: 'BuyerIdentity', customer?: { __typename?: 'Customer', email?: string | null, hasTags: Array<{ __typename?: 'HasTagResponse', tag: string, hasTag: boolean }> } | null } | null, cost: { __typename?: 'CartCost', subtotalAmount: { __typename?: 'MoneyV2', amount: any } }, lines: Array<{ __typename?: 'CartLine', quantity: number, cost: { __typename?: 'CartLineCost', amountPerQuantity: { __typename?: 'MoneyV2', amount: any }, subtotalAmount: { __typename?: 'MoneyV2', amount: any }, totalAmount: { __typename?: 'MoneyV2', amount: any }, compareAtAmountPerQuantity?: { __typename?: 'MoneyV2', amount: any } | null }, sellingPlanAllocation?: { __typename?: 'SellingPlanAllocation', sellingPlan: { __typename?: 'SellingPlan', id: string } } | null, merchandise: { __typename: 'CustomProduct' } | { __typename: 'ProductVariant', id: string, product: { __typename?: 'Product', id: string, productType?: string | null, inAnyCollection: boolean, hasTags: Array<{ __typename?: 'HasTagResponse', tag: string, hasTag: boolean }> } } }>, deliveryGroups: Array<{ __typename?: 'CartDeliveryGroup', deliveryAddress?: { __typename?: 'MailingAddress', countryCode?: CountryCode | null } | null, deliveryOptions: Array<{ __typename?: 'CartDeliveryOption', title?: string | null, handle: any, code?: string | null, cost: { __typename?: 'MoneyV2', amount: any } }> }> }, discountNode: { __typename?: 'DiscountNode', metafield?: { __typename?: 'Metafield', value: string } | null } };
@@ -41,7 +41,6 @@ describe('CountryCodeQualifier', () => {
41
41
  expect(result).toEqual(false);
42
42
  });
43
43
 
44
- // @ts-ignore
45
44
  const discountCart = {
46
45
  cart: {
47
46
  deliveryGroups: [