@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.
Files changed (125) hide show
  1. package/dist/effect/Actions/bridge.js +71 -0
  2. package/dist/effect/Actions/bridge.js.map +1 -0
  3. package/dist/effect/Actions/errors.js +46 -0
  4. package/dist/effect/Actions/errors.js.map +1 -0
  5. package/dist/effect/Actions/index.js +23 -0
  6. package/dist/effect/Actions/index.js.map +1 -0
  7. package/dist/effect/Actions/service.js +127 -0
  8. package/dist/effect/Actions/service.js.map +1 -0
  9. package/dist/effect/Actions/trampoline.js +26 -0
  10. package/dist/effect/Actions/trampoline.js.map +1 -0
  11. package/dist/effect/Ajax/Sections/index.js +2 -4
  12. package/dist/effect/Ajax/Sections/schema.js +28 -39
  13. package/dist/effect/Ajax/Sections/schema.js.map +1 -1
  14. package/dist/effect/Ajax/Window/data/AllowedRouteOrigins.js +75 -0
  15. package/dist/effect/Ajax/Window/data/AllowedRouteOrigins.js.map +1 -0
  16. package/dist/effect/Ajax/Window/data/ShopifyRoutes.js +86 -37
  17. package/dist/effect/Ajax/Window/data/ShopifyRoutes.js.map +1 -1
  18. package/dist/effect/Ajax/Window/data/StorefrontClientConfig.js +14 -13
  19. package/dist/effect/Ajax/Window/data/StorefrontClientConfig.js.map +1 -1
  20. package/dist/effect/Ajax/Window/data/StorefrontOrigin.js +32 -0
  21. package/dist/effect/Ajax/Window/data/StorefrontOrigin.js.map +1 -0
  22. package/dist/effect/Ajax/Window/data/index.js +15 -5
  23. package/dist/effect/Ajax/Window/data/index.js.map +1 -1
  24. package/dist/effect/Ajax/Window/index.js +2 -4
  25. package/dist/effect/Ajax/index.js +13 -3
  26. package/dist/effect/Ajax/index.js.map +1 -1
  27. package/dist/effect/Logging/index.js +13 -10
  28. package/dist/effect/Logging/index.js.map +1 -1
  29. package/dist/effect/Resource/data.js +20 -30
  30. package/dist/effect/Resource/data.js.map +1 -1
  31. package/dist/effect/Resource/index.js +14 -3
  32. package/dist/effect/Resource/index.js.map +1 -1
  33. package/dist/effect/Resource/schema.js +46 -45
  34. package/dist/effect/Resource/schema.js.map +1 -1
  35. package/dist/effect/Schemas/index.js +75 -0
  36. package/dist/effect/Schemas/index.js.map +1 -0
  37. package/dist/effect/_virtual/_rolldown/runtime.js +13 -0
  38. package/dist/effect/index.d.ts +396 -62
  39. package/dist/effect/index.js +6 -8
  40. package/dist/main/_virtual/_rolldown/runtime.js +13 -0
  41. package/dist/main/actions.js +78 -0
  42. package/dist/main/actions.js.map +1 -0
  43. package/dist/main/effect/Actions/bridge.js +65 -0
  44. package/dist/main/effect/Actions/bridge.js.map +1 -0
  45. package/dist/main/effect/Actions/errors.js +46 -0
  46. package/dist/main/effect/Actions/errors.js.map +1 -0
  47. package/dist/main/effect/Actions/index.js +4 -0
  48. package/dist/main/effect/Actions/service.js +127 -0
  49. package/dist/main/effect/Actions/service.js.map +1 -0
  50. package/dist/main/effect/Actions/trampoline.js +26 -0
  51. package/dist/main/effect/Actions/trampoline.js.map +1 -0
  52. package/dist/main/effect/Ajax/Sections/index.js +1 -4
  53. package/dist/main/effect/Ajax/Sections/schema.js +11 -41
  54. package/dist/main/effect/Ajax/Sections/schema.js.map +1 -1
  55. package/dist/main/effect/Ajax/Window/data/AllowedRouteOrigins.js +18 -0
  56. package/dist/main/effect/Ajax/Window/data/AllowedRouteOrigins.js.map +1 -0
  57. package/dist/main/effect/Ajax/Window/data/ShopifyRoutes.js +37 -37
  58. package/dist/main/effect/Ajax/Window/data/ShopifyRoutes.js.map +1 -1
  59. package/dist/main/effect/Ajax/Window/data/StorefrontClientConfig.js +3 -14
  60. package/dist/main/effect/Ajax/Window/data/StorefrontClientConfig.js.map +1 -1
  61. package/dist/main/effect/Ajax/Window/data/StorefrontOrigin.js +6 -0
  62. package/dist/main/effect/Ajax/Window/data/StorefrontOrigin.js.map +1 -0
  63. package/dist/main/effect/Ajax/Window/data/index.js +4 -6
  64. package/dist/main/effect/Ajax/Window/index.js +1 -4
  65. package/dist/main/effect/Ajax/index.js +2 -4
  66. package/dist/main/effect/Logging/index.js +2 -13
  67. package/dist/main/effect/Resource/data.js +20 -30
  68. package/dist/main/effect/Resource/data.js.map +1 -1
  69. package/dist/main/effect/Resource/index.js +3 -4
  70. package/dist/main/effect/Resource/schema.js +46 -45
  71. package/dist/main/effect/Resource/schema.js.map +1 -1
  72. package/dist/main/effect/Schemas/index.js +28 -0
  73. package/dist/main/effect/Schemas/index.js.map +1 -0
  74. package/dist/main/effect/index.js +5 -8
  75. package/dist/main/index.d.ts +359 -11
  76. package/dist/main/index.js +3 -3
  77. package/dist/main/resources/index.js +8 -7
  78. package/dist/main/resources/index.js.map +1 -1
  79. package/package.json +9 -9
  80. package/dist/effect/Ajax/Sections/index.js.map +0 -1
  81. package/dist/effect/Ajax/Window/data/types.js +0 -3
  82. package/dist/effect/Ajax/Window/data/types.js.map +0 -1
  83. package/dist/effect/Ajax/Window/index.js.map +0 -1
  84. package/dist/effect/index.js.map +0 -1
  85. package/dist/index.d.ts +0 -77
  86. package/dist/jsdelivr/effect/Ajax/Sections/index.js +0 -4
  87. package/dist/jsdelivr/effect/Ajax/Sections/index.js.map +0 -1
  88. package/dist/jsdelivr/effect/Ajax/Sections/schema.js +0 -20
  89. package/dist/jsdelivr/effect/Ajax/Sections/schema.js.map +0 -1
  90. package/dist/jsdelivr/effect/Ajax/Window/data/ShopifyRoutes.js +0 -38
  91. package/dist/jsdelivr/effect/Ajax/Window/data/ShopifyRoutes.js.map +0 -1
  92. package/dist/jsdelivr/effect/Ajax/Window/data/StorefrontClientConfig.js +0 -16
  93. package/dist/jsdelivr/effect/Ajax/Window/data/StorefrontClientConfig.js.map +0 -1
  94. package/dist/jsdelivr/effect/Ajax/Window/data/index.js +0 -6
  95. package/dist/jsdelivr/effect/Ajax/Window/data/index.js.map +0 -1
  96. package/dist/jsdelivr/effect/Ajax/Window/data/types.js +0 -3
  97. package/dist/jsdelivr/effect/Ajax/Window/data/types.js.map +0 -1
  98. package/dist/jsdelivr/effect/Ajax/Window/index.js +0 -4
  99. package/dist/jsdelivr/effect/Ajax/Window/index.js.map +0 -1
  100. package/dist/jsdelivr/effect/Ajax/index.js +0 -4
  101. package/dist/jsdelivr/effect/Ajax/index.js.map +0 -1
  102. package/dist/jsdelivr/effect/Logging/index.js +0 -13
  103. package/dist/jsdelivr/effect/Logging/index.js.map +0 -1
  104. package/dist/jsdelivr/effect/Resource/data.js +0 -17
  105. package/dist/jsdelivr/effect/Resource/data.js.map +0 -1
  106. package/dist/jsdelivr/effect/Resource/index.js +0 -4
  107. package/dist/jsdelivr/effect/Resource/index.js.map +0 -1
  108. package/dist/jsdelivr/effect/Resource/schema.js +0 -47
  109. package/dist/jsdelivr/effect/Resource/schema.js.map +0 -1
  110. package/dist/jsdelivr/effect/index.js +0 -8
  111. package/dist/jsdelivr/effect/index.js.map +0 -1
  112. package/dist/jsdelivr/index.js +0 -3
  113. package/dist/jsdelivr/index.js.map +0 -1
  114. package/dist/jsdelivr/resources/index.js +0 -9
  115. package/dist/jsdelivr/resources/index.js.map +0 -1
  116. package/dist/main/effect/Ajax/Sections/index.js.map +0 -1
  117. package/dist/main/effect/Ajax/Window/data/index.js.map +0 -1
  118. package/dist/main/effect/Ajax/Window/data/types.js +0 -3
  119. package/dist/main/effect/Ajax/Window/data/types.js.map +0 -1
  120. package/dist/main/effect/Ajax/Window/index.js.map +0 -1
  121. package/dist/main/effect/Ajax/index.js.map +0 -1
  122. package/dist/main/effect/Logging/index.js.map +0 -1
  123. package/dist/main/effect/Resource/index.js.map +0 -1
  124. package/dist/main/effect/index.js.map +0 -1
  125. package/dist/main/index.js.map +0 -1
@@ -1,4 +1,2 @@
1
- export * from './Window/index.js';
2
- export * from './Sections/index.js';
3
- //# sourceMappingURL=index.js.map
4
- //# sourceMappingURL=index.js.map
1
+ import "./Sections/index.js";
2
+ import "./Window/index.js";
@@ -1,13 +1,2 @@
1
- import * as Effect from 'effect/Effect';
2
- import * as FiberRef from 'effect/FiberRef';
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 * as Effect from 'effect/Effect';
2
- import * as Schema from 'effect/Schema';
3
- import * as ParseResult from 'effect/ParseResult';
4
- import { ID, Type, GID } from './schema.js';
5
-
6
- const format = ({
7
- id,
8
- type
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
- const parse = (input) => Schema.decode(
19
- Schema.transformOrFail(GID, ID, {
20
- encode: (value, _, ast) => ParseResult.fail(
21
- new ParseResult.Forbidden(
22
- ast,
23
- value,
24
- "Encoding an ID to a GID is not allowed. Use the format function to convert IDs to GIDs."
25
- )
26
- ),
27
- decode: (value) => ParseResult.succeed(`${value}`.split("/").pop())
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
- //# sourceMappingURL=data.js.map
22
+
33
23
  //# sourceMappingURL=data.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/effect/Resource/data.ts"],"names":[],"mappings":";;;;;AAYO,MAAM,SAAS,CAA2C;AAAA,EAC/D,EAAA;AAAA,EACA;AACF,CAKE,KAAA,MAAA,CAAO,IAAI,aAAa;AACtB,EAAA,MAAM,CAAC,QAAA,EAAU,UAAU,CAAA,GAAI,OAAO,MAAO,CAAA,GAAA;AAAA,IAC3C,CAAC,MAAA,CAAO,MAAO,CAAA,EAAE,CAAE,CAAA,EAAE,CAAG,EAAA,MAAA,CAAO,MAAO,CAAA,IAAI,CAAE,CAAA,IAAI,CAAC,CAAA;AAAA,IACjD;AAAA,MACE,WAAa,EAAA;AAAA;AACf,GACF;AACA,EAAO,OAAA,CAAA,cAAA,EAAiB,UAAU,CAAA,CAAA,EAAI,QAAQ,CAAA,CAAA;AAChD,CAAC;AAEU,MAAA,KAAA,GAAQ,CAAC,KAAA,KACpB,MAAO,CAAA,MAAA;AAAA,EACL,MAAA,CAAO,eAAgB,CAAA,GAAA,EAAK,EAAI,EAAA;AAAA,IAC9B,MAAQ,EAAA,CAAC,KAAO,EAAA,CAAA,EAAG,QACjB,WAAY,CAAA,IAAA;AAAA,MACV,IAAI,WAAY,CAAA,SAAA;AAAA,QACd,GAAA;AAAA,QACA,KAAA;AAAA,QACA;AAAA;AACF,KACF;AAAA,IACF,MAAQ,EAAA,CAAC,KAAU,KAAA,WAAA,CAAY,OAAQ,CAAA,CAAA,EAAG,KAAK,CAAA,CAAA,CAAG,KAAM,CAAA,GAAG,CAAE,CAAA,GAAA,EAAM;AAAA,GACpE;AACH,CAAA,CAAE,KAAK","file":"data.js","sourcesContent":["import type { ParseError } from \"effect/ParseResult\";\n\nimport * as Effect from \"effect/Effect\";\nimport * as Schema from \"effect/Schema\";\nimport * as ParseResult from \"effect/ParseResult\";\nimport { ID, GID, Type } from \"./schema.js\";\n\ntype FormatOptions<T extends ID, R extends Type> = {\n id: T;\n type: R;\n};\n\nexport const format = <const T extends ID, const R extends Type>({\n id,\n type,\n}: FormatOptions<T, R>): Effect.Effect<\n `gid://shopify/${R}/${T}`,\n ParseError,\n never\n> =>\n Effect.gen(function* () {\n const [actualId, actualType] = yield* Effect.all(\n [Schema.decode(ID)(id), Schema.decode(Type)(type)],\n {\n concurrency: \"unbounded\",\n },\n );\n return `gid://shopify/${actualType}/${actualId}` as `gid://shopify/${R}/${T}`;\n });\n\nexport const parse = (input: string) =>\n Schema.decode(\n Schema.transformOrFail(GID, ID, {\n encode: (value, _, ast) =>\n ParseResult.fail(\n new ParseResult.Forbidden(\n ast,\n value,\n \"Encoding an ID to a GID is not allowed. Use the format function to convert IDs to GIDs.\",\n ),\n ),\n decode: (value) => ParseResult.succeed(`${value}`.split(\"/\").pop()!),\n }),\n )(input);\n"]}
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
- export { GID, ID, Type } from './schema.js';
2
- export * from './data.js';
3
- //# sourceMappingURL=index.js.map
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 * as Schema from 'effect/Schema';
2
-
3
- const Type = Schema.Literal(
4
- "Cart",
5
- "Collection",
6
- "Customer",
7
- "DeliveryCarrierService",
8
- "DeliveryLocationGroup",
9
- "DeliveryProfile",
10
- "DeliveryZone",
11
- "DraftOrder",
12
- "DraftOrderLineItem",
13
- "Duty",
14
- "EmailTemplate",
15
- "Fulfillment",
16
- "FulfullmentEvent",
17
- "FullfullmentService",
18
- "InventoryItem",
19
- "InventoryLevel",
20
- "LineItem",
21
- "Location",
22
- "MarketingEvent",
23
- "MediaImage",
24
- "Metafield",
25
- "OnlineStoreArticle",
26
- "OnlineStoreBlog",
27
- "OnlineStorePage",
28
- "Order",
29
- "OrderTransaction",
30
- "Product",
31
- "ProductImage",
32
- "ProductVariant",
33
- "Refund",
34
- "Shop",
35
- "StaffMember",
36
- "Theme"
37
- );
38
- const GID = Schema.String.pipe(Schema.startsWith("gid://shopify/"));
39
- const ID = Schema.Union(
40
- Schema.Number,
41
- Schema.NumberFromString,
42
- Schema.String
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
- //# sourceMappingURL=schema.js.map
47
+
47
48
  //# sourceMappingURL=schema.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/effect/Resource/schema.ts"],"names":[],"mappings":";;AAGO,MAAM,OAAO,MAAO,CAAA,OAAA;AAAA,EACzB,MAAA;AAAA,EACA,YAAA;AAAA,EACA,UAAA;AAAA,EACA,wBAAA;AAAA,EACA,uBAAA;AAAA,EACA,iBAAA;AAAA,EACA,cAAA;AAAA,EACA,YAAA;AAAA,EACA,oBAAA;AAAA,EACA,MAAA;AAAA,EACA,eAAA;AAAA,EACA,aAAA;AAAA,EACA,kBAAA;AAAA,EACA,qBAAA;AAAA,EACA,eAAA;AAAA,EACA,gBAAA;AAAA,EACA,UAAA;AAAA,EACA,UAAA;AAAA,EACA,gBAAA;AAAA,EACA,YAAA;AAAA,EACA,WAAA;AAAA,EACA,oBAAA;AAAA,EACA,iBAAA;AAAA,EACA,iBAAA;AAAA,EACA,OAAA;AAAA,EACA,kBAAA;AAAA,EACA,SAAA;AAAA,EACA,cAAA;AAAA,EACA,gBAAA;AAAA,EACA,QAAA;AAAA,EACA,MAAA;AAAA,EACA,aAAA;AAAA,EACA;AACF;AAGO,MAAM,MAAM,MAAO,CAAA,MAAA,CAAO,KAAK,MAAO,CAAA,UAAA,CAAW,gBAAgB,CAAC;AAGlE,MAAM,KAAK,MAAO,CAAA,KAAA;AAAA,EACvB,MAAO,CAAA,MAAA;AAAA,EACP,MAAO,CAAA,gBAAA;AAAA,EACP,MAAO,CAAA;AACT","file":"schema.js","sourcesContent":["import * as Schema from \"effect/Schema\";\n\nexport type Type = Schema.Schema.Type<typeof Type>;\nexport const Type = Schema.Literal(\n \"Cart\",\n \"Collection\",\n \"Customer\",\n \"DeliveryCarrierService\",\n \"DeliveryLocationGroup\",\n \"DeliveryProfile\",\n \"DeliveryZone\",\n \"DraftOrder\",\n \"DraftOrderLineItem\",\n \"Duty\",\n \"EmailTemplate\",\n \"Fulfillment\",\n \"FulfullmentEvent\",\n \"FullfullmentService\",\n \"InventoryItem\",\n \"InventoryLevel\",\n \"LineItem\",\n \"Location\",\n \"MarketingEvent\",\n \"MediaImage\",\n \"Metafield\",\n \"OnlineStoreArticle\",\n \"OnlineStoreBlog\",\n \"OnlineStorePage\",\n \"Order\",\n \"OrderTransaction\",\n \"Product\",\n \"ProductImage\",\n \"ProductVariant\",\n \"Refund\",\n \"Shop\",\n \"StaffMember\",\n \"Theme\",\n);\n\nexport type GID = Schema.Schema.Encoded<typeof GID>;\nexport const GID = Schema.String.pipe(Schema.startsWith(\"gid://shopify/\"));\n\nexport type ID = Schema.Schema.Encoded<typeof ID>;\nexport const ID = Schema.Union(\n Schema.Number,\n Schema.NumberFromString,\n Schema.String,\n);\n"]}
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 * as index_js$2 from './Resource/index.js';
2
- export { index_js$2 as Resource };
3
- import * as index_js from './Ajax/index.js';
4
- export { index_js as Ajax };
5
- import * as index_js$1 from './Logging/index.js';
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";