@ehrenkind/shopify-lib 0.7.5 → 0.8.1
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/dist/index.cjs +642 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1223 -325
- package/dist/index.d.ts +1223 -325
- package/dist/index.mjs +632 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -264,7 +264,7 @@ async function makeRequest(query, variables, retries = 0) {
|
|
|
264
264
|
|
|
265
265
|
// src/mutations/customers/deleteCustomerById.ts
|
|
266
266
|
async function deleteCustomerById(customerId, retries = 1) {
|
|
267
|
-
const
|
|
267
|
+
const mutation15 = gql`#graphql
|
|
268
268
|
mutation customerDelete($input: CustomerDeleteInput!) {
|
|
269
269
|
customerDelete(input: $input) {
|
|
270
270
|
deletedCustomerId
|
|
@@ -279,7 +279,7 @@ async function deleteCustomerById(customerId, retries = 1) {
|
|
|
279
279
|
input: { id: customerId }
|
|
280
280
|
};
|
|
281
281
|
const response = await fetchShopifyGraphql({
|
|
282
|
-
query:
|
|
282
|
+
query: mutation15,
|
|
283
283
|
variables,
|
|
284
284
|
retries,
|
|
285
285
|
dataExtractor: (data) => {
|
|
@@ -302,7 +302,7 @@ async function deleteFilesByIds(fileIds, retries = 1) {
|
|
|
302
302
|
if (fileIds.length === 0) {
|
|
303
303
|
return [];
|
|
304
304
|
}
|
|
305
|
-
const
|
|
305
|
+
const mutation15 = gql`#graphql
|
|
306
306
|
mutation fileDelete($fileIds: [ID!]!) {
|
|
307
307
|
fileDelete(fileIds: $fileIds) {
|
|
308
308
|
deletedFileIds
|
|
@@ -316,7 +316,7 @@ async function deleteFilesByIds(fileIds, retries = 1) {
|
|
|
316
316
|
`;
|
|
317
317
|
const variables = { fileIds };
|
|
318
318
|
const response = await fetchShopifyGraphql({
|
|
319
|
-
query:
|
|
319
|
+
query: mutation15,
|
|
320
320
|
variables,
|
|
321
321
|
retries,
|
|
322
322
|
dataExtractor: (data) => {
|
|
@@ -411,7 +411,9 @@ async function createMetaobjectDefinition(input, retries = 0) {
|
|
|
411
411
|
name: input.name,
|
|
412
412
|
description: input.description,
|
|
413
413
|
displayNameKey: input.displayNameKey,
|
|
414
|
-
fieldDefinitions: input.fieldDefinitions
|
|
414
|
+
fieldDefinitions: input.fieldDefinitions,
|
|
415
|
+
access: input.access,
|
|
416
|
+
capabilities: input.capabilities
|
|
415
417
|
}
|
|
416
418
|
};
|
|
417
419
|
const result = await fetchShopifyGraphql({
|
|
@@ -703,6 +705,173 @@ async function cancelOrderById(orderId, retries = 0) {
|
|
|
703
705
|
return true;
|
|
704
706
|
}
|
|
705
707
|
|
|
708
|
+
// src/generated-api-types/admin.types.ts
|
|
709
|
+
var CurrencyCode = /* @__PURE__ */ ((CurrencyCode2) => {
|
|
710
|
+
CurrencyCode2["Aed"] = "AED";
|
|
711
|
+
CurrencyCode2["Afn"] = "AFN";
|
|
712
|
+
CurrencyCode2["All"] = "ALL";
|
|
713
|
+
CurrencyCode2["Amd"] = "AMD";
|
|
714
|
+
CurrencyCode2["Ang"] = "ANG";
|
|
715
|
+
CurrencyCode2["Aoa"] = "AOA";
|
|
716
|
+
CurrencyCode2["Ars"] = "ARS";
|
|
717
|
+
CurrencyCode2["Aud"] = "AUD";
|
|
718
|
+
CurrencyCode2["Awg"] = "AWG";
|
|
719
|
+
CurrencyCode2["Azn"] = "AZN";
|
|
720
|
+
CurrencyCode2["Bam"] = "BAM";
|
|
721
|
+
CurrencyCode2["Bbd"] = "BBD";
|
|
722
|
+
CurrencyCode2["Bdt"] = "BDT";
|
|
723
|
+
CurrencyCode2["Bgn"] = "BGN";
|
|
724
|
+
CurrencyCode2["Bhd"] = "BHD";
|
|
725
|
+
CurrencyCode2["Bif"] = "BIF";
|
|
726
|
+
CurrencyCode2["Bmd"] = "BMD";
|
|
727
|
+
CurrencyCode2["Bnd"] = "BND";
|
|
728
|
+
CurrencyCode2["Bob"] = "BOB";
|
|
729
|
+
CurrencyCode2["Brl"] = "BRL";
|
|
730
|
+
CurrencyCode2["Bsd"] = "BSD";
|
|
731
|
+
CurrencyCode2["Btn"] = "BTN";
|
|
732
|
+
CurrencyCode2["Bwp"] = "BWP";
|
|
733
|
+
CurrencyCode2["Byn"] = "BYN";
|
|
734
|
+
CurrencyCode2["Byr"] = "BYR";
|
|
735
|
+
CurrencyCode2["Bzd"] = "BZD";
|
|
736
|
+
CurrencyCode2["Cad"] = "CAD";
|
|
737
|
+
CurrencyCode2["Cdf"] = "CDF";
|
|
738
|
+
CurrencyCode2["Chf"] = "CHF";
|
|
739
|
+
CurrencyCode2["Clp"] = "CLP";
|
|
740
|
+
CurrencyCode2["Cny"] = "CNY";
|
|
741
|
+
CurrencyCode2["Cop"] = "COP";
|
|
742
|
+
CurrencyCode2["Crc"] = "CRC";
|
|
743
|
+
CurrencyCode2["Cve"] = "CVE";
|
|
744
|
+
CurrencyCode2["Czk"] = "CZK";
|
|
745
|
+
CurrencyCode2["Djf"] = "DJF";
|
|
746
|
+
CurrencyCode2["Dkk"] = "DKK";
|
|
747
|
+
CurrencyCode2["Dop"] = "DOP";
|
|
748
|
+
CurrencyCode2["Dzd"] = "DZD";
|
|
749
|
+
CurrencyCode2["Egp"] = "EGP";
|
|
750
|
+
CurrencyCode2["Ern"] = "ERN";
|
|
751
|
+
CurrencyCode2["Etb"] = "ETB";
|
|
752
|
+
CurrencyCode2["Eur"] = "EUR";
|
|
753
|
+
CurrencyCode2["Fjd"] = "FJD";
|
|
754
|
+
CurrencyCode2["Fkp"] = "FKP";
|
|
755
|
+
CurrencyCode2["Gbp"] = "GBP";
|
|
756
|
+
CurrencyCode2["Gel"] = "GEL";
|
|
757
|
+
CurrencyCode2["Ghs"] = "GHS";
|
|
758
|
+
CurrencyCode2["Gip"] = "GIP";
|
|
759
|
+
CurrencyCode2["Gmd"] = "GMD";
|
|
760
|
+
CurrencyCode2["Gnf"] = "GNF";
|
|
761
|
+
CurrencyCode2["Gtq"] = "GTQ";
|
|
762
|
+
CurrencyCode2["Gyd"] = "GYD";
|
|
763
|
+
CurrencyCode2["Hkd"] = "HKD";
|
|
764
|
+
CurrencyCode2["Hnl"] = "HNL";
|
|
765
|
+
CurrencyCode2["Hrk"] = "HRK";
|
|
766
|
+
CurrencyCode2["Htg"] = "HTG";
|
|
767
|
+
CurrencyCode2["Huf"] = "HUF";
|
|
768
|
+
CurrencyCode2["Idr"] = "IDR";
|
|
769
|
+
CurrencyCode2["Ils"] = "ILS";
|
|
770
|
+
CurrencyCode2["Inr"] = "INR";
|
|
771
|
+
CurrencyCode2["Iqd"] = "IQD";
|
|
772
|
+
CurrencyCode2["Irr"] = "IRR";
|
|
773
|
+
CurrencyCode2["Isk"] = "ISK";
|
|
774
|
+
CurrencyCode2["Jep"] = "JEP";
|
|
775
|
+
CurrencyCode2["Jmd"] = "JMD";
|
|
776
|
+
CurrencyCode2["Jod"] = "JOD";
|
|
777
|
+
CurrencyCode2["Jpy"] = "JPY";
|
|
778
|
+
CurrencyCode2["Kes"] = "KES";
|
|
779
|
+
CurrencyCode2["Kgs"] = "KGS";
|
|
780
|
+
CurrencyCode2["Khr"] = "KHR";
|
|
781
|
+
CurrencyCode2["Kid"] = "KID";
|
|
782
|
+
CurrencyCode2["Kmf"] = "KMF";
|
|
783
|
+
CurrencyCode2["Krw"] = "KRW";
|
|
784
|
+
CurrencyCode2["Kwd"] = "KWD";
|
|
785
|
+
CurrencyCode2["Kyd"] = "KYD";
|
|
786
|
+
CurrencyCode2["Kzt"] = "KZT";
|
|
787
|
+
CurrencyCode2["Lak"] = "LAK";
|
|
788
|
+
CurrencyCode2["Lbp"] = "LBP";
|
|
789
|
+
CurrencyCode2["Lkr"] = "LKR";
|
|
790
|
+
CurrencyCode2["Lrd"] = "LRD";
|
|
791
|
+
CurrencyCode2["Lsl"] = "LSL";
|
|
792
|
+
CurrencyCode2["Ltl"] = "LTL";
|
|
793
|
+
CurrencyCode2["Lvl"] = "LVL";
|
|
794
|
+
CurrencyCode2["Lyd"] = "LYD";
|
|
795
|
+
CurrencyCode2["Mad"] = "MAD";
|
|
796
|
+
CurrencyCode2["Mdl"] = "MDL";
|
|
797
|
+
CurrencyCode2["Mga"] = "MGA";
|
|
798
|
+
CurrencyCode2["Mkd"] = "MKD";
|
|
799
|
+
CurrencyCode2["Mmk"] = "MMK";
|
|
800
|
+
CurrencyCode2["Mnt"] = "MNT";
|
|
801
|
+
CurrencyCode2["Mop"] = "MOP";
|
|
802
|
+
CurrencyCode2["Mru"] = "MRU";
|
|
803
|
+
CurrencyCode2["Mur"] = "MUR";
|
|
804
|
+
CurrencyCode2["Mvr"] = "MVR";
|
|
805
|
+
CurrencyCode2["Mwk"] = "MWK";
|
|
806
|
+
CurrencyCode2["Mxn"] = "MXN";
|
|
807
|
+
CurrencyCode2["Myr"] = "MYR";
|
|
808
|
+
CurrencyCode2["Mzn"] = "MZN";
|
|
809
|
+
CurrencyCode2["Nad"] = "NAD";
|
|
810
|
+
CurrencyCode2["Ngn"] = "NGN";
|
|
811
|
+
CurrencyCode2["Nio"] = "NIO";
|
|
812
|
+
CurrencyCode2["Nok"] = "NOK";
|
|
813
|
+
CurrencyCode2["Npr"] = "NPR";
|
|
814
|
+
CurrencyCode2["Nzd"] = "NZD";
|
|
815
|
+
CurrencyCode2["Omr"] = "OMR";
|
|
816
|
+
CurrencyCode2["Pab"] = "PAB";
|
|
817
|
+
CurrencyCode2["Pen"] = "PEN";
|
|
818
|
+
CurrencyCode2["Pgk"] = "PGK";
|
|
819
|
+
CurrencyCode2["Php"] = "PHP";
|
|
820
|
+
CurrencyCode2["Pkr"] = "PKR";
|
|
821
|
+
CurrencyCode2["Pln"] = "PLN";
|
|
822
|
+
CurrencyCode2["Pyg"] = "PYG";
|
|
823
|
+
CurrencyCode2["Qar"] = "QAR";
|
|
824
|
+
CurrencyCode2["Ron"] = "RON";
|
|
825
|
+
CurrencyCode2["Rsd"] = "RSD";
|
|
826
|
+
CurrencyCode2["Rub"] = "RUB";
|
|
827
|
+
CurrencyCode2["Rwf"] = "RWF";
|
|
828
|
+
CurrencyCode2["Sar"] = "SAR";
|
|
829
|
+
CurrencyCode2["Sbd"] = "SBD";
|
|
830
|
+
CurrencyCode2["Scr"] = "SCR";
|
|
831
|
+
CurrencyCode2["Sdg"] = "SDG";
|
|
832
|
+
CurrencyCode2["Sek"] = "SEK";
|
|
833
|
+
CurrencyCode2["Sgd"] = "SGD";
|
|
834
|
+
CurrencyCode2["Shp"] = "SHP";
|
|
835
|
+
CurrencyCode2["Sll"] = "SLL";
|
|
836
|
+
CurrencyCode2["Sos"] = "SOS";
|
|
837
|
+
CurrencyCode2["Srd"] = "SRD";
|
|
838
|
+
CurrencyCode2["Ssp"] = "SSP";
|
|
839
|
+
CurrencyCode2["Std"] = "STD";
|
|
840
|
+
CurrencyCode2["Stn"] = "STN";
|
|
841
|
+
CurrencyCode2["Syp"] = "SYP";
|
|
842
|
+
CurrencyCode2["Szl"] = "SZL";
|
|
843
|
+
CurrencyCode2["Thb"] = "THB";
|
|
844
|
+
CurrencyCode2["Tjs"] = "TJS";
|
|
845
|
+
CurrencyCode2["Tmt"] = "TMT";
|
|
846
|
+
CurrencyCode2["Tnd"] = "TND";
|
|
847
|
+
CurrencyCode2["Top"] = "TOP";
|
|
848
|
+
CurrencyCode2["Try"] = "TRY";
|
|
849
|
+
CurrencyCode2["Ttd"] = "TTD";
|
|
850
|
+
CurrencyCode2["Twd"] = "TWD";
|
|
851
|
+
CurrencyCode2["Tzs"] = "TZS";
|
|
852
|
+
CurrencyCode2["Uah"] = "UAH";
|
|
853
|
+
CurrencyCode2["Ugx"] = "UGX";
|
|
854
|
+
CurrencyCode2["Usd"] = "USD";
|
|
855
|
+
CurrencyCode2["Usdc"] = "USDC";
|
|
856
|
+
CurrencyCode2["Uyu"] = "UYU";
|
|
857
|
+
CurrencyCode2["Uzs"] = "UZS";
|
|
858
|
+
CurrencyCode2["Ved"] = "VED";
|
|
859
|
+
CurrencyCode2["Vef"] = "VEF";
|
|
860
|
+
CurrencyCode2["Ves"] = "VES";
|
|
861
|
+
CurrencyCode2["Vnd"] = "VND";
|
|
862
|
+
CurrencyCode2["Vuv"] = "VUV";
|
|
863
|
+
CurrencyCode2["Wst"] = "WST";
|
|
864
|
+
CurrencyCode2["Xaf"] = "XAF";
|
|
865
|
+
CurrencyCode2["Xcd"] = "XCD";
|
|
866
|
+
CurrencyCode2["Xof"] = "XOF";
|
|
867
|
+
CurrencyCode2["Xpf"] = "XPF";
|
|
868
|
+
CurrencyCode2["Xxx"] = "XXX";
|
|
869
|
+
CurrencyCode2["Yer"] = "YER";
|
|
870
|
+
CurrencyCode2["Zar"] = "ZAR";
|
|
871
|
+
CurrencyCode2["Zmw"] = "ZMW";
|
|
872
|
+
return CurrencyCode2;
|
|
873
|
+
})(CurrencyCode || {});
|
|
874
|
+
|
|
706
875
|
// src/mutations/refunds/createRefund.ts
|
|
707
876
|
var mutation6 = gql`#graphql
|
|
708
877
|
mutation createRefund($input: RefundInput!) {
|
|
@@ -953,36 +1122,60 @@ var querySuggestedRefund = gql`#graphql
|
|
|
953
1122
|
amount
|
|
954
1123
|
currencyCode
|
|
955
1124
|
}
|
|
1125
|
+
presentmentMoney {
|
|
1126
|
+
amount
|
|
1127
|
+
currencyCode
|
|
1128
|
+
}
|
|
956
1129
|
}
|
|
957
1130
|
maximumRefundableSet {
|
|
958
1131
|
shopMoney {
|
|
959
1132
|
amount
|
|
960
1133
|
currencyCode
|
|
961
1134
|
}
|
|
1135
|
+
presentmentMoney {
|
|
1136
|
+
amount
|
|
1137
|
+
currencyCode
|
|
1138
|
+
}
|
|
962
1139
|
}
|
|
963
1140
|
subtotalSet {
|
|
964
1141
|
shopMoney {
|
|
965
1142
|
amount
|
|
966
1143
|
currencyCode
|
|
967
1144
|
}
|
|
1145
|
+
presentmentMoney {
|
|
1146
|
+
amount
|
|
1147
|
+
currencyCode
|
|
1148
|
+
}
|
|
968
1149
|
}
|
|
969
1150
|
totalTaxSet {
|
|
970
1151
|
shopMoney {
|
|
971
1152
|
amount
|
|
972
1153
|
currencyCode
|
|
973
1154
|
}
|
|
1155
|
+
presentmentMoney {
|
|
1156
|
+
amount
|
|
1157
|
+
currencyCode
|
|
1158
|
+
}
|
|
974
1159
|
}
|
|
975
1160
|
discountedSubtotalSet {
|
|
976
1161
|
shopMoney {
|
|
977
1162
|
amount
|
|
978
1163
|
currencyCode
|
|
979
1164
|
}
|
|
1165
|
+
presentmentMoney {
|
|
1166
|
+
amount
|
|
1167
|
+
currencyCode
|
|
1168
|
+
}
|
|
980
1169
|
}
|
|
981
1170
|
totalCartDiscountAmountSet {
|
|
982
1171
|
shopMoney {
|
|
983
1172
|
amount
|
|
984
1173
|
currencyCode
|
|
985
1174
|
}
|
|
1175
|
+
presentmentMoney {
|
|
1176
|
+
amount
|
|
1177
|
+
currencyCode
|
|
1178
|
+
}
|
|
986
1179
|
}
|
|
987
1180
|
shipping {
|
|
988
1181
|
amountSet {
|
|
@@ -990,18 +1183,30 @@ var querySuggestedRefund = gql`#graphql
|
|
|
990
1183
|
amount
|
|
991
1184
|
currencyCode
|
|
992
1185
|
}
|
|
1186
|
+
presentmentMoney {
|
|
1187
|
+
amount
|
|
1188
|
+
currencyCode
|
|
1189
|
+
}
|
|
993
1190
|
}
|
|
994
1191
|
maximumRefundableSet {
|
|
995
1192
|
shopMoney {
|
|
996
1193
|
amount
|
|
997
1194
|
currencyCode
|
|
998
1195
|
}
|
|
1196
|
+
presentmentMoney {
|
|
1197
|
+
amount
|
|
1198
|
+
currencyCode
|
|
1199
|
+
}
|
|
999
1200
|
}
|
|
1000
1201
|
taxSet {
|
|
1001
1202
|
shopMoney {
|
|
1002
1203
|
amount
|
|
1003
1204
|
currencyCode
|
|
1004
1205
|
}
|
|
1206
|
+
presentmentMoney {
|
|
1207
|
+
amount
|
|
1208
|
+
currencyCode
|
|
1209
|
+
}
|
|
1005
1210
|
}
|
|
1006
1211
|
}
|
|
1007
1212
|
refundLineItems {
|
|
@@ -1015,12 +1220,20 @@ var querySuggestedRefund = gql`#graphql
|
|
|
1015
1220
|
amount
|
|
1016
1221
|
currencyCode
|
|
1017
1222
|
}
|
|
1223
|
+
presentmentMoney {
|
|
1224
|
+
amount
|
|
1225
|
+
currencyCode
|
|
1226
|
+
}
|
|
1018
1227
|
}
|
|
1019
1228
|
totalDiscountSet {
|
|
1020
1229
|
shopMoney {
|
|
1021
1230
|
amount
|
|
1022
1231
|
currencyCode
|
|
1023
1232
|
}
|
|
1233
|
+
presentmentMoney {
|
|
1234
|
+
amount
|
|
1235
|
+
currencyCode
|
|
1236
|
+
}
|
|
1024
1237
|
}
|
|
1025
1238
|
}
|
|
1026
1239
|
quantity
|
|
@@ -1029,18 +1242,30 @@ var querySuggestedRefund = gql`#graphql
|
|
|
1029
1242
|
amount
|
|
1030
1243
|
currencyCode
|
|
1031
1244
|
}
|
|
1245
|
+
presentmentMoney {
|
|
1246
|
+
amount
|
|
1247
|
+
currencyCode
|
|
1248
|
+
}
|
|
1032
1249
|
}
|
|
1033
1250
|
subtotalSet {
|
|
1034
1251
|
shopMoney {
|
|
1035
1252
|
amount
|
|
1036
1253
|
currencyCode
|
|
1037
1254
|
}
|
|
1255
|
+
presentmentMoney {
|
|
1256
|
+
amount
|
|
1257
|
+
currencyCode
|
|
1258
|
+
}
|
|
1038
1259
|
}
|
|
1039
1260
|
totalTaxSet {
|
|
1040
1261
|
shopMoney {
|
|
1041
1262
|
amount
|
|
1042
1263
|
currencyCode
|
|
1043
1264
|
}
|
|
1265
|
+
presentmentMoney {
|
|
1266
|
+
amount
|
|
1267
|
+
currencyCode
|
|
1268
|
+
}
|
|
1044
1269
|
}
|
|
1045
1270
|
restockType
|
|
1046
1271
|
}
|
|
@@ -1052,12 +1277,20 @@ var querySuggestedRefund = gql`#graphql
|
|
|
1052
1277
|
amount
|
|
1053
1278
|
currencyCode
|
|
1054
1279
|
}
|
|
1280
|
+
presentmentMoney {
|
|
1281
|
+
amount
|
|
1282
|
+
currencyCode
|
|
1283
|
+
}
|
|
1055
1284
|
}
|
|
1056
1285
|
maximumRefundableSet {
|
|
1057
1286
|
shopMoney {
|
|
1058
1287
|
amount
|
|
1059
1288
|
currencyCode
|
|
1060
1289
|
}
|
|
1290
|
+
presentmentMoney {
|
|
1291
|
+
amount
|
|
1292
|
+
currencyCode
|
|
1293
|
+
}
|
|
1061
1294
|
}
|
|
1062
1295
|
parentTransaction {
|
|
1063
1296
|
id
|
|
@@ -1114,6 +1347,352 @@ async function calculateRefund(orderId, options = {}, retries = 3) {
|
|
|
1114
1347
|
return response.order.suggestedRefund;
|
|
1115
1348
|
}
|
|
1116
1349
|
|
|
1350
|
+
// src/mutations/metaobjects/setMetaobjectStatus.ts
|
|
1351
|
+
var mutation9 = gql`#graphql
|
|
1352
|
+
mutation setMetaobjectStatus($id: ID!, $metaobject: MetaobjectUpdateInput!) {
|
|
1353
|
+
metaobjectUpdate(id: $id, metaobject: $metaobject) {
|
|
1354
|
+
metaobject {
|
|
1355
|
+
id
|
|
1356
|
+
}
|
|
1357
|
+
userErrors {
|
|
1358
|
+
code
|
|
1359
|
+
field
|
|
1360
|
+
message
|
|
1361
|
+
}
|
|
1362
|
+
}
|
|
1363
|
+
}
|
|
1364
|
+
`;
|
|
1365
|
+
async function setMetaobjectStatus(id, status, retries = 1) {
|
|
1366
|
+
const variables = {
|
|
1367
|
+
id,
|
|
1368
|
+
metaobject: {
|
|
1369
|
+
capabilities: {
|
|
1370
|
+
publishable: { status }
|
|
1371
|
+
}
|
|
1372
|
+
}
|
|
1373
|
+
};
|
|
1374
|
+
await fetchShopifyGraphql({
|
|
1375
|
+
query: mutation9,
|
|
1376
|
+
variables,
|
|
1377
|
+
retries,
|
|
1378
|
+
dataExtractor: (data) => {
|
|
1379
|
+
if (!data.metaobjectUpdate) {
|
|
1380
|
+
throw new Error("GraphQL response missing 'metaobjectUpdate' field");
|
|
1381
|
+
}
|
|
1382
|
+
const { metaobject, userErrors } = data.metaobjectUpdate;
|
|
1383
|
+
return {
|
|
1384
|
+
nodes: metaobject ? [{ id: metaobject.id }] : [],
|
|
1385
|
+
userErrors
|
|
1386
|
+
};
|
|
1387
|
+
}
|
|
1388
|
+
});
|
|
1389
|
+
logger.debug(`Set metaobject ${id} status to ${status}`);
|
|
1390
|
+
}
|
|
1391
|
+
|
|
1392
|
+
// src/mutations/metaobjects/deleteMetaobject.ts
|
|
1393
|
+
var mutation10 = gql`#graphql
|
|
1394
|
+
mutation deleteMetaobject($id: ID!) {
|
|
1395
|
+
metaobjectDelete(id: $id) {
|
|
1396
|
+
deletedId
|
|
1397
|
+
userErrors {
|
|
1398
|
+
code
|
|
1399
|
+
field
|
|
1400
|
+
message
|
|
1401
|
+
}
|
|
1402
|
+
}
|
|
1403
|
+
}
|
|
1404
|
+
`;
|
|
1405
|
+
async function deleteMetaobject(id, retries = 0) {
|
|
1406
|
+
const variables = { id };
|
|
1407
|
+
const result = await fetchShopifyGraphql({
|
|
1408
|
+
query: mutation10,
|
|
1409
|
+
variables,
|
|
1410
|
+
retries,
|
|
1411
|
+
dataExtractor: (data) => {
|
|
1412
|
+
if (!data.metaobjectDelete) {
|
|
1413
|
+
throw new Error("GraphQL response missing 'metaobjectDelete' field");
|
|
1414
|
+
}
|
|
1415
|
+
const { deletedId: deletedId2, userErrors } = data.metaobjectDelete;
|
|
1416
|
+
return {
|
|
1417
|
+
nodes: [{ deletedId: deletedId2 ?? null }],
|
|
1418
|
+
userErrors
|
|
1419
|
+
};
|
|
1420
|
+
}
|
|
1421
|
+
});
|
|
1422
|
+
const deletedId = result[0]?.deletedId ?? void 0;
|
|
1423
|
+
if (deletedId) {
|
|
1424
|
+
logger.debug(`Deleted metaobject ${deletedId}`);
|
|
1425
|
+
}
|
|
1426
|
+
return deletedId;
|
|
1427
|
+
}
|
|
1428
|
+
|
|
1429
|
+
// src/mutations/metafields/metafieldsSet.ts
|
|
1430
|
+
var mutation11 = gql`#graphql
|
|
1431
|
+
mutation metafieldsSet($metafields: [MetafieldsSetInput!]!) {
|
|
1432
|
+
metafieldsSet(metafields: $metafields) {
|
|
1433
|
+
metafields {
|
|
1434
|
+
id
|
|
1435
|
+
namespace
|
|
1436
|
+
key
|
|
1437
|
+
value
|
|
1438
|
+
}
|
|
1439
|
+
userErrors {
|
|
1440
|
+
code
|
|
1441
|
+
field
|
|
1442
|
+
message
|
|
1443
|
+
}
|
|
1444
|
+
}
|
|
1445
|
+
}
|
|
1446
|
+
`;
|
|
1447
|
+
async function metafieldsSet(metafields, retries = 1) {
|
|
1448
|
+
const variables = { metafields };
|
|
1449
|
+
const result = await fetchShopifyGraphql(
|
|
1450
|
+
{
|
|
1451
|
+
query: mutation11,
|
|
1452
|
+
variables,
|
|
1453
|
+
retries,
|
|
1454
|
+
dataExtractor: (data) => {
|
|
1455
|
+
if (!data.metafieldsSet) {
|
|
1456
|
+
throw new Error("GraphQL response missing 'metafieldsSet' field");
|
|
1457
|
+
}
|
|
1458
|
+
const { metafields: set, userErrors } = data.metafieldsSet;
|
|
1459
|
+
return {
|
|
1460
|
+
nodes: (set ?? []).map((m) => ({
|
|
1461
|
+
id: m.id,
|
|
1462
|
+
namespace: m.namespace,
|
|
1463
|
+
key: m.key,
|
|
1464
|
+
value: m.value
|
|
1465
|
+
})),
|
|
1466
|
+
userErrors
|
|
1467
|
+
};
|
|
1468
|
+
}
|
|
1469
|
+
}
|
|
1470
|
+
);
|
|
1471
|
+
logger.debug(`Set ${result.length} metafield(s)`);
|
|
1472
|
+
return result;
|
|
1473
|
+
}
|
|
1474
|
+
|
|
1475
|
+
// src/mutations/metafieldDefinitions/createMetafieldDefinition.ts
|
|
1476
|
+
var mutation12 = gql`#graphql
|
|
1477
|
+
mutation createMetafieldDefinition($definition: MetafieldDefinitionInput!) {
|
|
1478
|
+
metafieldDefinitionCreate(definition: $definition) {
|
|
1479
|
+
createdDefinition {
|
|
1480
|
+
id
|
|
1481
|
+
}
|
|
1482
|
+
userErrors {
|
|
1483
|
+
code
|
|
1484
|
+
field
|
|
1485
|
+
message
|
|
1486
|
+
}
|
|
1487
|
+
}
|
|
1488
|
+
}
|
|
1489
|
+
`;
|
|
1490
|
+
async function createMetafieldDefinition(definition, retries = 0) {
|
|
1491
|
+
const variables = { definition };
|
|
1492
|
+
const result = await fetchShopifyGraphql({
|
|
1493
|
+
query: mutation12,
|
|
1494
|
+
variables,
|
|
1495
|
+
retries,
|
|
1496
|
+
dataExtractor: (data) => {
|
|
1497
|
+
if (!data.metafieldDefinitionCreate) {
|
|
1498
|
+
throw new Error(
|
|
1499
|
+
"GraphQL response missing 'metafieldDefinitionCreate' field"
|
|
1500
|
+
);
|
|
1501
|
+
}
|
|
1502
|
+
const { createdDefinition, userErrors } = data.metafieldDefinitionCreate;
|
|
1503
|
+
return {
|
|
1504
|
+
nodes: createdDefinition ? [{ id: createdDefinition.id }] : [],
|
|
1505
|
+
userErrors
|
|
1506
|
+
};
|
|
1507
|
+
}
|
|
1508
|
+
});
|
|
1509
|
+
const created = result[0];
|
|
1510
|
+
if (!created) {
|
|
1511
|
+
throw new Error("Metafield definition creation returned no result");
|
|
1512
|
+
}
|
|
1513
|
+
logger.debug(`Created metafield definition ${created.id}`);
|
|
1514
|
+
return created.id;
|
|
1515
|
+
}
|
|
1516
|
+
|
|
1517
|
+
// src/mutations/metafieldDefinitions/updateMetafieldDefinition.ts
|
|
1518
|
+
var mutation13 = gql`#graphql
|
|
1519
|
+
mutation updateMetafieldDefinition(
|
|
1520
|
+
$definition: MetafieldDefinitionUpdateInput!
|
|
1521
|
+
) {
|
|
1522
|
+
metafieldDefinitionUpdate(definition: $definition) {
|
|
1523
|
+
updatedDefinition {
|
|
1524
|
+
id
|
|
1525
|
+
}
|
|
1526
|
+
userErrors {
|
|
1527
|
+
code
|
|
1528
|
+
field
|
|
1529
|
+
message
|
|
1530
|
+
}
|
|
1531
|
+
}
|
|
1532
|
+
}
|
|
1533
|
+
`;
|
|
1534
|
+
async function updateMetafieldDefinition(definition, retries = 1) {
|
|
1535
|
+
const variables = { definition };
|
|
1536
|
+
const result = await fetchShopifyGraphql({
|
|
1537
|
+
query: mutation13,
|
|
1538
|
+
variables,
|
|
1539
|
+
retries,
|
|
1540
|
+
dataExtractor: (data) => {
|
|
1541
|
+
if (!data.metafieldDefinitionUpdate) {
|
|
1542
|
+
throw new Error(
|
|
1543
|
+
"GraphQL response missing 'metafieldDefinitionUpdate' field"
|
|
1544
|
+
);
|
|
1545
|
+
}
|
|
1546
|
+
const { updatedDefinition, userErrors } = data.metafieldDefinitionUpdate;
|
|
1547
|
+
return {
|
|
1548
|
+
nodes: updatedDefinition ? [{ id: updatedDefinition.id }] : [],
|
|
1549
|
+
userErrors
|
|
1550
|
+
};
|
|
1551
|
+
}
|
|
1552
|
+
});
|
|
1553
|
+
const updated = result[0]?.id;
|
|
1554
|
+
if (updated) {
|
|
1555
|
+
logger.debug(`Updated metafield definition ${updated}`);
|
|
1556
|
+
}
|
|
1557
|
+
return updated;
|
|
1558
|
+
}
|
|
1559
|
+
|
|
1560
|
+
// src/mutations/customers/updateCustomerEmailMarketingConsent.ts
|
|
1561
|
+
var mutation14 = gql`#graphql
|
|
1562
|
+
mutation updateCustomerEmailMarketingConsent(
|
|
1563
|
+
$input: CustomerEmailMarketingConsentUpdateInput!
|
|
1564
|
+
) {
|
|
1565
|
+
customerEmailMarketingConsentUpdate(input: $input) {
|
|
1566
|
+
customer {
|
|
1567
|
+
id
|
|
1568
|
+
emailMarketingConsent {
|
|
1569
|
+
marketingState
|
|
1570
|
+
}
|
|
1571
|
+
}
|
|
1572
|
+
userErrors {
|
|
1573
|
+
field
|
|
1574
|
+
message
|
|
1575
|
+
}
|
|
1576
|
+
}
|
|
1577
|
+
}
|
|
1578
|
+
`;
|
|
1579
|
+
async function updateCustomerEmailMarketingConsent(input, retries = 1) {
|
|
1580
|
+
const variables = {
|
|
1581
|
+
input: {
|
|
1582
|
+
customerId: input.customerId,
|
|
1583
|
+
emailMarketingConsent: {
|
|
1584
|
+
marketingState: input.marketingState,
|
|
1585
|
+
marketingOptInLevel: input.marketingOptInLevel
|
|
1586
|
+
}
|
|
1587
|
+
}
|
|
1588
|
+
};
|
|
1589
|
+
const result = await fetchShopifyGraphql({
|
|
1590
|
+
query: mutation14,
|
|
1591
|
+
variables,
|
|
1592
|
+
retries,
|
|
1593
|
+
dataExtractor: (data) => {
|
|
1594
|
+
if (!data.customerEmailMarketingConsentUpdate) {
|
|
1595
|
+
throw new Error(
|
|
1596
|
+
"GraphQL response missing 'customerEmailMarketingConsentUpdate' field"
|
|
1597
|
+
);
|
|
1598
|
+
}
|
|
1599
|
+
const { customer, userErrors } = data.customerEmailMarketingConsentUpdate;
|
|
1600
|
+
return {
|
|
1601
|
+
nodes: customer ? [
|
|
1602
|
+
{
|
|
1603
|
+
id: customer.id,
|
|
1604
|
+
marketingState: customer.emailMarketingConsent?.marketingState ?? null
|
|
1605
|
+
}
|
|
1606
|
+
] : [],
|
|
1607
|
+
userErrors
|
|
1608
|
+
};
|
|
1609
|
+
}
|
|
1610
|
+
});
|
|
1611
|
+
const updated = result[0];
|
|
1612
|
+
if (!updated) {
|
|
1613
|
+
throw new Error(
|
|
1614
|
+
"Customer email marketing consent update returned no result"
|
|
1615
|
+
);
|
|
1616
|
+
}
|
|
1617
|
+
logger.debug(
|
|
1618
|
+
`Updated customer ${updated.id} email marketing consent to ${updated.marketingState}`
|
|
1619
|
+
);
|
|
1620
|
+
return updated;
|
|
1621
|
+
}
|
|
1622
|
+
|
|
1623
|
+
// src/queries/metaobjects/getMetaobjectsByType.queries.ts
|
|
1624
|
+
var queryMetaobjectsByType = gql`#graphql
|
|
1625
|
+
query metaobjectsByType($type: String!, $first: Int!, $after: String) {
|
|
1626
|
+
metaobjects(type: $type, first: $first, after: $after) {
|
|
1627
|
+
nodes {
|
|
1628
|
+
id
|
|
1629
|
+
handle
|
|
1630
|
+
displayName
|
|
1631
|
+
type
|
|
1632
|
+
fields {
|
|
1633
|
+
key
|
|
1634
|
+
value
|
|
1635
|
+
}
|
|
1636
|
+
}
|
|
1637
|
+
pageInfo {
|
|
1638
|
+
hasNextPage
|
|
1639
|
+
endCursor
|
|
1640
|
+
}
|
|
1641
|
+
}
|
|
1642
|
+
}
|
|
1643
|
+
`;
|
|
1644
|
+
|
|
1645
|
+
// src/queries/metaobjects/getMetaobjectsByType.ts
|
|
1646
|
+
async function getMetaobjectsByType(type, options = {}, retries = 3) {
|
|
1647
|
+
const variables = {
|
|
1648
|
+
type,
|
|
1649
|
+
first: options.pageSize ?? 250
|
|
1650
|
+
};
|
|
1651
|
+
const nodes = await fetchShopifyGraphql({
|
|
1652
|
+
query: queryMetaobjectsByType,
|
|
1653
|
+
variables,
|
|
1654
|
+
fetchAllPages: true,
|
|
1655
|
+
retries,
|
|
1656
|
+
dataExtractor: (data) => {
|
|
1657
|
+
if (!data.metaobjects) {
|
|
1658
|
+
throw new Error("GraphQL response missing 'metaobjects' field");
|
|
1659
|
+
}
|
|
1660
|
+
return {
|
|
1661
|
+
nodes: data.metaobjects.nodes,
|
|
1662
|
+
pageInfo: data.metaobjects.pageInfo
|
|
1663
|
+
};
|
|
1664
|
+
}
|
|
1665
|
+
});
|
|
1666
|
+
logger.debug(`Fetched ${nodes.length} metaobject(s) of type "${type}"`);
|
|
1667
|
+
return nodes;
|
|
1668
|
+
}
|
|
1669
|
+
|
|
1670
|
+
// src/queries/metaobjectDefinitions/getMetaobjectDefinitionByType.queries.ts
|
|
1671
|
+
var queryMetaobjectDefinitionByType = gql`#graphql
|
|
1672
|
+
query metaobjectDefinitionByType($type: String!) {
|
|
1673
|
+
metaobjectDefinitionByType(type: $type) {
|
|
1674
|
+
id
|
|
1675
|
+
type
|
|
1676
|
+
name
|
|
1677
|
+
}
|
|
1678
|
+
}
|
|
1679
|
+
`;
|
|
1680
|
+
|
|
1681
|
+
// src/queries/metaobjectDefinitions/getMetaobjectDefinitionByType.ts
|
|
1682
|
+
async function getMetaobjectDefinitionByType(type, retries = 3) {
|
|
1683
|
+
const variables = { type };
|
|
1684
|
+
const response = await fetchShopifyGraphql({
|
|
1685
|
+
query: queryMetaobjectDefinitionByType,
|
|
1686
|
+
variables,
|
|
1687
|
+
retries
|
|
1688
|
+
});
|
|
1689
|
+
if (!response.metaobjectDefinitionByType) {
|
|
1690
|
+
logger.debug(`No metaobject definition found for type "${type}"`);
|
|
1691
|
+
return void 0;
|
|
1692
|
+
}
|
|
1693
|
+
return response.metaobjectDefinitionByType;
|
|
1694
|
+
}
|
|
1695
|
+
|
|
1117
1696
|
// src/queries/orders/getOrderById.ts
|
|
1118
1697
|
import z3 from "zod";
|
|
1119
1698
|
|
|
@@ -1238,6 +1817,14 @@ var queryOrderByIdFull = gql`#graphql
|
|
|
1238
1817
|
currencyCode
|
|
1239
1818
|
}
|
|
1240
1819
|
}
|
|
1820
|
+
discountAllocations {
|
|
1821
|
+
allocatedAmountSet {
|
|
1822
|
+
shopMoney {
|
|
1823
|
+
amount
|
|
1824
|
+
currencyCode
|
|
1825
|
+
}
|
|
1826
|
+
}
|
|
1827
|
+
}
|
|
1241
1828
|
vendor
|
|
1242
1829
|
image {
|
|
1243
1830
|
url
|
|
@@ -1254,6 +1841,25 @@ var queryOrderByIdFull = gql`#graphql
|
|
|
1254
1841
|
}
|
|
1255
1842
|
}
|
|
1256
1843
|
}
|
|
1844
|
+
discountApplications(first: 20) {
|
|
1845
|
+
nodes {
|
|
1846
|
+
allocationMethod
|
|
1847
|
+
targetType
|
|
1848
|
+
value {
|
|
1849
|
+
__typename
|
|
1850
|
+
... on PricingPercentageValue {
|
|
1851
|
+
percentage
|
|
1852
|
+
}
|
|
1853
|
+
... on MoneyV2 {
|
|
1854
|
+
amount
|
|
1855
|
+
currencyCode
|
|
1856
|
+
}
|
|
1857
|
+
}
|
|
1858
|
+
... on DiscountCodeApplication {
|
|
1859
|
+
code
|
|
1860
|
+
}
|
|
1861
|
+
}
|
|
1862
|
+
}
|
|
1257
1863
|
fulfillments {
|
|
1258
1864
|
id
|
|
1259
1865
|
name
|
|
@@ -1310,6 +1916,17 @@ var queryOrderByIdFull = gql`#graphql
|
|
|
1310
1916
|
currencyCode
|
|
1311
1917
|
}
|
|
1312
1918
|
}
|
|
1919
|
+
transactions(first: 50) {
|
|
1920
|
+
nodes {
|
|
1921
|
+
kind
|
|
1922
|
+
amountSet {
|
|
1923
|
+
shopMoney {
|
|
1924
|
+
amount
|
|
1925
|
+
currencyCode
|
|
1926
|
+
}
|
|
1927
|
+
}
|
|
1928
|
+
}
|
|
1929
|
+
}
|
|
1313
1930
|
}
|
|
1314
1931
|
}
|
|
1315
1932
|
}
|
|
@@ -2564,16 +3181,19 @@ async function getMetaobjectByHandle(handle, retries = 3) {
|
|
|
2564
3181
|
return response.metaobjectByHandle;
|
|
2565
3182
|
}
|
|
2566
3183
|
export {
|
|
3184
|
+
CurrencyCode,
|
|
2567
3185
|
ShopifyUserError,
|
|
2568
3186
|
bulkUpdateProductVariants,
|
|
2569
3187
|
calculateRefund,
|
|
2570
3188
|
cancelOrderById,
|
|
2571
3189
|
createFile,
|
|
2572
3190
|
createFulfillment,
|
|
3191
|
+
createMetafieldDefinition,
|
|
2573
3192
|
createMetaobjectDefinition,
|
|
2574
3193
|
createRefund,
|
|
2575
3194
|
deleteCustomerById,
|
|
2576
3195
|
deleteFilesByIds,
|
|
3196
|
+
deleteMetaobject,
|
|
2577
3197
|
getAllProductVariants,
|
|
2578
3198
|
getCustomerSegmentMembers,
|
|
2579
3199
|
getCustomersByEmail,
|
|
@@ -2582,6 +3202,8 @@ export {
|
|
|
2582
3202
|
getFulfillmentTrackingIds,
|
|
2583
3203
|
getLeanProductVariants,
|
|
2584
3204
|
getMetaobjectByHandle,
|
|
3205
|
+
getMetaobjectDefinitionByType,
|
|
3206
|
+
getMetaobjectsByType,
|
|
2585
3207
|
getOrderById,
|
|
2586
3208
|
getOrderByName,
|
|
2587
3209
|
getOrderCancellationInfoByName,
|
|
@@ -2589,8 +3211,13 @@ export {
|
|
|
2589
3211
|
getOrdersByCustomerId,
|
|
2590
3212
|
getProductVariantsBySkus,
|
|
2591
3213
|
isRetryableError,
|
|
3214
|
+
metafieldsSet,
|
|
2592
3215
|
parseGid,
|
|
3216
|
+
fetchShopifyGraphql as runShopifyGraphql,
|
|
3217
|
+
setMetaobjectStatus,
|
|
3218
|
+
updateCustomerEmailMarketingConsent,
|
|
2593
3219
|
updateFulfillmentTracking,
|
|
3220
|
+
updateMetafieldDefinition,
|
|
2594
3221
|
upsertMetaobject
|
|
2595
3222
|
};
|
|
2596
3223
|
//# sourceMappingURL=index.mjs.map
|