@brytdesigns/shopify-ajax-cart-api 1.0.20 → 1.0.21
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/effect/index.d.ts +32 -137
- package/dist/effect/schema.js +3 -52
- package/dist/effect/schema.js.map +1 -1
- package/dist/esm/index.js +15 -99
- package/dist/esm/index.js.map +1 -1
- package/dist/main/effect/schema.js +3 -52
- package/dist/main/effect/schema.js.map +1 -1
- package/dist/main/index.d.ts +70 -301
- package/dist/main/index.js +1 -1
- package/dist/main/index.js.map +1 -1
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
|
@@ -6858,7 +6858,6 @@ var match7 = (concurrency, sequential4, unbounded4, bounded4) => {
|
|
|
6858
6858
|
// ../../../node_modules/.pnpm/effect@3.15.2/node_modules/effect/dist/esm/Clock.js
|
|
6859
6859
|
var sleep2 = sleep;
|
|
6860
6860
|
var currentTimeMillis2 = currentTimeMillis;
|
|
6861
|
-
var clockWith2 = clockWith;
|
|
6862
6861
|
var Clock = clockTag;
|
|
6863
6862
|
|
|
6864
6863
|
// ../../../node_modules/.pnpm/effect@3.15.2/node_modules/effect/dist/esm/internal/logSpan.js
|
|
@@ -6922,7 +6921,6 @@ var try_ = (arg) => {
|
|
|
6922
6921
|
}
|
|
6923
6922
|
});
|
|
6924
6923
|
};
|
|
6925
|
-
var clockWith3 = clockWith2;
|
|
6926
6924
|
var diffFiberRefs = (self) => summarized(self, fiberRefs2, diff5);
|
|
6927
6925
|
var diffFiberRefsAndRuntimeFlags = (self) => summarized(self, zip2(fiberRefs2, runtimeFlags), ([refs, flags], [refsNew, flagsNew]) => [diff5(refs, refsNew), diff4(flags, flagsNew)]);
|
|
6928
6926
|
var match8 = /* @__PURE__ */ dual(2, (self, options3) => matchEffect(self, {
|
|
@@ -10636,27 +10634,6 @@ var Latch = class extends Class2 {
|
|
|
10636
10634
|
};
|
|
10637
10635
|
};
|
|
10638
10636
|
var unsafeMakeLatch = (open) => new Latch(open ?? false);
|
|
10639
|
-
var cached2 = /* @__PURE__ */ dual(2, (self, timeToLive) => map11(cachedInvalidateWithTTL(self, timeToLive), (tuple) => tuple[0]));
|
|
10640
|
-
var cachedInvalidateWithTTL = /* @__PURE__ */ dual(2, (self, timeToLive) => {
|
|
10641
|
-
const duration = decode(timeToLive);
|
|
10642
|
-
return flatMap7(context(), (env) => map11(makeSynchronized(none2()), (cache) => [provideContext(getCachedValue(self, duration, cache), env), invalidateCache(cache)]));
|
|
10643
|
-
});
|
|
10644
|
-
var computeCachedValue = (self, timeToLive, start3) => {
|
|
10645
|
-
const timeToLiveMillis = toMillis(decode(timeToLive));
|
|
10646
|
-
return pipe(deferredMake(), tap((deferred) => intoDeferred(self, deferred)), map11((deferred) => some2([start3 + timeToLiveMillis, deferred])));
|
|
10647
|
-
};
|
|
10648
|
-
var getCachedValue = (self, timeToLive, cache) => uninterruptibleMask((restore) => pipe(clockWith3((clock3) => clock3.currentTimeMillis), flatMap7((time) => updateSomeAndGetEffectSynchronized(cache, (option2) => {
|
|
10649
|
-
switch (option2._tag) {
|
|
10650
|
-
case "None": {
|
|
10651
|
-
return some2(computeCachedValue(self, timeToLive, time));
|
|
10652
|
-
}
|
|
10653
|
-
case "Some": {
|
|
10654
|
-
const [end3] = option2.value;
|
|
10655
|
-
return end3 - time <= 0 ? some2(computeCachedValue(self, timeToLive, time)) : none2();
|
|
10656
|
-
}
|
|
10657
|
-
}
|
|
10658
|
-
})), flatMap7((option2) => isNone2(option2) ? dieMessage("BUG: Effect.cachedInvalidate - please report an issue at https://github.com/Effect-TS/effect/issues") : restore(deferredAwait(option2.value[1])))));
|
|
10659
|
-
var invalidateCache = (cache) => set4(cache, none2());
|
|
10660
10637
|
var forkIn = /* @__PURE__ */ dual(2, (self, scope4) => withFiberRuntime((parent, parentStatus) => {
|
|
10661
10638
|
const scopeImpl = scope4;
|
|
10662
10639
|
const fiber = unsafeFork2(self, parent, parentStatus.runtimeFlags, globalScope);
|
|
@@ -10708,17 +10685,6 @@ var unsafeMakeSynchronized = (value2) => {
|
|
|
10708
10685
|
const sem = unsafeMakeSemaphore(1);
|
|
10709
10686
|
return new SynchronizedImpl(ref, sem.withPermits(1));
|
|
10710
10687
|
};
|
|
10711
|
-
var updateSomeAndGetEffectSynchronized = /* @__PURE__ */ dual(2, (self, pf) => self.modifyEffect((value2) => {
|
|
10712
|
-
const result = pf(value2);
|
|
10713
|
-
switch (result._tag) {
|
|
10714
|
-
case "None": {
|
|
10715
|
-
return succeed([value2, value2]);
|
|
10716
|
-
}
|
|
10717
|
-
case "Some": {
|
|
10718
|
-
return map11(result.value, (a) => [a, a]);
|
|
10719
|
-
}
|
|
10720
|
-
}
|
|
10721
|
-
}));
|
|
10722
10688
|
|
|
10723
10689
|
// ../../../node_modules/.pnpm/effect@3.15.2/node_modules/effect/dist/esm/internal/managedRuntime/circular.js
|
|
10724
10690
|
var TypeId13 = /* @__PURE__ */ Symbol.for("effect/ManagedRuntime");
|
|
@@ -11351,7 +11317,6 @@ var pollUpTo = /* @__PURE__ */ dual(2, (self, n) => {
|
|
|
11351
11317
|
|
|
11352
11318
|
// ../../../node_modules/.pnpm/effect@3.15.2/node_modules/effect/dist/esm/Effect.js
|
|
11353
11319
|
var isEffect2 = isEffect;
|
|
11354
|
-
var cachedWithTTL = cached2;
|
|
11355
11320
|
var cached3 = memoize;
|
|
11356
11321
|
var all4 = all3;
|
|
11357
11322
|
var forEach8 = forEach7;
|
|
@@ -13565,8 +13530,8 @@ var go = (ast, isDecoding) => {
|
|
|
13565
13530
|
};
|
|
13566
13531
|
}
|
|
13567
13532
|
case "Suspend": {
|
|
13568
|
-
const
|
|
13569
|
-
return (a, options3) =>
|
|
13533
|
+
const get19 = memoizeThunk(() => goMemo(annotations(ast.f(), ast.annotations), isDecoding));
|
|
13534
|
+
return (a, options3) => get19()(a, options3);
|
|
13570
13535
|
}
|
|
13571
13536
|
}
|
|
13572
13537
|
};
|
|
@@ -17080,55 +17045,9 @@ var UnitPriceMeasurement = Struct({
|
|
|
17080
17045
|
reference_unit: String$,
|
|
17081
17046
|
reference_value: Number$
|
|
17082
17047
|
});
|
|
17083
|
-
var VariantQuantityRule = Struct({
|
|
17084
|
-
min: NullOr(Number$),
|
|
17085
|
-
max: NullOr(Number$),
|
|
17086
|
-
increment: Number$
|
|
17087
|
-
});
|
|
17088
17048
|
var VariantOptions = optionalWith(Array$(String$), {
|
|
17089
17049
|
default: () => []
|
|
17090
17050
|
});
|
|
17091
|
-
var BaseVariant = Struct({
|
|
17092
|
-
id: Resource_exports.ID,
|
|
17093
|
-
title: String$,
|
|
17094
|
-
options: VariantOptions,
|
|
17095
|
-
quantity_rule: VariantQuantityRule
|
|
17096
|
-
});
|
|
17097
|
-
var ProductOption = Struct({
|
|
17098
|
-
name: String$,
|
|
17099
|
-
position: Number$,
|
|
17100
|
-
values: Array$(String$)
|
|
17101
|
-
});
|
|
17102
|
-
var BaseProduct = Struct({
|
|
17103
|
-
id: Resource_exports.ID,
|
|
17104
|
-
title: String$,
|
|
17105
|
-
handle: String$,
|
|
17106
|
-
variants: Array$(BaseVariant),
|
|
17107
|
-
options: Array$(ProductOption),
|
|
17108
|
-
tags: Array$(String$)
|
|
17109
|
-
});
|
|
17110
|
-
var get14 = (url) => tryPromise2({
|
|
17111
|
-
try: () => fetch(url).then((res) => {
|
|
17112
|
-
if (res.ok) {
|
|
17113
|
-
return res.json();
|
|
17114
|
-
}
|
|
17115
|
-
throw new Error(String(res.status));
|
|
17116
|
-
}),
|
|
17117
|
-
catch: (e) => new Error(String(e))
|
|
17118
|
-
});
|
|
17119
|
-
var cachedGet = (url) => gen2(function* () {
|
|
17120
|
-
const cache = yield* cachedWithTTL(get14(url), "60 minutes");
|
|
17121
|
-
return yield* cache;
|
|
17122
|
-
});
|
|
17123
|
-
var Product = transformOrFail(String$, BaseProduct, {
|
|
17124
|
-
decode(handle, _, ast) {
|
|
17125
|
-
return mapBoth3(cachedGet(`/products/${handle}.js`), {
|
|
17126
|
-
onFailure: (e) => new Type2(ast, handle, e.message),
|
|
17127
|
-
onSuccess: (product) => product
|
|
17128
|
-
});
|
|
17129
|
-
},
|
|
17130
|
-
encode: (product) => succeed8(product.handle)
|
|
17131
|
-
});
|
|
17132
17051
|
var BaseLineItem = Struct({
|
|
17133
17052
|
id: Resource_exports.ID,
|
|
17134
17053
|
properties: BaseAttributes,
|
|
@@ -17179,7 +17098,6 @@ var LineItem = transform2(
|
|
|
17179
17098
|
extend3(
|
|
17180
17099
|
BaseLineItem,
|
|
17181
17100
|
Struct({
|
|
17182
|
-
product: Product,
|
|
17183
17101
|
properties_array: optionalWith(BaseAttributesArray, {
|
|
17184
17102
|
default: () => []
|
|
17185
17103
|
}),
|
|
@@ -17203,7 +17121,6 @@ var LineItem = transform2(
|
|
|
17203
17121
|
{
|
|
17204
17122
|
decode: (lineItem) => ({
|
|
17205
17123
|
...lineItem,
|
|
17206
|
-
product: lineItem.handle,
|
|
17207
17124
|
properties_array: lineItem.properties,
|
|
17208
17125
|
private_properties: lineItem.properties,
|
|
17209
17126
|
private_properties_array: lineItem.properties,
|
|
@@ -17215,8 +17132,7 @@ var LineItem = transform2(
|
|
|
17215
17132
|
remove("private_properties"),
|
|
17216
17133
|
remove("private_properties_array"),
|
|
17217
17134
|
remove("public_properties"),
|
|
17218
|
-
remove("public_properties_array")
|
|
17219
|
-
remove("product")
|
|
17135
|
+
remove("public_properties_array")
|
|
17220
17136
|
)
|
|
17221
17137
|
}
|
|
17222
17138
|
);
|
|
@@ -17900,7 +17816,7 @@ var make50 = (method) => (url, options3) => modify4(empty35, {
|
|
|
17900
17816
|
url,
|
|
17901
17817
|
...options3 ?? void 0
|
|
17902
17818
|
});
|
|
17903
|
-
var
|
|
17819
|
+
var get15 = /* @__PURE__ */ make50("GET");
|
|
17904
17820
|
var post = /* @__PURE__ */ make50("POST");
|
|
17905
17821
|
var put = /* @__PURE__ */ make50("PUT");
|
|
17906
17822
|
var patch9 = /* @__PURE__ */ make50("PATCH");
|
|
@@ -18102,7 +18018,7 @@ var ClientProto = {
|
|
|
18102
18018
|
};
|
|
18103
18019
|
},
|
|
18104
18020
|
get(url, options3) {
|
|
18105
|
-
return this.execute(
|
|
18021
|
+
return this.execute(get15(url, options3));
|
|
18106
18022
|
},
|
|
18107
18023
|
head(url, options3) {
|
|
18108
18024
|
return this.execute(head5(url, options3));
|
|
@@ -18298,7 +18214,7 @@ var {
|
|
|
18298
18214
|
/** @internal */
|
|
18299
18215
|
execute: execute2,
|
|
18300
18216
|
/** @internal */
|
|
18301
|
-
get:
|
|
18217
|
+
get: get16,
|
|
18302
18218
|
/** @internal */
|
|
18303
18219
|
head: head6,
|
|
18304
18220
|
/** @internal */
|
|
@@ -18320,7 +18236,7 @@ var layerMergedContext = (effect3) => effect(tag, flatMap10(context2(), (context
|
|
|
18320
18236
|
var HttpClient = tag;
|
|
18321
18237
|
|
|
18322
18238
|
// ../../../node_modules/.pnpm/@effect+platform@0.82.4_effect@3.15.2/node_modules/@effect/platform/dist/esm/HttpClientRequest.js
|
|
18323
|
-
var
|
|
18239
|
+
var get17 = get15;
|
|
18324
18240
|
var post3 = post;
|
|
18325
18241
|
var setUrlParams2 = setUrlParams;
|
|
18326
18242
|
var bodyJson2 = bodyJson;
|
|
@@ -18328,13 +18244,13 @@ var bodyJson2 = bodyJson;
|
|
|
18328
18244
|
// ../../../node_modules/.pnpm/@effect+platform@0.82.4_effect@3.15.2/node_modules/@effect/platform/dist/esm/internal/fetchHttpClient.js
|
|
18329
18245
|
var fetchTagKey = "@effect/platform/FetchHttpClient/Fetch";
|
|
18330
18246
|
var requestInitTagKey = "@effect/platform/FetchHttpClient/FetchOptions";
|
|
18331
|
-
var
|
|
18247
|
+
var fetch = /* @__PURE__ */ make51((request, url, signal, fiber) => {
|
|
18332
18248
|
const context5 = fiber.getFiberRef(currentContext2);
|
|
18333
|
-
const
|
|
18249
|
+
const fetch2 = context5.unsafeMap.get(fetchTagKey) ?? globalThis.fetch;
|
|
18334
18250
|
const options3 = context5.unsafeMap.get(requestInitTagKey) ?? {};
|
|
18335
18251
|
const headers = options3.headers ? merge8(fromInput2(options3.headers), request.headers) : request.headers;
|
|
18336
18252
|
const send = (body) => map17(tryPromise2({
|
|
18337
|
-
try: () =>
|
|
18253
|
+
try: () => fetch2(url, {
|
|
18338
18254
|
...options3,
|
|
18339
18255
|
method: request.method,
|
|
18340
18256
|
headers,
|
|
@@ -18359,7 +18275,7 @@ var fetch2 = /* @__PURE__ */ make51((request, url, signal, fiber) => {
|
|
|
18359
18275
|
}
|
|
18360
18276
|
return send(void 0);
|
|
18361
18277
|
});
|
|
18362
|
-
var layer = /* @__PURE__ */ layerMergedContext(/* @__PURE__ */ succeed7(
|
|
18278
|
+
var layer = /* @__PURE__ */ layerMergedContext(/* @__PURE__ */ succeed7(fetch));
|
|
18363
18279
|
|
|
18364
18280
|
// ../../../node_modules/.pnpm/@effect+platform@0.82.4_effect@3.15.2/node_modules/@effect/platform/dist/esm/FetchHttpClient.js
|
|
18365
18281
|
var layer2 = layer;
|
|
@@ -18419,7 +18335,7 @@ var makeFactory = ({
|
|
|
18419
18335
|
}
|
|
18420
18336
|
}).pipe(bodyJson2(decodedInput));
|
|
18421
18337
|
} else if (method === "get") {
|
|
18422
|
-
request =
|
|
18338
|
+
request = get17(url, {
|
|
18423
18339
|
acceptJson: true
|
|
18424
18340
|
}).pipe(setUrlParams2(decodedInput));
|
|
18425
18341
|
} else {
|
|
@@ -18527,11 +18443,11 @@ var make57 = makeFactory({
|
|
|
18527
18443
|
var add6 = make53;
|
|
18528
18444
|
var change = make54;
|
|
18529
18445
|
var clear = make55;
|
|
18530
|
-
var
|
|
18446
|
+
var get18 = make56;
|
|
18531
18447
|
var update5 = make57;
|
|
18532
18448
|
|
|
18533
18449
|
// src/index.ts
|
|
18534
|
-
var validateCart = (cart) =>
|
|
18450
|
+
var validateCart = (cart) => runSync(decodeUnknown2(CartOutput)(cart));
|
|
18535
18451
|
var createAjaxCartApi = ({ debug = false }) => {
|
|
18536
18452
|
let baseLayer = empty30;
|
|
18537
18453
|
let minimumLogLevel2 = None3;
|
|
@@ -18639,7 +18555,7 @@ var createAjaxCartApi = ({ debug = false }) => {
|
|
|
18639
18555
|
}
|
|
18640
18556
|
),
|
|
18641
18557
|
get: (input, options3) => runPromise(
|
|
18642
|
-
|
|
18558
|
+
get18(input).pipe(
|
|
18643
18559
|
withMinimumLogLevel2(minimumLogLevel2),
|
|
18644
18560
|
provide2(ajaxLayer),
|
|
18645
18561
|
catchAll2((error) => {
|