@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,40 +1,89 @@
1
- import * as Data from 'effect/Data';
2
-
3
- const Defaults = {
4
- account_addresses_url: "/account/addresses",
5
- account_login_url: "/account/login",
6
- account_logout_url: "/account/logout",
7
- account_recover_url: "/account/recover",
8
- account_register_url: "/account/register",
9
- account_url: "/account",
10
- all_products_collection_url: "/collections/all",
11
- product_url: "/products/:handle",
12
- products_url: "/products",
13
- cart_add_url: "/cart/add.js",
14
- cart_change_url: "/cart/change.js",
15
- cart_clear_url: "/cart/clear.js",
16
- cart_update_url: "/cart/update.js",
17
- cart_url: "/cart.js",
18
- collections_url: "/collections",
19
- predictive_search_url: "/search/suggest",
20
- product_recommendations_url: "/recommendations/products",
21
- root_url: "/",
22
- search_url: "/search",
23
- storefront_login_url: "/customer_authentication/login?return_to=%2Fservices%2Fliquid_rendering%2Fresource%3Ffast_storefront_renderer%3D1&locale=en"
24
- };
25
- class ShopifyRoutes extends Data.Class {
26
- constructor() {
27
- super({
28
- ...Defaults,
29
- ...window?.BrytDesigns?.routes || {}
30
- });
31
- }
32
- }
33
- const make = () => Data.case()({
34
- ...Defaults,
35
- ...window?.BrytDesigns?.routes || {}
1
+ import { __exportAll } from "../../../_virtual/_rolldown/runtime.js";
2
+ import * as Data from "effect/Data";
3
+ import * as Context from "effect/Context";
4
+ import * as Layer from "effect/Layer";
5
+ //#region src/effect/Ajax/Window/data/ShopifyRoutes.ts
6
+ var ShopifyRoutes_exports = /* @__PURE__ */ __exportAll({
7
+ Defaults: () => Defaults,
8
+ Routes: () => Routes,
9
+ ShopifyRoutes: () => ShopifyRoutes,
10
+ layer: () => layer,
11
+ make: () => make
36
12
  });
13
+ var Defaults = {
14
+ account_addresses_url: "/account/addresses",
15
+ account_login_url: "/account/login",
16
+ account_logout_url: "/account/logout",
17
+ account_recover_url: "/account/recover",
18
+ account_register_url: "/account/register",
19
+ account_url: "/account",
20
+ all_products_collection_url: "/collections/all",
21
+ product_url: "/products/:handle",
22
+ products_url: "/products",
23
+ cart_add_url: "/cart/add.js",
24
+ cart_change_url: "/cart/change.js",
25
+ cart_clear_url: "/cart/clear.js",
26
+ cart_update_url: "/cart/update.js",
27
+ cart_url: "/cart.js",
28
+ collections_url: "/collections",
29
+ predictive_search_url: "/search/suggest",
30
+ product_recommendations_url: "/recommendations/products",
31
+ root_url: "/",
32
+ search_url: "/search",
33
+ storefront_login_url: "/customer_authentication/login?return_to=%2Fservices%2Fliquid_rendering%2Fresource%3Ffast_storefront_renderer%3D1&locale=en"
34
+ };
35
+ var ShopifyRoutes = class extends Data.Class {
36
+ constructor() {
37
+ super({
38
+ ...Defaults,
39
+ ...window?.BrytDesigns?.routes || {}
40
+ });
41
+ }
42
+ };
43
+ var make = () => new ShopifyRoutes();
44
+ /**
45
+ * The route table, as a service.
46
+ *
47
+ * Deliberately a `Context.Reference` rather than a `Context.Service`: a
48
+ * `Reference` carries its own default, so reading it leaves the effect's `R`
49
+ * channel at `never`. A `Service` would push `ShopifyRoutes` into `R` for
50
+ * every request effect in every downstream package, and those effects are run
51
+ * by plain Shopify themes through `Effect.runPromise` — which cannot provide
52
+ * anything. The default has to be the common path, and overriding it the
53
+ * exception.
54
+ *
55
+ * The default is evaluated lazily, on first read — but only once. Effect
56
+ * memoises a reference's default onto the reference itself
57
+ * (`Context.getDefaultValue`), so the table is read from `window` on the first
58
+ * Ajax call of the page and reused from then on.
59
+ *
60
+ * That is a deliberate change from the previous behaviour, where `make()` ran
61
+ * on every request and so picked up a later mutation of
62
+ * `window.BrytDesigns.routes`. Laziness buys the common case — a theme's inline
63
+ * script sets the routes before the first request, which module-scope
64
+ * evaluation would have missed — but a theme that rebinds routes *after* the
65
+ * first request must now provide them explicitly, with {@link layer} or
66
+ * `Effect.provideService`.
67
+ *
68
+ * @example
69
+ * ```ts
70
+ * // Override in a test, with no DOM in sight.
71
+ * Effect.provideService(effect, ShopifyRoutes.Routes, {
72
+ * ...ShopifyRoutes.Defaults,
73
+ * cart_url: "/fixtures/cart.js",
74
+ * });
75
+ * ```
76
+ */
77
+ var Routes = Context.Reference("@brytdesigns/shopify-utils/ShopifyRoutes", { defaultValue: () => typeof window === "undefined" ? Defaults : make() });
78
+ /**
79
+ * Pins the route table to an explicit value.
80
+ *
81
+ * Only needed when something must override the window-derived default for a
82
+ * whole program rather than a single effect; `Effect.provideService` covers
83
+ * the single-effect case without building a layer.
84
+ */
85
+ var layer = (routes) => Layer.succeed(Routes, routes);
86
+ //#endregion
87
+ export { Defaults, Routes, ShopifyRoutes, ShopifyRoutes_exports, layer, make };
37
88
 
38
- export { Defaults, ShopifyRoutes, make };
39
- //# sourceMappingURL=ShopifyRoutes.js.map
40
89
  //# sourceMappingURL=ShopifyRoutes.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/effect/Ajax/Window/data/ShopifyRoutes.ts"],"names":[],"mappings":";;AAIO,MAAM,QAA2B,GAAA;AAAA,EACtC,qBAAuB,EAAA,oBAAA;AAAA,EACvB,iBAAmB,EAAA,gBAAA;AAAA,EACnB,kBAAoB,EAAA,iBAAA;AAAA,EACpB,mBAAqB,EAAA,kBAAA;AAAA,EACrB,oBAAsB,EAAA,mBAAA;AAAA,EACtB,WAAa,EAAA,UAAA;AAAA,EACb,2BAA6B,EAAA,kBAAA;AAAA,EAC7B,WAAa,EAAA,mBAAA;AAAA,EACb,YAAc,EAAA,WAAA;AAAA,EACd,YAAc,EAAA,cAAA;AAAA,EACd,eAAiB,EAAA,iBAAA;AAAA,EACjB,cAAgB,EAAA,gBAAA;AAAA,EAChB,eAAiB,EAAA,iBAAA;AAAA,EACjB,QAAU,EAAA,UAAA;AAAA,EACV,eAAiB,EAAA,cAAA;AAAA,EACjB,qBAAuB,EAAA,iBAAA;AAAA,EACvB,2BAA6B,EAAA,2BAAA;AAAA,EAC7B,QAAU,EAAA,GAAA;AAAA,EACV,UAAY,EAAA,SAAA;AAAA,EACZ,oBACE,EAAA;AACJ;AAEO,MAAM,aAAA,SAAsB,KAAK,KAAsB,CAAA;AAAA,EAC5D,WAAc,GAAA;AACZ,IAAM,KAAA,CAAA;AAAA,MACJ,GAAG,QAAA;AAAA,MACH,GAAI,MAAA,EAAQ,WAAa,EAAA,MAAA,IAAU;AAAC,KACrC,CAAA;AAAA;AAEL;AAEO,MAAM,IAAO,GAAA,MAClB,IAAK,CAAA,IAAA,EAAsB,CAAA;AAAA,EACzB,GAAG,QAAA;AAAA,EACH,GAAI,MAAA,EAAQ,WAAa,EAAA,MAAA,IAAU;AACrC,CAAC","file":"ShopifyRoutes.js","sourcesContent":["import type { IShopifyRoutes } from \"./types.js\";\n\nimport * as Data from \"effect/Data\";\n\nexport const Defaults: IShopifyRoutes = {\n account_addresses_url: \"/account/addresses\",\n account_login_url: \"/account/login\",\n account_logout_url: \"/account/logout\",\n account_recover_url: \"/account/recover\",\n account_register_url: \"/account/register\",\n account_url: \"/account\",\n all_products_collection_url: \"/collections/all\",\n product_url: \"/products/:handle\",\n products_url: \"/products\",\n cart_add_url: \"/cart/add.js\",\n cart_change_url: \"/cart/change.js\",\n cart_clear_url: \"/cart/clear.js\",\n cart_update_url: \"/cart/update.js\",\n cart_url: \"/cart.js\",\n collections_url: \"/collections\",\n predictive_search_url: \"/search/suggest\",\n product_recommendations_url: \"/recommendations/products\",\n root_url: \"/\",\n search_url: \"/search\",\n storefront_login_url:\n \"/customer_authentication/login?return_to=%2Fservices%2Fliquid_rendering%2Fresource%3Ffast_storefront_renderer%3D1&locale=en\",\n};\n\nexport class ShopifyRoutes extends Data.Class<IShopifyRoutes> {\n constructor() {\n super({\n ...Defaults,\n ...(window?.BrytDesigns?.routes || {}),\n });\n }\n}\n\nexport const make = () =>\n Data.case<ShopifyRoutes>()({\n ...Defaults,\n ...(window?.BrytDesigns?.routes || {}),\n });\n"]}
1
+ {"version":3,"file":"ShopifyRoutes.js","names":[],"sources":["../../../../../src/effect/Ajax/Window/data/ShopifyRoutes.ts"],"sourcesContent":["import * as Context from \"effect/Context\";\nimport * as Data from \"effect/Data\";\nimport * as Layer from \"effect/Layer\";\nimport type { IShopifyRoutes } from \"./types.js\";\n\nexport const Defaults: IShopifyRoutes = {\n\taccount_addresses_url: \"/account/addresses\",\n\taccount_login_url: \"/account/login\",\n\taccount_logout_url: \"/account/logout\",\n\taccount_recover_url: \"/account/recover\",\n\taccount_register_url: \"/account/register\",\n\taccount_url: \"/account\",\n\tall_products_collection_url: \"/collections/all\",\n\tproduct_url: \"/products/:handle\",\n\tproducts_url: \"/products\",\n\tcart_add_url: \"/cart/add.js\",\n\tcart_change_url: \"/cart/change.js\",\n\tcart_clear_url: \"/cart/clear.js\",\n\tcart_update_url: \"/cart/update.js\",\n\tcart_url: \"/cart.js\",\n\tcollections_url: \"/collections\",\n\tpredictive_search_url: \"/search/suggest\",\n\tproduct_recommendations_url: \"/recommendations/products\",\n\troot_url: \"/\",\n\tsearch_url: \"/search\",\n\tstorefront_login_url:\n\t\t\"/customer_authentication/login?return_to=%2Fservices%2Fliquid_rendering%2Fresource%3Ffast_storefront_renderer%3D1&locale=en\",\n};\n\nexport class ShopifyRoutes extends Data.Class<IShopifyRoutes> {\n\tconstructor() {\n\t\tsuper({\n\t\t\t...Defaults,\n\t\t\t...(window?.BrytDesigns?.routes || {}),\n\t\t});\n\t}\n}\n\n// v4 removed Data.case. The class constructor already applies exactly these\n// defaults, so the factory collapses to it.\nexport const make = (): ShopifyRoutes => new ShopifyRoutes();\n\n/**\n * The route table, as a service.\n *\n * Deliberately a `Context.Reference` rather than a `Context.Service`: a\n * `Reference` carries its own default, so reading it leaves the effect's `R`\n * channel at `never`. A `Service` would push `ShopifyRoutes` into `R` for\n * every request effect in every downstream package, and those effects are run\n * by plain Shopify themes through `Effect.runPromise` — which cannot provide\n * anything. The default has to be the common path, and overriding it the\n * exception.\n *\n * The default is evaluated lazily, on first read — but only once. Effect\n * memoises a reference's default onto the reference itself\n * (`Context.getDefaultValue`), so the table is read from `window` on the first\n * Ajax call of the page and reused from then on.\n *\n * That is a deliberate change from the previous behaviour, where `make()` ran\n * on every request and so picked up a later mutation of\n * `window.BrytDesigns.routes`. Laziness buys the common case — a theme's inline\n * script sets the routes before the first request, which module-scope\n * evaluation would have missed — but a theme that rebinds routes *after* the\n * first request must now provide them explicitly, with {@link layer} or\n * `Effect.provideService`.\n *\n * @example\n * ```ts\n * // Override in a test, with no DOM in sight.\n * Effect.provideService(effect, ShopifyRoutes.Routes, {\n * ...ShopifyRoutes.Defaults,\n * cart_url: \"/fixtures/cart.js\",\n * });\n * ```\n */\nexport const Routes: Context.Reference<IShopifyRoutes> =\n\tContext.Reference<IShopifyRoutes>(\n\t\t\"@brytdesigns/shopify-utils/ShopifyRoutes\",\n\t\t{\n\t\t\t// Guarded rather than just `make()`: the class constructor reads `window`\n\t\t\t// unconditionally, and `window?.` does not protect against the identifier\n\t\t\t// being undeclared. Falling back to `Defaults` keeps the reference usable\n\t\t\t// from Node - which is what lets `ajax-client`'s tests run without jsdom.\n\t\t\tdefaultValue: () => (typeof window === \"undefined\" ? Defaults : make()),\n\t\t},\n\t);\n\n/**\n * Pins the route table to an explicit value.\n *\n * Only needed when something must override the window-derived default for a\n * whole program rather than a single effect; `Effect.provideService` covers\n * the single-effect case without building a layer.\n */\nexport const layer = (routes: IShopifyRoutes): Layer.Layer<never> =>\n\tLayer.succeed(Routes, routes);\n"],"mappings":";;;;;;;;;;;;AAKA,IAAa,WAA2B;CACvC,uBAAuB;CACvB,mBAAmB;CACnB,oBAAoB;CACpB,qBAAqB;CACrB,sBAAsB;CACtB,aAAa;CACb,6BAA6B;CAC7B,aAAa;CACb,cAAc;CACd,cAAc;CACd,iBAAiB;CACjB,gBAAgB;CAChB,iBAAiB;CACjB,UAAU;CACV,iBAAiB;CACjB,uBAAuB;CACvB,6BAA6B;CAC7B,UAAU;CACV,YAAY;CACZ,sBACC;AACF;AAEA,IAAa,gBAAb,cAAmC,KAAK,MAAsB;CAC7D,cAAc;EACb,MAAM;GACL,GAAG;GACH,GAAI,QAAQ,aAAa,UAAU,CAAC;EACrC,CAAC;CACF;AACD;AAIA,IAAa,aAA4B,IAAI,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmC3D,IAAa,SACZ,QAAQ,UACP,4CACA,EAKC,oBAAqB,OAAO,WAAW,cAAc,WAAW,KAAK,EACtE,CACD;;;;;;;;AASD,IAAa,SAAS,WACrB,MAAM,QAAQ,QAAQ,MAAM"}
@@ -1,16 +1,17 @@
1
- import * as Data from 'effect/Data';
2
-
3
- class StorefrontClientConfig extends Data.Class {
4
- constructor() {
5
- super({
6
- ...window.BrytDesigns.storefront.config
7
- });
8
- }
9
- }
10
- const make = () => Data.case()({
11
- ...window.BrytDesigns.storefront.config
1
+ import { __exportAll } from "../../../_virtual/_rolldown/runtime.js";
2
+ import * as Data from "effect/Data";
3
+ //#region src/effect/Ajax/Window/data/StorefrontClientConfig.ts
4
+ var StorefrontClientConfig_exports = /* @__PURE__ */ __exportAll({
5
+ StorefrontClientConfig: () => StorefrontClientConfig,
6
+ make: () => make
12
7
  });
8
+ var StorefrontClientConfig = class extends Data.Class {
9
+ constructor() {
10
+ super({ ...window.BrytDesigns.storefront.config });
11
+ }
12
+ };
13
+ var make = () => new StorefrontClientConfig();
14
+ //#endregion
15
+ export { StorefrontClientConfig, StorefrontClientConfig_exports, make };
13
16
 
14
- export { StorefrontClientConfig, make };
15
- //# sourceMappingURL=StorefrontClientConfig.js.map
16
17
  //# sourceMappingURL=StorefrontClientConfig.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/effect/Ajax/Window/data/StorefrontClientConfig.ts"],"names":[],"mappings":";;AAIO,MAAM,sBAAA,SAA+B,KAAK,KAA+B,CAAA;AAAA,EAC9E,WAAc,GAAA;AACZ,IAAM,KAAA,CAAA;AAAA,MACJ,GAAG,MAAO,CAAA,WAAA,CAAY,UAAW,CAAA;AAAA,KAClC,CAAA;AAAA;AAEL;AAEO,MAAM,IAAO,GAAA,MAClB,IAAK,CAAA,IAAA,EAA+B,CAAA;AAAA,EAClC,GAAG,MAAO,CAAA,WAAA,CAAY,UAAW,CAAA;AACnC,CAAC","file":"StorefrontClientConfig.js","sourcesContent":["import type { IStorefrontClientConfig } from \"./types.js\";\n\nimport * as Data from \"effect/Data\";\n\nexport class StorefrontClientConfig extends Data.Class<IStorefrontClientConfig> {\n constructor() {\n super({\n ...window.BrytDesigns.storefront.config,\n });\n }\n}\n\nexport const make = () =>\n Data.case<StorefrontClientConfig>()({\n ...window.BrytDesigns.storefront.config,\n });\n"]}
1
+ {"version":3,"file":"StorefrontClientConfig.js","names":[],"sources":["../../../../../src/effect/Ajax/Window/data/StorefrontClientConfig.ts"],"sourcesContent":["import * as Data from \"effect/Data\";\nimport type { IStorefrontClientConfig } from \"./types.js\";\n\nexport class StorefrontClientConfig extends Data.Class<IStorefrontClientConfig> {\n\tconstructor() {\n\t\tsuper({\n\t\t\t...window.BrytDesigns.storefront.config,\n\t\t});\n\t}\n}\n\n// v4 removed Data.case. The class constructor already applies exactly these\n// defaults, so the factory collapses to it.\nexport const make = (): StorefrontClientConfig => new StorefrontClientConfig();\n"],"mappings":";;;;;;;AAGA,IAAa,yBAAb,cAA4C,KAAK,MAA+B;CAC/E,cAAc;EACb,MAAM,EACL,GAAG,OAAO,YAAY,WAAW,OAClC,CAAC;CACF;AACD;AAIA,IAAa,aAAqC,IAAI,uBAAuB"}
@@ -0,0 +1,32 @@
1
+ import { __exportAll } from "../../../_virtual/_rolldown/runtime.js";
2
+ import * as Context from "effect/Context";
3
+ import * as Layer from "effect/Layer";
4
+ //#region src/effect/Ajax/Window/data/StorefrontOrigin.ts
5
+ var StorefrontOrigin_exports = /* @__PURE__ */ __exportAll({
6
+ Origin: () => Origin,
7
+ layer: () => layer
8
+ });
9
+ /**
10
+ * The origin every Ajax route is resolved against.
11
+ *
12
+ * Shopify's Ajax endpoints are same-origin paths (`/cart.js`), so this is
13
+ * `window.location.origin` on a storefront and the only reason the request
14
+ * layer needed a DOM at all. Lifting it to a `Context.Reference` means
15
+ * `ajax-client` can build a request without one, which is what makes its
16
+ * tests runnable outside jsdom.
17
+ *
18
+ * A `Reference` rather than a `Service` for the same reason as
19
+ * {@link ShopifyRoutes.Routes}: the default must work with no provision, so
20
+ * themes can keep calling `Effect.runPromise` directly.
21
+ *
22
+ * Read lazily. `window.location.origin` is stable within a page, but reading
23
+ * it at module scope would still break any environment that imports this
24
+ * module before a DOM exists.
25
+ */
26
+ var Origin = Context.Reference("@brytdesigns/shopify-utils/StorefrontOrigin", { defaultValue: () => typeof window === "undefined" ? "" : window.location.origin });
27
+ /** Pins the origin for a whole program. */
28
+ var layer = (origin) => Layer.succeed(Origin, origin);
29
+ //#endregion
30
+ export { Origin, StorefrontOrigin_exports, layer };
31
+
32
+ //# sourceMappingURL=StorefrontOrigin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StorefrontOrigin.js","names":[],"sources":["../../../../../src/effect/Ajax/Window/data/StorefrontOrigin.ts"],"sourcesContent":["import * as Context from \"effect/Context\";\nimport * as Layer from \"effect/Layer\";\n\n/**\n * The origin every Ajax route is resolved against.\n *\n * Shopify's Ajax endpoints are same-origin paths (`/cart.js`), so this is\n * `window.location.origin` on a storefront and the only reason the request\n * layer needed a DOM at all. Lifting it to a `Context.Reference` means\n * `ajax-client` can build a request without one, which is what makes its\n * tests runnable outside jsdom.\n *\n * A `Reference` rather than a `Service` for the same reason as\n * {@link ShopifyRoutes.Routes}: the default must work with no provision, so\n * themes can keep calling `Effect.runPromise` directly.\n *\n * Read lazily. `window.location.origin` is stable within a page, but reading\n * it at module scope would still break any environment that imports this\n * module before a DOM exists.\n */\nexport const Origin: Context.Reference<string> = Context.Reference<string>(\n\t\"@brytdesigns/shopify-utils/StorefrontOrigin\",\n\t{\n\t\tdefaultValue: () =>\n\t\t\ttypeof window === \"undefined\" ? \"\" : window.location.origin,\n\t},\n);\n\n/** Pins the origin for a whole program. */\nexport const layer = (origin: string): Layer.Layer<never> =>\n\tLayer.succeed(Origin, origin);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAoBA,IAAa,SAAoC,QAAQ,UACxD,+CACA,EACC,oBACC,OAAO,WAAW,cAAc,KAAK,OAAO,SAAS,OACvD,CACD;;AAGA,IAAa,SAAS,WACrB,MAAM,QAAQ,QAAQ,MAAM"}
@@ -1,6 +1,16 @@
1
- import * as ShopifyRoutes_js from './ShopifyRoutes.js';
2
- export { ShopifyRoutes_js as ShopifyRoutes };
3
- import * as StorefrontClientConfig_js from './StorefrontClientConfig.js';
4
- export { StorefrontClientConfig_js as StorefrontClientConfig };
5
- //# sourceMappingURL=index.js.map
1
+ import { __exportAll } from "../../../_virtual/_rolldown/runtime.js";
2
+ import { AllowedRouteOrigins_exports } from "./AllowedRouteOrigins.js";
3
+ import { ShopifyRoutes_exports } from "./ShopifyRoutes.js";
4
+ import { StorefrontClientConfig_exports } from "./StorefrontClientConfig.js";
5
+ import { StorefrontOrigin_exports } from "./StorefrontOrigin.js";
6
+ //#region src/effect/Ajax/Window/data/index.ts
7
+ var data_exports = /* @__PURE__ */ __exportAll({
8
+ AllowedRouteOrigins: () => AllowedRouteOrigins_exports,
9
+ ShopifyRoutes: () => ShopifyRoutes_exports,
10
+ StorefrontClientConfig: () => StorefrontClientConfig_exports,
11
+ StorefrontOrigin: () => StorefrontOrigin_exports
12
+ });
13
+ //#endregion
14
+ export { AllowedRouteOrigins_exports as AllowedRouteOrigins, ShopifyRoutes_exports as ShopifyRoutes, StorefrontClientConfig_exports as StorefrontClientConfig, StorefrontOrigin_exports as StorefrontOrigin, data_exports };
15
+
6
16
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js","sourcesContent":[]}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../../../src/effect/Ajax/Window/data/index.ts"],"sourcesContent":["export * as AllowedRouteOrigins from \"./AllowedRouteOrigins.js\";\nexport * as ShopifyRoutes from \"./ShopifyRoutes.js\";\nexport * as StorefrontClientConfig from \"./StorefrontClientConfig.js\";\nexport * as StorefrontOrigin from \"./StorefrontOrigin.js\";\n"],"mappings":""}
@@ -1,4 +1,2 @@
1
- import * as index_js from './data/index.js';
2
- export { index_js as Window };
3
- //# sourceMappingURL=index.js.map
4
- //# sourceMappingURL=index.js.map
1
+ import { data_exports } from "./data/index.js";
2
+ export { data_exports as Window };
@@ -1,4 +1,14 @@
1
- export * from './Window/index.js';
2
- export * from './Sections/index.js';
3
- //# sourceMappingURL=index.js.map
1
+ import { __exportAll } from "../_virtual/_rolldown/runtime.js";
2
+ import { schema_exports } from "./Sections/schema.js";
3
+ import "./Sections/index.js";
4
+ import { data_exports } from "./Window/data/index.js";
5
+ import "./Window/index.js";
6
+ //#region src/effect/Ajax/index.ts
7
+ var Ajax_exports = /* @__PURE__ */ __exportAll({
8
+ Sections: () => schema_exports,
9
+ Window: () => data_exports
10
+ });
11
+ //#endregion
12
+ export { Ajax_exports, schema_exports as Sections, data_exports as Window };
13
+
4
14
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js","sourcesContent":[]}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../src/effect/Ajax/index.ts"],"sourcesContent":["export * from \"./Sections/index.js\";\nexport * from \"./Window/index.js\";\n"],"mappings":""}
@@ -1,13 +1,16 @@
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;
1
+ import { __exportAll } from "../_virtual/_rolldown/runtime.js";
2
+ import * as Effect from "effect/Effect";
3
+ import * as References from "effect/References";
4
+ //#region src/effect/Logging/index.ts
5
+ var Logging_exports = /* @__PURE__ */ __exportAll({
6
+ filterLevelOrNever: () => filterLevelOrNever,
7
+ makeNamespacedLogSpan: () => makeNamespacedLogSpan
8
+ });
9
+ var filterLevelOrNever = (level, effect) => Effect.gen(function* () {
10
+ if ((yield* References.MinimumLogLevel) !== level) return yield* effect;
8
11
  });
9
- const makeNamespacedLogSpan = (prefix) => (label) => Effect.withLogSpan(`${prefix}:${label}`);
12
+ var makeNamespacedLogSpan = (prefix) => (label) => Effect.withLogSpan(`${prefix}:${label}`);
13
+ //#endregion
14
+ export { Logging_exports, filterLevelOrNever, makeNamespacedLogSpan };
10
15
 
11
- export { filterLevelOrNever, makeNamespacedLogSpan };
12
- //# sourceMappingURL=index.js.map
13
16
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/effect/Logging/index.ts"],"names":[],"mappings":";;;;AAIO,MAAM,qBAAqB,CAChC,KAAA,EACA,MAEA,KAAA,MAAA,CAAO,IAAI,aAAa;AACtB,EAAA,MAAM,QAAW,GAAA,OAAO,QAAS,CAAA,GAAA,CAAI,SAAS,sBAAsB,CAAA;AACpE,EAAA,IAAI,QAAS,CAAA,IAAA,KAAS,KAAM,CAAA,IAAA,SAAa,OAAO,MAAA;AAClD,CAAC;AAEU,MAAA,qBAAA,GAAwB,CAAC,MAAA,KAAmB,CAAC,KAAA,KACxD,MAAO,CAAA,WAAA,CAAY,CAAG,EAAA,MAAM,CAAI,CAAA,EAAA,KAAK,CAAE,CAAA","file":"index.js","sourcesContent":["import * as Effect from \"effect/Effect\";\nimport * as FiberRef from \"effect/FiberRef\";\nimport * as LogLevel from \"effect/LogLevel\";\n\nexport const filterLevelOrNever = <A, E, R>(\n level: LogLevel.LogLevel,\n effect: Effect.Effect<A, E, R>\n) =>\n Effect.gen(function* () {\n const logLevel = yield* FiberRef.get(FiberRef.currentMinimumLogLevel);\n if (logLevel._tag !== level._tag) return yield* effect;\n });\n\nexport const makeNamespacedLogSpan = (prefix: string) => (label: string) =>\n Effect.withLogSpan(`${prefix}:${label}`);\n"]}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../src/effect/Logging/index.ts"],"sourcesContent":["import * as Effect from \"effect/Effect\";\nimport type * as LogLevel from \"effect/LogLevel\";\nimport * as References from \"effect/References\";\n\nexport const filterLevelOrNever = <A, E, R>(\n\tlevel: LogLevel.LogLevel,\n\teffect: Effect.Effect<A, E, R>,\n) =>\n\tEffect.gen(function* () {\n\t\t// v4: the minimum log level is a Context.Reference rather than a FiberRef,\n\t\t// and levels are string literals rather than branded objects.\n\t\tconst logLevel = yield* References.MinimumLogLevel;\n\t\tif (logLevel !== level) return yield* effect;\n\t});\n\nexport const makeNamespacedLogSpan = (prefix: string) => (label: string) =>\n\tEffect.withLogSpan(`${prefix}:${label}`);\n"],"mappings":";;;;;;;;AAIA,IAAa,sBACZ,OACA,WAEA,OAAO,IAAI,aAAa;CAIvB,KAAI,OADoB,WAAW,qBAClB,OAAO,OAAO,OAAO;AACvC,CAAC;AAEF,IAAa,yBAAyB,YAAoB,UACzD,OAAO,YAAY,GAAG,OAAO,GAAG,OAAO"}
@@ -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,15 @@
1
- export { GID, ID, Type } from './schema.js';
2
- export * from './data.js';
3
- //# sourceMappingURL=index.js.map
1
+ import { __exportAll } from "../_virtual/_rolldown/runtime.js";
2
+ import { GID, ID, Type } from "./schema.js";
3
+ import { format, parse } from "./data.js";
4
+ //#region src/effect/Resource/index.ts
5
+ var Resource_exports = /* @__PURE__ */ __exportAll({
6
+ GID: () => GID,
7
+ ID: () => ID,
8
+ Type: () => Type,
9
+ format: () => format,
10
+ parse: () => parse
11
+ });
12
+ //#endregion
13
+ export { GID, ID, Resource_exports, Type, format, parse };
14
+
4
15
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js","sourcesContent":[]}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../src/effect/Resource/index.ts"],"sourcesContent":["export * from \"./data.js\";\nexport { GID, ID, Type } from \"./schema.js\";\n"],"mappings":""}
@@ -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,75 @@
1
+ import { __exportAll } from "../_virtual/_rolldown/runtime.js";
2
+ import * as Effect from "effect/Effect";
3
+ import * as Schema from "effect/Schema";
4
+ import * as SchemaIssue from "effect/SchemaIssue";
5
+ import * as Arr from "effect/Array";
6
+ import * as Option from "effect/Option";
7
+ import * as SchemaParser from "effect/SchemaParser";
8
+ import * as SchemaTransformation from "effect/SchemaTransformation";
9
+ //#region src/effect/Schemas/index.ts
10
+ var Schemas_exports = /* @__PURE__ */ __exportAll({
11
+ ArrayDroppingInvalid: () => ArrayDroppingInvalid,
12
+ FiniteFromNumericString: () => FiniteFromNumericString
13
+ });
14
+ var formatIssue = SchemaIssue.makeFormatterDefault();
15
+ /**
16
+ * An array that decodes element by element and drops the elements that fail.
17
+ *
18
+ * `Schema.Array` fails the whole array on its first bad element, which is right
19
+ * for a request body and wrong for a list of search results: one product with a
20
+ * malformed price would reject every product, collection and page around it.
21
+ * This keeps the rest.
22
+ *
23
+ * Built with `declareConstructor` rather than `Schema.Array(item.pipe(
24
+ * Schema.catchDecoding(...)))`. Recovering to `Option.none()` inside an array
25
+ * does not drop the element: v4's array parser reports a missing element as a
26
+ * `MissingKey` issue, so the array fails anyway. A declaration owns the whole
27
+ * array and can leave elements out.
28
+ *
29
+ * The type is `ReadonlyArray<Type>`, identical to `Schema.Array`'s, so a
30
+ * schema can switch to this without changing what it decodes to. Input that is
31
+ * not an array at all still fails: that is a broken response, not a bad item.
32
+ *
33
+ * Each dropped element is logged at `Debug` with its index and the issue, so
34
+ * it is visible wherever the caller has turned debug logging on and silent
35
+ * everywhere else.
36
+ *
37
+ * @example
38
+ * ```ts
39
+ * import { Schemas } from "@brytdesigns/shopify-utils/effect";
40
+ *
41
+ * const Results = Schema.Struct({
42
+ * products: Schemas.ArrayDroppingInvalid(Product),
43
+ * });
44
+ * ```
45
+ */
46
+ var ArrayDroppingInvalid = (item) => Schema.declareConstructor()([item], ([codec]) => {
47
+ const decode = SchemaParser.decodeUnknownEffect(codec);
48
+ return (input, ast, options) => {
49
+ if (!Array.isArray(input)) return Effect.fail(new SchemaIssue.InvalidType(ast, input, options));
50
+ return Effect.forEach(input, (element, index) => decode(element, options).pipe(Effect.map(Option.some), Effect.catch((issue) => Effect.logDebug("Dropped an array element that failed to decode", {
51
+ index,
52
+ issue: formatIssue(issue)
53
+ }).pipe(Effect.as(Option.none()))))).pipe(Effect.map(Arr.getSomes));
54
+ };
55
+ });
56
+ /**
57
+ * A string holding a number, decoded to that number. Anything else fails.
58
+ *
59
+ * What Effect 3's `Schema.NumberFromString` was, and Effect 4's is not. v4's
60
+ * is plain `Number(s)` and never fails: "abc" decodes to NaN, and "" and
61
+ * whitespace to 0. `Schema.FiniteFromString` rejects NaN and Infinity but
62
+ * still reads a blank string as 0. Neither is safe in a union whose later
63
+ * members are meant to catch what the numeric one refuses, and neither should
64
+ * turn a missing price into a free product.
65
+ *
66
+ * Accepts what v3 accepted, minus the non-finite values: a string with at
67
+ * least one non-whitespace character that `Number()` reads as finite. So
68
+ * `"10.00"` is 10, `" 42 "` is 42, and `""`, `" "`, `"abc"` and `"NaN"`
69
+ * fail.
70
+ */
71
+ var FiniteFromNumericString = Schema.String.check(Schema.isPattern(/\S/, { expected: "a non-blank string" })).pipe(Schema.decodeTo(Schema.Finite, SchemaTransformation.numberFromString));
72
+ //#endregion
73
+ export { ArrayDroppingInvalid, FiniteFromNumericString, Schemas_exports };
74
+
75
+ //# 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":";;;;;;;;;;;;;AAQA,IAAM,cAAc,YAAY,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCrD,IAAa,wBAAqD,SACjE,OAAO,mBAGL,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,WAAW;CACxB,MAAM,SAAS,aAAa,oBAAoB,KAAK;CAErD,QAAQ,OAAO,KAAK,YAAY;EAC/B,IAAI,CAAC,MAAM,QAAQ,KAAK,GACvB,OAAO,OAAO,KAAK,IAAI,YAAY,YAAY,KAAK,OAAO,OAAO,CAAC;EAGpE,OAAO,OAAO,QAAQ,QAAQ,SAAS,UACtC,OAAO,SAAS,OAAO,CAAC,CAAC,KACxB,OAAO,IAAI,OAAO,IAAI,GACtB,OAAO,OAAO,UACb,OAAO,SAAS,kDAAkD;GACjE;GACA,OAAO,YAAY,KAAK;EACzB,CAAC,CAAC,CAAC,KAAK,OAAO,GAAG,OAAO,KAAK,CAAC,CAAC,CACjC,CACD,CACD,CAAC,CAAC,KAAK,OAAO,IAAI,IAAI,QAAQ,CAAC;CAChC;AACD,CAAC;;;;;;;;;;;;;;;;AAiBF,IAAa,0BAA0B,OAAO,OAAO,MACpD,OAAO,UAAU,MAAM,EAAE,UAAU,qBAAqB,CAAC,CAC1D,CAAC,CAAC,KAAK,OAAO,SAAS,OAAO,QAAQ,qBAAqB,gBAAgB,CAAC"}