@brytdesigns/shopify-utils 1.2.22 → 3.1.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/dist/effect/Actions/bridge.js +71 -0
- package/dist/effect/Actions/bridge.js.map +1 -0
- package/dist/effect/Actions/errors.js +46 -0
- package/dist/effect/Actions/errors.js.map +1 -0
- package/dist/effect/Actions/index.js +23 -0
- package/dist/effect/Actions/index.js.map +1 -0
- package/dist/effect/Actions/service.js +127 -0
- package/dist/effect/Actions/service.js.map +1 -0
- package/dist/effect/Actions/trampoline.js +26 -0
- package/dist/effect/Actions/trampoline.js.map +1 -0
- package/dist/effect/Ajax/Sections/index.js +2 -4
- package/dist/effect/Ajax/Sections/schema.js +28 -39
- package/dist/effect/Ajax/Sections/schema.js.map +1 -1
- package/dist/effect/Ajax/Window/data/AllowedRouteOrigins.js +75 -0
- package/dist/effect/Ajax/Window/data/AllowedRouteOrigins.js.map +1 -0
- package/dist/effect/Ajax/Window/data/ShopifyRoutes.js +86 -37
- package/dist/effect/Ajax/Window/data/ShopifyRoutes.js.map +1 -1
- package/dist/effect/Ajax/Window/data/StorefrontClientConfig.js +14 -13
- package/dist/effect/Ajax/Window/data/StorefrontClientConfig.js.map +1 -1
- package/dist/effect/Ajax/Window/data/StorefrontOrigin.js +32 -0
- package/dist/effect/Ajax/Window/data/StorefrontOrigin.js.map +1 -0
- package/dist/effect/Ajax/Window/data/index.js +15 -5
- package/dist/effect/Ajax/Window/data/index.js.map +1 -1
- package/dist/effect/Ajax/Window/index.js +2 -4
- package/dist/effect/Ajax/index.js +13 -3
- package/dist/effect/Ajax/index.js.map +1 -1
- package/dist/effect/Logging/index.js +13 -10
- package/dist/effect/Logging/index.js.map +1 -1
- package/dist/effect/Resource/data.js +20 -30
- package/dist/effect/Resource/data.js.map +1 -1
- package/dist/effect/Resource/index.js +14 -3
- package/dist/effect/Resource/index.js.map +1 -1
- package/dist/effect/Resource/schema.js +46 -45
- package/dist/effect/Resource/schema.js.map +1 -1
- package/dist/effect/Schemas/index.js +75 -0
- package/dist/effect/Schemas/index.js.map +1 -0
- package/dist/effect/_virtual/_rolldown/runtime.js +13 -0
- package/dist/effect/index.d.ts +396 -62
- package/dist/effect/index.js +6 -8
- package/dist/main/_virtual/_rolldown/runtime.js +13 -0
- package/dist/main/actions.js +78 -0
- package/dist/main/actions.js.map +1 -0
- package/dist/main/effect/Actions/bridge.js +65 -0
- package/dist/main/effect/Actions/bridge.js.map +1 -0
- package/dist/main/effect/Actions/errors.js +46 -0
- package/dist/main/effect/Actions/errors.js.map +1 -0
- package/dist/main/effect/Actions/index.js +4 -0
- package/dist/main/effect/Actions/service.js +127 -0
- package/dist/main/effect/Actions/service.js.map +1 -0
- package/dist/main/effect/Actions/trampoline.js +26 -0
- package/dist/main/effect/Actions/trampoline.js.map +1 -0
- package/dist/main/effect/Ajax/Sections/index.js +1 -4
- package/dist/main/effect/Ajax/Sections/schema.js +11 -41
- package/dist/main/effect/Ajax/Sections/schema.js.map +1 -1
- package/dist/main/effect/Ajax/Window/data/AllowedRouteOrigins.js +18 -0
- package/dist/main/effect/Ajax/Window/data/AllowedRouteOrigins.js.map +1 -0
- package/dist/main/effect/Ajax/Window/data/ShopifyRoutes.js +37 -37
- package/dist/main/effect/Ajax/Window/data/ShopifyRoutes.js.map +1 -1
- package/dist/main/effect/Ajax/Window/data/StorefrontClientConfig.js +3 -14
- package/dist/main/effect/Ajax/Window/data/StorefrontClientConfig.js.map +1 -1
- package/dist/main/effect/Ajax/Window/data/StorefrontOrigin.js +6 -0
- package/dist/main/effect/Ajax/Window/data/StorefrontOrigin.js.map +1 -0
- package/dist/main/effect/Ajax/Window/data/index.js +4 -6
- package/dist/main/effect/Ajax/Window/index.js +1 -4
- package/dist/main/effect/Ajax/index.js +2 -4
- package/dist/main/effect/Logging/index.js +2 -13
- package/dist/main/effect/Resource/data.js +20 -30
- package/dist/main/effect/Resource/data.js.map +1 -1
- package/dist/main/effect/Resource/index.js +3 -4
- package/dist/main/effect/Resource/schema.js +46 -45
- package/dist/main/effect/Resource/schema.js.map +1 -1
- package/dist/main/effect/Schemas/index.js +28 -0
- package/dist/main/effect/Schemas/index.js.map +1 -0
- package/dist/main/effect/index.js +5 -8
- package/dist/main/index.d.ts +359 -11
- package/dist/main/index.js +3 -3
- package/dist/main/resources/index.js +8 -7
- package/dist/main/resources/index.js.map +1 -1
- package/package.json +9 -9
- package/dist/effect/Ajax/Sections/index.js.map +0 -1
- package/dist/effect/Ajax/Window/data/types.js +0 -3
- package/dist/effect/Ajax/Window/data/types.js.map +0 -1
- package/dist/effect/Ajax/Window/index.js.map +0 -1
- package/dist/effect/index.js.map +0 -1
- package/dist/index.d.ts +0 -77
- package/dist/jsdelivr/effect/Ajax/Sections/index.js +0 -4
- package/dist/jsdelivr/effect/Ajax/Sections/index.js.map +0 -1
- package/dist/jsdelivr/effect/Ajax/Sections/schema.js +0 -20
- package/dist/jsdelivr/effect/Ajax/Sections/schema.js.map +0 -1
- package/dist/jsdelivr/effect/Ajax/Window/data/ShopifyRoutes.js +0 -38
- package/dist/jsdelivr/effect/Ajax/Window/data/ShopifyRoutes.js.map +0 -1
- package/dist/jsdelivr/effect/Ajax/Window/data/StorefrontClientConfig.js +0 -16
- package/dist/jsdelivr/effect/Ajax/Window/data/StorefrontClientConfig.js.map +0 -1
- package/dist/jsdelivr/effect/Ajax/Window/data/index.js +0 -6
- package/dist/jsdelivr/effect/Ajax/Window/data/index.js.map +0 -1
- package/dist/jsdelivr/effect/Ajax/Window/data/types.js +0 -3
- package/dist/jsdelivr/effect/Ajax/Window/data/types.js.map +0 -1
- package/dist/jsdelivr/effect/Ajax/Window/index.js +0 -4
- package/dist/jsdelivr/effect/Ajax/Window/index.js.map +0 -1
- package/dist/jsdelivr/effect/Ajax/index.js +0 -4
- package/dist/jsdelivr/effect/Ajax/index.js.map +0 -1
- package/dist/jsdelivr/effect/Logging/index.js +0 -13
- package/dist/jsdelivr/effect/Logging/index.js.map +0 -1
- package/dist/jsdelivr/effect/Resource/data.js +0 -17
- package/dist/jsdelivr/effect/Resource/data.js.map +0 -1
- package/dist/jsdelivr/effect/Resource/index.js +0 -4
- package/dist/jsdelivr/effect/Resource/index.js.map +0 -1
- package/dist/jsdelivr/effect/Resource/schema.js +0 -47
- package/dist/jsdelivr/effect/Resource/schema.js.map +0 -1
- package/dist/jsdelivr/effect/index.js +0 -8
- package/dist/jsdelivr/effect/index.js.map +0 -1
- package/dist/jsdelivr/index.js +0 -3
- package/dist/jsdelivr/index.js.map +0 -1
- package/dist/jsdelivr/resources/index.js +0 -9
- package/dist/jsdelivr/resources/index.js.map +0 -1
- package/dist/main/effect/Ajax/Sections/index.js.map +0 -1
- package/dist/main/effect/Ajax/Window/data/index.js.map +0 -1
- package/dist/main/effect/Ajax/Window/data/types.js +0 -3
- package/dist/main/effect/Ajax/Window/data/types.js.map +0 -1
- package/dist/main/effect/Ajax/Window/index.js.map +0 -1
- package/dist/main/effect/Ajax/index.js.map +0 -1
- package/dist/main/effect/Logging/index.js.map +0 -1
- package/dist/main/effect/Resource/index.js.map +0 -1
- package/dist/main/effect/index.js.map +0 -1
- package/dist/main/index.js.map +0 -1
|
@@ -1,13 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import 'effect/LogLevel';
|
|
4
|
-
|
|
5
|
-
const filterLevelOrNever = (level, effect) => Effect.gen(function* () {
|
|
6
|
-
const logLevel = yield* FiberRef.get(FiberRef.currentMinimumLogLevel);
|
|
7
|
-
if (logLevel._tag !== level._tag) return yield* effect;
|
|
8
|
-
});
|
|
9
|
-
const makeNamespacedLogSpan = (prefix) => (label) => Effect.withLogSpan(`${prefix}:${label}`);
|
|
10
|
-
|
|
11
|
-
export { filterLevelOrNever, makeNamespacedLogSpan };
|
|
12
|
-
//# sourceMappingURL=index.js.map
|
|
13
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
import "effect/Effect";
|
|
2
|
+
import "effect/References";
|
|
@@ -1,33 +1,23 @@
|
|
|
1
|
-
import
|
|
2
|
-
import * as
|
|
3
|
-
import * as
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}) => Effect.gen(function* () {
|
|
10
|
-
const [actualId, actualType] = yield* Effect.all(
|
|
11
|
-
[Schema.decode(ID)(id), Schema.decode(Type)(type)],
|
|
12
|
-
{
|
|
13
|
-
concurrency: "unbounded"
|
|
14
|
-
}
|
|
15
|
-
);
|
|
16
|
-
return `gid://shopify/${actualType}/${actualId}`;
|
|
1
|
+
import { GID, ID, Type } from "./schema.js";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
import * as Schema from "effect/Schema";
|
|
4
|
+
import * as SchemaGetter from "effect/SchemaGetter";
|
|
5
|
+
//#region src/effect/Resource/data.ts
|
|
6
|
+
var format = ({ id, type }) => Effect.gen(function* () {
|
|
7
|
+
const [actualId, actualType] = yield* Effect.all([Schema.decodeEffect(ID)(id), Schema.decodeEffect(Type)(type)], { concurrency: "unbounded" });
|
|
8
|
+
return `gid://shopify/${actualType}/${actualId}`;
|
|
17
9
|
});
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
)(input);
|
|
30
|
-
|
|
10
|
+
/**
|
|
11
|
+
* v4 replaces `Schema.transformOrFail` with `decodeTo` plus `SchemaGetter`
|
|
12
|
+
* transformations. The decode direction never fails, so it is a plain
|
|
13
|
+
* `transform`; the encode direction is refused outright, which `forbidden`
|
|
14
|
+
* expresses directly rather than by constructing an issue by hand.
|
|
15
|
+
*/
|
|
16
|
+
var parse = (input) => Schema.decodeEffect(GID.pipe(Schema.decodeTo(ID, {
|
|
17
|
+
decode: SchemaGetter.transform((value) => `${value}`.split("/").pop()),
|
|
18
|
+
encode: SchemaGetter.forbidden(() => "Encoding an ID to a GID is not allowed. Use the format function to convert IDs to GIDs.")
|
|
19
|
+
})))(input);
|
|
20
|
+
//#endregion
|
|
31
21
|
export { format, parse };
|
|
32
|
-
|
|
22
|
+
|
|
33
23
|
//# sourceMappingURL=data.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"data.js","names":[],"sources":["../../../../src/effect/Resource/data.ts"],"sourcesContent":["import * as Effect from \"effect/Effect\";\nimport * as Schema from \"effect/Schema\";\nimport * as SchemaGetter from \"effect/SchemaGetter\";\nimport { GID, ID, Type } from \"./schema.js\";\n\ntype FormatOptions<T extends ID, R extends Type> = {\n\tid: T;\n\ttype: R;\n};\n\nexport const format = <const T extends ID, const R extends Type>({\n\tid,\n\ttype,\n}: FormatOptions<T, R>) =>\n\tEffect.gen(function* () {\n\t\tconst [actualId, actualType] = yield* Effect.all(\n\t\t\t[Schema.decodeEffect(ID)(id), Schema.decodeEffect(Type)(type)],\n\t\t\t{\n\t\t\t\tconcurrency: \"unbounded\",\n\t\t\t},\n\t\t);\n\t\treturn `gid://shopify/${actualType}/${actualId}` as `gid://shopify/${R}/${T}`;\n\t});\n\n/**\n * v4 replaces `Schema.transformOrFail` with `decodeTo` plus `SchemaGetter`\n * transformations. The decode direction never fails, so it is a plain\n * `transform`; the encode direction is refused outright, which `forbidden`\n * expresses directly rather than by constructing an issue by hand.\n */\nexport const parse = (input: string) =>\n\tSchema.decodeEffect(\n\t\tGID.pipe(\n\t\t\tSchema.decodeTo(ID, {\n\t\t\t\tdecode: SchemaGetter.transform(\n\t\t\t\t\t(value: string) => `${value}`.split(\"/\").pop() as ID,\n\t\t\t\t),\n\t\t\t\tencode: SchemaGetter.forbidden(\n\t\t\t\t\t() =>\n\t\t\t\t\t\t\"Encoding an ID to a GID is not allowed. Use the format function to convert IDs to GIDs.\",\n\t\t\t\t),\n\t\t\t}),\n\t\t),\n\t)(input);\n"],"mappings":";;;;;AAUA,IAAa,UAAoD,EAChE,IACA,WAEA,OAAO,IAAI,aAAa;CACvB,MAAM,CAAC,UAAU,cAAc,OAAO,OAAO,IAC5C,CAAC,OAAO,aAAa,EAAE,CAAC,CAAC,EAAE,GAAG,OAAO,aAAa,IAAI,CAAC,CAAC,IAAI,CAAC,GAC7D,EACC,aAAa,YACd,CACD;CACA,OAAO,iBAAiB,WAAW,GAAG;AACvC,CAAC;;;;;;;AAQF,IAAa,SAAS,UACrB,OAAO,aACN,IAAI,KACH,OAAO,SAAS,IAAI;CACnB,QAAQ,aAAa,WACnB,UAAkB,GAAG,QAAQ,MAAM,GAAG,CAAC,CAAC,IAAI,CAC9C;CACA,QAAQ,aAAa,gBAEnB,yFACF;AACD,CAAC,CACF,CACD,CAAC,CAAC,KAAK"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
import "./schema.js";
|
|
2
|
+
import { format, parse } from "./data.js";
|
|
3
|
+
export { format, parse };
|
|
@@ -1,47 +1,48 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
1
|
+
import { FiniteFromNumericString } from "../Schemas/index.js";
|
|
2
|
+
import * as Schema from "effect/Schema";
|
|
3
|
+
//#region src/effect/Resource/schema.ts
|
|
4
|
+
var Type = Schema.Literals([
|
|
5
|
+
"Cart",
|
|
6
|
+
"Collection",
|
|
7
|
+
"Customer",
|
|
8
|
+
"DeliveryCarrierService",
|
|
9
|
+
"DeliveryLocationGroup",
|
|
10
|
+
"DeliveryProfile",
|
|
11
|
+
"DeliveryZone",
|
|
12
|
+
"DraftOrder",
|
|
13
|
+
"DraftOrderLineItem",
|
|
14
|
+
"Duty",
|
|
15
|
+
"EmailTemplate",
|
|
16
|
+
"Fulfillment",
|
|
17
|
+
"FulfullmentEvent",
|
|
18
|
+
"FullfullmentService",
|
|
19
|
+
"InventoryItem",
|
|
20
|
+
"InventoryLevel",
|
|
21
|
+
"LineItem",
|
|
22
|
+
"Location",
|
|
23
|
+
"MarketingEvent",
|
|
24
|
+
"MediaImage",
|
|
25
|
+
"Metafield",
|
|
26
|
+
"OnlineStoreArticle",
|
|
27
|
+
"OnlineStoreBlog",
|
|
28
|
+
"OnlineStorePage",
|
|
29
|
+
"Order",
|
|
30
|
+
"OrderTransaction",
|
|
31
|
+
"Product",
|
|
32
|
+
"ProductImage",
|
|
33
|
+
"ProductVariant",
|
|
34
|
+
"Refund",
|
|
35
|
+
"Shop",
|
|
36
|
+
"StaffMember",
|
|
37
|
+
"Theme"
|
|
38
|
+
]);
|
|
39
|
+
var GID = Schema.String.check(Schema.isStartingWith("gid://shopify/"));
|
|
40
|
+
var ID = Schema.Union([
|
|
41
|
+
Schema.Number,
|
|
42
|
+
FiniteFromNumericString,
|
|
43
|
+
Schema.String
|
|
44
|
+
]);
|
|
45
|
+
//#endregion
|
|
45
46
|
export { GID, ID, Type };
|
|
46
|
-
|
|
47
|
+
|
|
47
48
|
//# sourceMappingURL=schema.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"schema.js","names":[],"sources":["../../../../src/effect/Resource/schema.ts"],"sourcesContent":["import * as Schema from \"effect/Schema\";\nimport * as Schemas from \"../Schemas/index.js\";\n\nexport type Type = Schema.Schema.Type<typeof Type>;\nexport const Type = Schema.Literals([\n\t\"Cart\",\n\t\"Collection\",\n\t\"Customer\",\n\t\"DeliveryCarrierService\",\n\t\"DeliveryLocationGroup\",\n\t\"DeliveryProfile\",\n\t\"DeliveryZone\",\n\t\"DraftOrder\",\n\t\"DraftOrderLineItem\",\n\t\"Duty\",\n\t\"EmailTemplate\",\n\t\"Fulfillment\",\n\t\"FulfullmentEvent\",\n\t\"FullfullmentService\",\n\t\"InventoryItem\",\n\t\"InventoryLevel\",\n\t\"LineItem\",\n\t\"Location\",\n\t\"MarketingEvent\",\n\t\"MediaImage\",\n\t\"Metafield\",\n\t\"OnlineStoreArticle\",\n\t\"OnlineStoreBlog\",\n\t\"OnlineStorePage\",\n\t\"Order\",\n\t\"OrderTransaction\",\n\t\"Product\",\n\t\"ProductImage\",\n\t\"ProductVariant\",\n\t\"Refund\",\n\t\"Shop\",\n\t\"StaffMember\",\n\t\"Theme\",\n]);\n\nexport type GID = Schema.Codec.Encoded<typeof GID>;\nexport const GID = Schema.String.check(Schema.isStartingWith(\"gid://shopify/\"));\n\n/**\n * A Shopify id: a number, a numeric string decoded to one, or any other\n * string left as it is - a line item key, a handle, an empty string.\n *\n * The middle member was `Schema.NumberFromString`, which in Effect 4 never\n * fails, so `String` was unreachable and every non-numeric id decoded to NaN.\n * See `Schemas.FiniteFromNumericString`.\n */\nexport type ID = Schema.Codec.Encoded<typeof ID>;\nexport const ID = Schema.Union([\n\tSchema.Number,\n\tSchemas.FiniteFromNumericString,\n\tSchema.String,\n]);\n"],"mappings":";;;AAIA,IAAa,OAAO,OAAO,SAAS;CACnC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACD,CAAC;AAGD,IAAa,MAAM,OAAO,OAAO,MAAM,OAAO,eAAe,gBAAgB,CAAC;AAW9E,IAAa,KAAK,OAAO,MAAM;CAC9B,OAAO;CACP;CACA,OAAO;AACR,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import "effect/Effect";
|
|
2
|
+
import * as Schema from "effect/Schema";
|
|
3
|
+
import * as SchemaIssue from "effect/SchemaIssue";
|
|
4
|
+
import "effect/Array";
|
|
5
|
+
import "effect/Option";
|
|
6
|
+
import "effect/SchemaParser";
|
|
7
|
+
import * as SchemaTransformation from "effect/SchemaTransformation";
|
|
8
|
+
SchemaIssue.makeFormatterDefault();
|
|
9
|
+
/**
|
|
10
|
+
* A string holding a number, decoded to that number. Anything else fails.
|
|
11
|
+
*
|
|
12
|
+
* What Effect 3's `Schema.NumberFromString` was, and Effect 4's is not. v4's
|
|
13
|
+
* is plain `Number(s)` and never fails: "abc" decodes to NaN, and "" and
|
|
14
|
+
* whitespace to 0. `Schema.FiniteFromString` rejects NaN and Infinity but
|
|
15
|
+
* still reads a blank string as 0. Neither is safe in a union whose later
|
|
16
|
+
* members are meant to catch what the numeric one refuses, and neither should
|
|
17
|
+
* turn a missing price into a free product.
|
|
18
|
+
*
|
|
19
|
+
* Accepts what v3 accepted, minus the non-finite values: a string with at
|
|
20
|
+
* least one non-whitespace character that `Number()` reads as finite. So
|
|
21
|
+
* `"10.00"` is 10, `" 42 "` is 42, and `""`, `" "`, `"abc"` and `"NaN"`
|
|
22
|
+
* fail.
|
|
23
|
+
*/
|
|
24
|
+
var FiniteFromNumericString = Schema.String.check(Schema.isPattern(/\S/, { expected: "a non-blank string" })).pipe(Schema.decodeTo(Schema.Finite, SchemaTransformation.numberFromString));
|
|
25
|
+
//#endregion
|
|
26
|
+
export { FiniteFromNumericString };
|
|
27
|
+
|
|
28
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../../src/effect/Schemas/index.ts"],"sourcesContent":["import * as Arr from \"effect/Array\";\nimport * as Effect from \"effect/Effect\";\nimport * as Option from \"effect/Option\";\nimport * as Schema from \"effect/Schema\";\nimport * as SchemaIssue from \"effect/SchemaIssue\";\nimport * as SchemaParser from \"effect/SchemaParser\";\nimport * as SchemaTransformation from \"effect/SchemaTransformation\";\n\nconst formatIssue = SchemaIssue.makeFormatterDefault();\n\n/**\n * An array that decodes element by element and drops the elements that fail.\n *\n * `Schema.Array` fails the whole array on its first bad element, which is right\n * for a request body and wrong for a list of search results: one product with a\n * malformed price would reject every product, collection and page around it.\n * This keeps the rest.\n *\n * Built with `declareConstructor` rather than `Schema.Array(item.pipe(\n * Schema.catchDecoding(...)))`. Recovering to `Option.none()` inside an array\n * does not drop the element: v4's array parser reports a missing element as a\n * `MissingKey` issue, so the array fails anyway. A declaration owns the whole\n * array and can leave elements out.\n *\n * The type is `ReadonlyArray<Type>`, identical to `Schema.Array`'s, so a\n * schema can switch to this without changing what it decodes to. Input that is\n * not an array at all still fails: that is a broken response, not a bad item.\n *\n * Each dropped element is logged at `Debug` with its index and the issue, so\n * it is visible wherever the caller has turned debug logging on and silent\n * everywhere else.\n *\n * @example\n * ```ts\n * import { Schemas } from \"@brytdesigns/shopify-utils/effect\";\n *\n * const Results = Schema.Struct({\n * products: Schemas.ArrayDroppingInvalid(Product),\n * });\n * ```\n */\nexport const ArrayDroppingInvalid = <S extends Schema.Constraint>(item: S) =>\n\tSchema.declareConstructor<\n\t\tReadonlyArray<S[\"Type\"]>,\n\t\tReadonlyArray<S[\"Encoded\"]>\n\t>()([item], ([codec]) => {\n\t\tconst decode = SchemaParser.decodeUnknownEffect(codec);\n\n\t\treturn (input, ast, options) => {\n\t\t\tif (!Array.isArray(input)) {\n\t\t\t\treturn Effect.fail(new SchemaIssue.InvalidType(ast, input, options));\n\t\t\t}\n\n\t\t\treturn Effect.forEach(input, (element, index) =>\n\t\t\t\tdecode(element, options).pipe(\n\t\t\t\t\tEffect.map(Option.some),\n\t\t\t\t\tEffect.catch((issue) =>\n\t\t\t\t\t\tEffect.logDebug(\"Dropped an array element that failed to decode\", {\n\t\t\t\t\t\t\tindex,\n\t\t\t\t\t\t\tissue: formatIssue(issue),\n\t\t\t\t\t\t}).pipe(Effect.as(Option.none())),\n\t\t\t\t\t),\n\t\t\t\t),\n\t\t\t).pipe(Effect.map(Arr.getSomes));\n\t\t};\n\t});\n\n/**\n * A string holding a number, decoded to that number. Anything else fails.\n *\n * What Effect 3's `Schema.NumberFromString` was, and Effect 4's is not. v4's\n * is plain `Number(s)` and never fails: \"abc\" decodes to NaN, and \"\" and\n * whitespace to 0. `Schema.FiniteFromString` rejects NaN and Infinity but\n * still reads a blank string as 0. Neither is safe in a union whose later\n * members are meant to catch what the numeric one refuses, and neither should\n * turn a missing price into a free product.\n *\n * Accepts what v3 accepted, minus the non-finite values: a string with at\n * least one non-whitespace character that `Number()` reads as finite. So\n * `\"10.00\"` is 10, `\" 42 \"` is 42, and `\"\"`, `\" \"`, `\"abc\"` and `\"NaN\"`\n * fail.\n */\nexport const FiniteFromNumericString = Schema.String.check(\n\tSchema.isPattern(/\\S/, { expected: \"a non-blank string\" }),\n).pipe(Schema.decodeTo(Schema.Finite, SchemaTransformation.numberFromString));\n"],"mappings":";;;;;;;AAQoB,YAAY,qBAAqB;;;;;;;;;;;;;;;;AA0ErD,IAAa,0BAA0B,OAAO,OAAO,MACpD,OAAO,UAAU,MAAM,EAAE,UAAU,qBAAqB,CAAC,CAC1D,CAAC,CAAC,KAAK,OAAO,SAAS,OAAO,QAAQ,qBAAqB,gBAAgB,CAAC"}
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
import
|
|
6
|
-
export { index_js$1 as Logging };
|
|
7
|
-
//# sourceMappingURL=index.js.map
|
|
8
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
import "./Actions/index.js";
|
|
2
|
+
import "./Ajax/index.js";
|
|
3
|
+
import "./Logging/index.js";
|
|
4
|
+
import "./Schemas/index.js";
|
|
5
|
+
import "./Resource/index.js";
|