@etohq/framework 1.0.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 (234) hide show
  1. package/README.md +0 -0
  2. package/dist/build-tools/compiler.d.ts +49 -0
  3. package/dist/build-tools/compiler.d.ts.map +1 -0
  4. package/dist/build-tools/compiler.js +291 -0
  5. package/dist/build-tools/compiler.js.map +1 -0
  6. package/dist/build-tools/index.d.ts +2 -0
  7. package/dist/build-tools/index.d.ts.map +1 -0
  8. package/dist/build-tools/index.js +18 -0
  9. package/dist/build-tools/index.js.map +1 -0
  10. package/dist/config/config.d.ts +34 -0
  11. package/dist/config/config.d.ts.map +1 -0
  12. package/dist/config/config.js +132 -0
  13. package/dist/config/config.js.map +1 -0
  14. package/dist/config/index.d.ts +5 -0
  15. package/dist/config/index.d.ts.map +1 -0
  16. package/dist/config/index.js +21 -0
  17. package/dist/config/index.js.map +1 -0
  18. package/dist/config/loader.d.ts +11 -0
  19. package/dist/config/loader.d.ts.map +1 -0
  20. package/dist/config/loader.js +35 -0
  21. package/dist/config/loader.js.map +1 -0
  22. package/dist/config/types.d.ts +901 -0
  23. package/dist/config/types.d.ts.map +1 -0
  24. package/dist/config/types.js +3 -0
  25. package/dist/config/types.js.map +1 -0
  26. package/dist/container.d.ts +3 -0
  27. package/dist/container.d.ts.map +1 -0
  28. package/dist/container.js +21 -0
  29. package/dist/container.js.map +1 -0
  30. package/dist/database/index.d.ts +3 -0
  31. package/dist/database/index.d.ts.map +1 -0
  32. package/dist/database/index.js +19 -0
  33. package/dist/database/index.js.map +1 -0
  34. package/dist/database/pg-connection-loader.d.ts +6 -0
  35. package/dist/database/pg-connection-loader.d.ts.map +1 -0
  36. package/dist/database/pg-connection-loader.js +37 -0
  37. package/dist/database/pg-connection-loader.js.map +1 -0
  38. package/dist/eto-app-loader.d.ts +51 -0
  39. package/dist/eto-app-loader.d.ts.map +1 -0
  40. package/dist/eto-app-loader.js +183 -0
  41. package/dist/eto-app-loader.js.map +1 -0
  42. package/dist/feature-flags/feature-flag-loader.d.ts +8 -0
  43. package/dist/feature-flags/feature-flag-loader.d.ts.map +1 -0
  44. package/dist/feature-flags/feature-flag-loader.js +81 -0
  45. package/dist/feature-flags/feature-flag-loader.js.map +1 -0
  46. package/dist/feature-flags/flag-router.d.ts +32 -0
  47. package/dist/feature-flags/flag-router.d.ts.map +1 -0
  48. package/dist/feature-flags/flag-router.js +67 -0
  49. package/dist/feature-flags/flag-router.js.map +1 -0
  50. package/dist/feature-flags/index.d.ts +5 -0
  51. package/dist/feature-flags/index.d.ts.map +1 -0
  52. package/dist/feature-flags/index.js +21 -0
  53. package/dist/feature-flags/index.js.map +1 -0
  54. package/dist/feature-flags/types.d.ts +31 -0
  55. package/dist/feature-flags/types.d.ts.map +1 -0
  56. package/dist/feature-flags/types.js +3 -0
  57. package/dist/feature-flags/types.js.map +1 -0
  58. package/dist/http/express-loader.d.ts +8 -0
  59. package/dist/http/express-loader.d.ts.map +1 -0
  60. package/dist/http/express-loader.js +85 -0
  61. package/dist/http/express-loader.js.map +1 -0
  62. package/dist/http/index.d.ts +15 -0
  63. package/dist/http/index.d.ts.map +1 -0
  64. package/dist/http/index.js +31 -0
  65. package/dist/http/index.js.map +1 -0
  66. package/dist/http/middlewares/apply-default-filters.d.ts +3 -0
  67. package/dist/http/middlewares/apply-default-filters.d.ts.map +1 -0
  68. package/dist/http/middlewares/apply-default-filters.js +32 -0
  69. package/dist/http/middlewares/apply-default-filters.js.map +1 -0
  70. package/dist/http/middlewares/apply-params-as-filters.d.ts +5 -0
  71. package/dist/http/middlewares/apply-params-as-filters.d.ts.map +1 -0
  72. package/dist/http/middlewares/apply-params-as-filters.js +14 -0
  73. package/dist/http/middlewares/apply-params-as-filters.js.map +1 -0
  74. package/dist/http/middlewares/authenticate-middleware.d.ts +11 -0
  75. package/dist/http/middlewares/authenticate-middleware.d.ts.map +1 -0
  76. package/dist/http/middlewares/authenticate-middleware.js +135 -0
  77. package/dist/http/middlewares/authenticate-middleware.js.map +1 -0
  78. package/dist/http/middlewares/clear-filters-by-key.d.ts +3 -0
  79. package/dist/http/middlewares/clear-filters-by-key.d.ts.map +1 -0
  80. package/dist/http/middlewares/clear-filters-by-key.js +12 -0
  81. package/dist/http/middlewares/clear-filters-by-key.js.map +1 -0
  82. package/dist/http/middlewares/ensure-publishable-api-key.d.ts +3 -0
  83. package/dist/http/middlewares/ensure-publishable-api-key.d.ts.map +1 -0
  84. package/dist/http/middlewares/ensure-publishable-api-key.js +49 -0
  85. package/dist/http/middlewares/ensure-publishable-api-key.js.map +1 -0
  86. package/dist/http/middlewares/error-handler.d.ts +23 -0
  87. package/dist/http/middlewares/error-handler.d.ts.map +1 -0
  88. package/dist/http/middlewares/error-handler.js +85 -0
  89. package/dist/http/middlewares/error-handler.js.map +1 -0
  90. package/dist/http/middlewares/exception-formatter.d.ts +9 -0
  91. package/dist/http/middlewares/exception-formatter.d.ts.map +1 -0
  92. package/dist/http/middlewares/exception-formatter.js +36 -0
  93. package/dist/http/middlewares/exception-formatter.js.map +1 -0
  94. package/dist/http/middlewares/index.d.ts +8 -0
  95. package/dist/http/middlewares/index.d.ts.map +1 -0
  96. package/dist/http/middlewares/index.js +24 -0
  97. package/dist/http/middlewares/index.js.map +1 -0
  98. package/dist/http/middlewares/set-context.d.ts +3 -0
  99. package/dist/http/middlewares/set-context.d.ts.map +1 -0
  100. package/dist/http/middlewares/set-context.js +18 -0
  101. package/dist/http/middlewares/set-context.js.map +1 -0
  102. package/dist/http/router.d.ts +100 -0
  103. package/dist/http/router.d.ts.map +1 -0
  104. package/dist/http/router.js +764 -0
  105. package/dist/http/router.js.map +1 -0
  106. package/dist/http/types.d.ts +141 -0
  107. package/dist/http/types.d.ts.map +1 -0
  108. package/dist/http/types.js +16 -0
  109. package/dist/http/types.js.map +1 -0
  110. package/dist/http/utils/define-middlewares.d.ts +18 -0
  111. package/dist/http/utils/define-middlewares.d.ts.map +1 -0
  112. package/dist/http/utils/define-middlewares.js +40 -0
  113. package/dist/http/utils/define-middlewares.js.map +1 -0
  114. package/dist/http/utils/get-query-config.d.ts +42 -0
  115. package/dist/http/utils/get-query-config.d.ts.map +1 -0
  116. package/dist/http/utils/get-query-config.js +183 -0
  117. package/dist/http/utils/get-query-config.js.map +1 -0
  118. package/dist/http/utils/http-compression.d.ts +5 -0
  119. package/dist/http/utils/http-compression.d.ts.map +1 -0
  120. package/dist/http/utils/http-compression.js +33 -0
  121. package/dist/http/utils/http-compression.js.map +1 -0
  122. package/dist/http/utils/maybe-apply-link-filter.d.ts +8 -0
  123. package/dist/http/utils/maybe-apply-link-filter.d.ts.map +1 -0
  124. package/dist/http/utils/maybe-apply-link-filter.js +71 -0
  125. package/dist/http/utils/maybe-apply-link-filter.js.map +1 -0
  126. package/dist/http/utils/refetch-entities.d.ts +5 -0
  127. package/dist/http/utils/refetch-entities.d.ts.map +1 -0
  128. package/dist/http/utils/refetch-entities.js +29 -0
  129. package/dist/http/utils/refetch-entities.js.map +1 -0
  130. package/dist/http/utils/restricted-fields.d.ts +6 -0
  131. package/dist/http/utils/restricted-fields.d.ts.map +1 -0
  132. package/dist/http/utils/restricted-fields.js +30 -0
  133. package/dist/http/utils/restricted-fields.js.map +1 -0
  134. package/dist/http/utils/unless-path.d.ts +9 -0
  135. package/dist/http/utils/unless-path.d.ts.map +1 -0
  136. package/dist/http/utils/unless-path.js +19 -0
  137. package/dist/http/utils/unless-path.js.map +1 -0
  138. package/dist/http/utils/validate-body.d.ts +5 -0
  139. package/dist/http/utils/validate-body.d.ts.map +1 -0
  140. package/dist/http/utils/validate-body.js +23 -0
  141. package/dist/http/utils/validate-body.js.map +1 -0
  142. package/dist/http/utils/validate-query.d.ts +6 -0
  143. package/dist/http/utils/validate-query.d.ts.map +1 -0
  144. package/dist/http/utils/validate-query.js +79 -0
  145. package/dist/http/utils/validate-query.js.map +1 -0
  146. package/dist/index.d.ts +16 -0
  147. package/dist/index.d.ts.map +1 -0
  148. package/dist/index.js +34 -0
  149. package/dist/index.js.map +1 -0
  150. package/dist/jobs/index.d.ts +2 -0
  151. package/dist/jobs/index.d.ts.map +1 -0
  152. package/dist/jobs/index.js +18 -0
  153. package/dist/jobs/index.js.map +1 -0
  154. package/dist/jobs/job-loader.d.ts +37 -0
  155. package/dist/jobs/job-loader.d.ts.map +1 -0
  156. package/dist/jobs/job-loader.js +130 -0
  157. package/dist/jobs/job-loader.js.map +1 -0
  158. package/dist/links/index.d.ts +2 -0
  159. package/dist/links/index.d.ts.map +1 -0
  160. package/dist/links/index.js +18 -0
  161. package/dist/links/index.js.map +1 -0
  162. package/dist/links/link-loader.d.ts +10 -0
  163. package/dist/links/link-loader.d.ts.map +1 -0
  164. package/dist/links/link-loader.js +74 -0
  165. package/dist/links/link-loader.js.map +1 -0
  166. package/dist/logger/index.d.ts +3 -0
  167. package/dist/logger/index.d.ts.map +1 -0
  168. package/dist/logger/index.js +9 -0
  169. package/dist/logger/index.js.map +1 -0
  170. package/dist/mikro-orm-cli/bin.d.ts +14 -0
  171. package/dist/mikro-orm-cli/bin.d.ts.map +1 -0
  172. package/dist/mikro-orm-cli/bin.js +54 -0
  173. package/dist/mikro-orm-cli/bin.js.map +1 -0
  174. package/dist/modules-sdk/index.d.ts +2 -0
  175. package/dist/modules-sdk/index.d.ts.map +1 -0
  176. package/dist/modules-sdk/index.js +18 -0
  177. package/dist/modules-sdk/index.js.map +1 -0
  178. package/dist/orchestration/index.d.ts +2 -0
  179. package/dist/orchestration/index.d.ts.map +1 -0
  180. package/dist/orchestration/index.js +18 -0
  181. package/dist/orchestration/index.js.map +1 -0
  182. package/dist/subscribers/index.d.ts +3 -0
  183. package/dist/subscribers/index.d.ts.map +1 -0
  184. package/dist/subscribers/index.js +19 -0
  185. package/dist/subscribers/index.js.map +1 -0
  186. package/dist/subscribers/subscriber-loader.d.ts +11 -0
  187. package/dist/subscribers/subscriber-loader.d.ts.map +1 -0
  188. package/dist/subscribers/subscriber-loader.js +196 -0
  189. package/dist/subscribers/subscriber-loader.js.map +1 -0
  190. package/dist/subscribers/types.d.ts +15 -0
  191. package/dist/subscribers/types.d.ts.map +1 -0
  192. package/dist/subscribers/types.js +3 -0
  193. package/dist/subscribers/types.js.map +1 -0
  194. package/dist/telemetry/index.d.ts +50 -0
  195. package/dist/telemetry/index.d.ts.map +1 -0
  196. package/dist/telemetry/index.js +81 -0
  197. package/dist/telemetry/index.js.map +1 -0
  198. package/dist/types/container.d.ts +62 -0
  199. package/dist/types/container.d.ts.map +1 -0
  200. package/dist/types/container.js +3 -0
  201. package/dist/types/container.js.map +1 -0
  202. package/dist/types/index.d.ts +2 -0
  203. package/dist/types/index.d.ts.map +1 -0
  204. package/dist/types/index.js +18 -0
  205. package/dist/types/index.js.map +1 -0
  206. package/dist/utils/index.d.ts +3 -0
  207. package/dist/utils/index.d.ts.map +1 -0
  208. package/dist/utils/index.js +19 -0
  209. package/dist/utils/index.js.map +1 -0
  210. package/dist/workflows/index.d.ts +3 -0
  211. package/dist/workflows/index.d.ts.map +1 -0
  212. package/dist/workflows/index.js +19 -0
  213. package/dist/workflows/index.js.map +1 -0
  214. package/dist/workflows/workflow-loader.d.ts +10 -0
  215. package/dist/workflows/workflow-loader.d.ts.map +1 -0
  216. package/dist/workflows/workflow-loader.js +74 -0
  217. package/dist/workflows/workflow-loader.js.map +1 -0
  218. package/dist/workflows-sdk/composer.d.ts +2 -0
  219. package/dist/workflows-sdk/composer.d.ts.map +1 -0
  220. package/dist/workflows-sdk/composer.js +18 -0
  221. package/dist/workflows-sdk/composer.js.map +1 -0
  222. package/dist/workflows-sdk/index.d.ts +3 -0
  223. package/dist/workflows-sdk/index.d.ts.map +1 -0
  224. package/dist/workflows-sdk/index.js +19 -0
  225. package/dist/workflows-sdk/index.js.map +1 -0
  226. package/dist/zod/index.d.ts +2 -0
  227. package/dist/zod/index.d.ts.map +1 -0
  228. package/dist/zod/index.js +18 -0
  229. package/dist/zod/index.js.map +1 -0
  230. package/dist/zod/zod-helpers.d.ts +3 -0
  231. package/dist/zod/zod-helpers.d.ts.map +1 -0
  232. package/dist/zod/zod-helpers.js +95 -0
  233. package/dist/zod/zod-helpers.js.map +1 -0
  234. package/package.json +120 -0
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
3
+ if (kind === "m") throw new TypeError("Private method is not writable");
4
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
5
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
6
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
7
+ };
8
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
10
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
11
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
+ };
13
+ var _Tracer_otTracer;
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.Tracer = void 0;
16
+ const api_1 = require("@opentelemetry/api");
17
+ /**
18
+ * Tracer creates an instrumentation scope within the application
19
+ * code. For example: You might create a tracer for the API
20
+ * requests, another one for the modules, one for workflows
21
+ * and so on.
22
+ *
23
+ * There is no need to create a Tracer instance per HTTP
24
+ * call.
25
+ */
26
+ class Tracer {
27
+ constructor(name, version) {
28
+ this.name = name;
29
+ this.version = version;
30
+ /**
31
+ * Reference to the underlying OpenTelemetry tracer
32
+ */
33
+ _Tracer_otTracer.set(this, void 0);
34
+ __classPrivateFieldSet(this, _Tracer_otTracer, api_1.trace.getTracer(name, version), "f");
35
+ }
36
+ /**
37
+ * Returns the underlying tracer from open telemetry that
38
+ * could be used directly for certain advanced use-cases
39
+ */
40
+ getOTTracer() {
41
+ return __classPrivateFieldGet(this, _Tracer_otTracer, "f");
42
+ }
43
+ /**
44
+ * Trace a function call. Using this method will create a
45
+ * child scope for the invocations within the callback.
46
+ */
47
+ trace(name, callback) {
48
+ return __classPrivateFieldGet(this, _Tracer_otTracer, "f").startActiveSpan(name, callback);
49
+ }
50
+ /**
51
+ * Returns the active context
52
+ */
53
+ getActiveContext() {
54
+ return api_1.context.active();
55
+ }
56
+ /**
57
+ * Returns the propagation state from the current active
58
+ * context
59
+ */
60
+ getPropagationState() {
61
+ let output = {};
62
+ api_1.propagation.inject(api_1.context.active(), output);
63
+ return output;
64
+ }
65
+ /**
66
+ * Use the existing propogation state and trace an action. This
67
+ * will allow the newly traced action to be part of some
68
+ * existing trace
69
+ */
70
+ withPropagationState(state) {
71
+ return {
72
+ trace: (name, callback) => {
73
+ const activeContext = api_1.propagation.extract(api_1.context.active(), state);
74
+ return __classPrivateFieldGet(this, _Tracer_otTracer, "f").startActiveSpan(name, {}, activeContext, callback);
75
+ },
76
+ };
77
+ }
78
+ }
79
+ exports.Tracer = Tracer;
80
+ _Tracer_otTracer = new WeakMap();
81
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/telemetry/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,4CAM2B;AAE3B;;;;;;;;GAQG;AACH,MAAa,MAAM;IAKjB,YAAmB,IAAY,EAAS,OAAgB;QAArC,SAAI,GAAJ,IAAI,CAAQ;QAAS,YAAO,GAAP,OAAO,CAAS;QAJxD;;WAEG;QACH,mCAAmB;QAEjB,uBAAA,IAAI,oBAAa,WAAK,CAAC,SAAS,CAAC,IAAI,EAAE,OAAO,CAAC,MAAA,CAAA;IACjD,CAAC;IAED;;;OAGG;IACH,WAAW;QACT,OAAO,uBAAA,IAAI,wBAAU,CAAA;IACvB,CAAC;IAED;;;OAGG;IACH,KAAK,CACH,IAAY,EACZ,QAAW;QAEX,OAAO,uBAAA,IAAI,wBAAU,CAAC,eAAe,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAA;IACvD,CAAC;IAED;;OAEG;IACH,gBAAgB;QACd,OAAO,aAAO,CAAC,MAAM,EAAE,CAAA;IACzB,CAAC;IAED;;;OAGG;IACH,mBAAmB;QACjB,IAAI,MAAM,GAAG,EAAE,CAAA;QACf,iBAAW,CAAC,MAAM,CAAC,aAAO,CAAC,MAAM,EAAE,EAAE,MAAM,CAAC,CAAA;QAC5C,OAAO,MAAsD,CAAA;IAC/D,CAAC;IAED;;;;OAIG;IACH,oBAAoB,CAAC,KAAmD;QACtE,OAAO;YACL,KAAK,EAAE,CACL,IAAY,EACZ,QAAW,EACI,EAAE;gBACjB,MAAM,aAAa,GAAG,iBAAW,CAAC,OAAO,CAAC,aAAO,CAAC,MAAM,EAAE,EAAE,KAAK,CAAC,CAAA;gBAClE,OAAO,uBAAA,IAAI,wBAAU,CAAC,eAAe,CAAC,IAAI,EAAE,EAAE,EAAE,aAAa,EAAE,QAAQ,CAAC,CAAA;YAC1E,CAAC;SACF,CAAA;IACH,CAAC;CACF;AA7DD,wBA6DC"}
@@ -0,0 +1,62 @@
1
+ import { Link } from "@etohq/modules-sdk";
2
+ import { ConfigModule, IApiKeyModuleService, IAuthModuleService, ICacheService, ICartModuleService, ICurrencyModuleService, ICustomerModuleService, IEventBusModuleService, IFileModuleService, IFulfillmentModuleService, IInventoryService, ILockingModule, INotificationModuleService, IOrderModuleService, IPaymentModuleService, IPricingModuleService, IProductModuleService, IPromotionModuleService, IRegionModuleService, ISalesChannelModuleService, IStockLocationService, IStoreModuleService, ITaxModuleService, IUserModuleService, IWorkflowEngineService, Logger, ModuleImplementations, RemoteQueryFunction } from "@etohq/types";
3
+ import { ContainerRegistrationKeys, Modules } from "@etohq/utils";
4
+ import { Knex } from "@mikro-orm/knex";
5
+ import { AwilixContainer, ResolveOptions } from "awilix";
6
+ declare module "@etohq/types" {
7
+ interface ModuleImplementations {
8
+ /**
9
+ * @deprecated use {@link ContainerRegistrationKeys.LINK} instead.
10
+ */
11
+ [ContainerRegistrationKeys.REMOTE_LINK]: Link;
12
+ /**
13
+ * @version 2.2.0
14
+ */
15
+ [ContainerRegistrationKeys.LINK]: Link;
16
+ [ContainerRegistrationKeys.CONFIG_MODULE]: ConfigModule;
17
+ [ContainerRegistrationKeys.PG_CONNECTION]: Knex<any>;
18
+ [ContainerRegistrationKeys.REMOTE_QUERY]: RemoteQueryFunction;
19
+ [ContainerRegistrationKeys.QUERY]: Omit<RemoteQueryFunction, symbol>;
20
+ [ContainerRegistrationKeys.LOGGER]: Logger;
21
+ [Modules.AUTH]: IAuthModuleService;
22
+ [Modules.CACHE]: ICacheService;
23
+ [Modules.CART]: ICartModuleService;
24
+ [Modules.CUSTOMER]: ICustomerModuleService;
25
+ [Modules.EVENT_BUS]: IEventBusModuleService;
26
+ [Modules.INVENTORY]: IInventoryService;
27
+ [Modules.PAYMENT]: IPaymentModuleService;
28
+ [Modules.PRICING]: IPricingModuleService;
29
+ [Modules.PRODUCT]: IProductModuleService;
30
+ [Modules.PROMOTION]: IPromotionModuleService;
31
+ [Modules.SALES_CHANNEL]: ISalesChannelModuleService;
32
+ [Modules.TAX]: ITaxModuleService;
33
+ [Modules.FULFILLMENT]: IFulfillmentModuleService;
34
+ [Modules.STOCK_LOCATION]: IStockLocationService;
35
+ [Modules.USER]: IUserModuleService;
36
+ [Modules.WORKFLOW_ENGINE]: IWorkflowEngineService;
37
+ [Modules.REGION]: IRegionModuleService;
38
+ [Modules.ORDER]: IOrderModuleService;
39
+ [Modules.API_KEY]: IApiKeyModuleService;
40
+ [Modules.STORE]: IStoreModuleService;
41
+ [Modules.CURRENCY]: ICurrencyModuleService;
42
+ [Modules.FILE]: IFileModuleService;
43
+ [Modules.NOTIFICATION]: INotificationModuleService;
44
+ [Modules.LOCKING]: ILockingModule;
45
+ }
46
+ }
47
+ export type EtoContainer<Cradle extends object = ModuleImplementations> = Omit<AwilixContainer, "resolve"> & {
48
+ resolve<K extends keyof Cradle>(key: K, resolveOptions?: ResolveOptions): Cradle[K];
49
+ resolve<T>(key: string, resolveOptions?: ResolveOptions): T;
50
+ /**
51
+ * @ignore
52
+ */
53
+ registerAdd: <T>(name: string, registration: T) => EtoContainer;
54
+ /**
55
+ * @ignore
56
+ */
57
+ createScope: () => EtoContainer;
58
+ };
59
+ export type ContainerLike = {
60
+ resolve<T = unknown>(key: string): T;
61
+ };
62
+ //# sourceMappingURL=container.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"container.d.ts","sourceRoot":"","sources":["../../src/types/container.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAA;AACzC,OAAO,EACL,YAAY,EACZ,oBAAoB,EACpB,kBAAkB,EAClB,aAAa,EACb,kBAAkB,EAClB,sBAAsB,EACtB,sBAAsB,EACtB,sBAAsB,EACtB,kBAAkB,EAClB,yBAAyB,EACzB,iBAAiB,EACjB,cAAc,EACd,0BAA0B,EAC1B,mBAAmB,EACnB,qBAAqB,EACrB,qBAAqB,EACrB,qBAAqB,EACrB,uBAAuB,EACvB,oBAAoB,EACpB,0BAA0B,EAC1B,qBAAqB,EACrB,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,EAClB,sBAAsB,EACtB,MAAM,EACN,qBAAqB,EACrB,mBAAmB,EACpB,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,yBAAyB,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACjE,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAA;AACtC,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAA;AAExD,OAAO,QAAQ,cAAc,CAAC;IAC5B,UAAiB,qBAAqB;QACpC;;WAEG;QACH,CAAC,yBAAyB,CAAC,WAAW,CAAC,EAAE,IAAI,CAAA;QAC7C;;WAEG;QACH,CAAC,yBAAyB,CAAC,IAAI,CAAC,EAAE,IAAI,CAAA;QACtC,CAAC,yB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;QACjD,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,oBAAoB,CAAA;QACtC,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,mBAAmB,CAAA;QACpC,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,oBAAoB,CAAA;QACvC,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,mBAAmB,CAAA;QACpC,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,sBAAsB,CAAA;QAC1C,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,kBAAkB,CAAA;QAClC,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,0BAA0B,CAAA;QAClD,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,cAAc,CAAA;KAClC;CACF;AAED,MAAM,MAAM,YAAY,CAAC,MAAM,SAAS,MAAM,GAAG,qBAAqB,IACpE,IAAI,CAAC,eAAe,EAAE,SAAS,CAAC,GAAG;IACjC,OAAO,CAAC,CAAC,SAAS,MAAM,MAAM,EAC5B,GAAG,EAAE,CAAC,EACN,cAAc,CAAC,EAAE,cAAc,GAC9B,MAAM,CAAC,CAAC,CAAC,CAAA;IACZ,OAAO,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,cAAc,GAAG,CAAC,CAAA;IAE3D;;OAEG;IACH,WAAW,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC,KAAK,YAAY,CAAA;IAC/D;;OAEG;IACH,WAAW,EAAE,MAAM,YAAY,CAAA;CAChC,CAAA;AAEH,MAAM,MAAM,aAAa,GAAG;IAC1B,OAAO,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,CAAC,CAAA;CACrC,CAAA"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=container.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"container.js","sourceRoot":"","sources":["../../src/types/container.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export * from "@etohq/types";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA"}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("@etohq/types"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA4B"}
@@ -0,0 +1,3 @@
1
+ import "../types/container";
2
+ export * from "@etohq/utils";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,CAAA;AAE3B,cAAc,cAAc,CAAA"}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ require("../types/container");
18
+ __exportStar(require("@etohq/utils"), exports);
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8BAA2B;AAE3B,+CAA4B"}
@@ -0,0 +1,3 @@
1
+ import "../types/container";
2
+ export * from "./workflow-loader";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/workflows/index.ts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,CAAA;AAE3B,cAAc,mBAAmB,CAAA"}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ require("../types/container");
18
+ __exportStar(require("./workflow-loader"), exports);
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/workflows/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8BAA2B;AAE3B,oDAAiC"}
@@ -0,0 +1,10 @@
1
+ export declare class WorkflowLoader {
2
+ #private;
3
+ constructor(sourceDir: string | string[]);
4
+ /**
5
+ * Load workflows from the source paths, workflows are registering themselves,
6
+ * therefore we only need to import them
7
+ */
8
+ load(): Promise<void>;
9
+ }
10
+ //# sourceMappingURL=workflow-loader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflow-loader.d.ts","sourceRoot":"","sources":["../../src/workflows/workflow-loader.ts"],"names":[],"mappings":"AAMA,qBAAa,cAAc;;gBAmBb,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE;IAIxC;;;OAGG;IACG,IAAI;CAoCX"}
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
3
+ if (kind === "m") throw new TypeError("Private method is not writable");
4
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
5
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
6
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
7
+ };
8
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
10
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
11
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
+ };
13
+ var _WorkflowLoader_sourceDir, _WorkflowLoader_excludes;
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.WorkflowLoader = void 0;
16
+ const utils_1 = require("@etohq/utils");
17
+ const promises_1 = require("fs/promises");
18
+ const path_1 = require("path");
19
+ const logger_1 = require("../logger");
20
+ class WorkflowLoader {
21
+ constructor(sourceDir) {
22
+ /**
23
+ * The directory from which to load the workflows
24
+ * @private
25
+ */
26
+ _WorkflowLoader_sourceDir.set(this, void 0);
27
+ /**
28
+ * The list of file names to exclude from the subscriber scan
29
+ * @private
30
+ */
31
+ _WorkflowLoader_excludes.set(this, [
32
+ /index\.js/,
33
+ /index\.ts/,
34
+ /\.DS_Store/,
35
+ /(\.ts\.map|\.js\.map|\.d\.ts|\.md)/,
36
+ /^_[^/\\]*(\.[^/\\]+)?$/,
37
+ ]);
38
+ __classPrivateFieldSet(this, _WorkflowLoader_sourceDir, sourceDir, "f");
39
+ }
40
+ /**
41
+ * Load workflows from the source paths, workflows are registering themselves,
42
+ * therefore we only need to import them
43
+ */
44
+ async load() {
45
+ const normalizedSourcePath = Array.isArray(__classPrivateFieldGet(this, _WorkflowLoader_sourceDir, "f"))
46
+ ? __classPrivateFieldGet(this, _WorkflowLoader_sourceDir, "f")
47
+ : [__classPrivateFieldGet(this, _WorkflowLoader_sourceDir, "f")];
48
+ const promises = normalizedSourcePath.map(async (sourcePath) => {
49
+ try {
50
+ await (0, promises_1.access)(sourcePath);
51
+ }
52
+ catch {
53
+ logger_1.logger.info(`No workflow to load from ${sourcePath}. skipped.`);
54
+ return;
55
+ }
56
+ return await (0, utils_1.readDirRecursive)(sourcePath).then(async (entries) => {
57
+ const fileEntries = entries.filter((entry) => {
58
+ return (!entry.isDirectory() &&
59
+ !__classPrivateFieldGet(this, _WorkflowLoader_excludes, "f").some((exclude) => exclude.test(entry.name)));
60
+ });
61
+ logger_1.logger.debug(`Registering workflows from ${sourcePath}.`);
62
+ return await (0, utils_1.promiseAll)(fileEntries.map(async (entry) => {
63
+ const fullPath = (0, path_1.join)(entry.path, entry.name);
64
+ return await (0, utils_1.dynamicImport)(fullPath);
65
+ }));
66
+ });
67
+ });
68
+ await (0, utils_1.promiseAll)(promises);
69
+ logger_1.logger.debug(`Workflows registered.`);
70
+ }
71
+ }
72
+ exports.WorkflowLoader = WorkflowLoader;
73
+ _WorkflowLoader_sourceDir = new WeakMap(), _WorkflowLoader_excludes = new WeakMap();
74
+ //# sourceMappingURL=workflow-loader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflow-loader.js","sourceRoot":"","sources":["../../src/workflows/workflow-loader.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,wCAA0E;AAE1E,0CAAoC;AACpC,+BAA2B;AAC3B,sCAAkC;AAElC,MAAa,cAAc;IAmBzB,YAAY,SAA4B;QAlBxC;;;WAGG;QACH,4CAA6B;QAE7B;;;WAGG;QACH,mCAAsB;YACpB,WAAW;YACX,WAAW;YACX,YAAY;YACZ,oCAAoC;YACpC,wBAAwB;SACzB,EAAA;QAGC,uBAAA,IAAI,6BAAc,SAAS,MAAA,CAAA;IAC7B,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,IAAI;QACR,MAAM,oBAAoB,GAAG,KAAK,CAAC,OAAO,CAAC,uBAAA,IAAI,iCAAW,CAAC;YACzD,CAAC,CAAC,uBAAA,IAAI,iCAAW;YACjB,CAAC,CAAC,CAAC,uBAAA,IAAI,iCAAW,CAAC,CAAA;QAErB,MAAM,QAAQ,GAAG,oBAAoB,CAAC,GAAG,CAAC,KAAK,EAAE,UAAU,EAAE,EAAE;YAC7D,IAAI,CAAC;gBACH,MAAM,IAAA,iBAAM,EAAC,UAAU,CAAC,CAAA;YAC1B,CAAC;YAAC,MAAM,CAAC;gBACP,eAAM,CAAC,IAAI,CAAC,4BAA4B,UAAU,YAAY,CAAC,CAAA;gBAC/D,OAAM;YACR,CAAC;YAED,OAAO,MAAM,IAAA,wBAAgB,EAAC,UAAU,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;gBAC/D,MAAM,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,KAAa,EAAE,EAAE;oBACnD,OAAO,CACL,CAAC,KAAK,CAAC,WAAW,EAAE;wBACpB,CAAC,uBAAA,IAAI,gCAAU,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAC5D,CAAA;gBACH,CAAC,CAAC,CAAA;gBAEF,eAAM,CAAC,KAAK,CAAC,8BAA8B,UAAU,GAAG,CAAC,CAAA;gBAEzD,OAAO,MAAM,IAAA,kBAAU,EACrB,WAAW,CAAC,GAAG,CAAC,KAAK,EAAE,KAAa,EAAE,EAAE;oBACtC,MAAM,QAAQ,GAAG,IAAA,WAAI,EAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,CAAA;oBAC7C,OAAO,MAAM,IAAA,qBAAa,EAAC,QAAQ,CAAC,CAAA;gBACtC,CAAC,CAAC,CACH,CAAA;YACH,CAAC,CAAC,CAAA;QACJ,CAAC,CAAC,CAAA;QAEF,MAAM,IAAA,kBAAU,EAAC,QAAQ,CAAC,CAAA;QAE1B,eAAM,CAAC,KAAK,CAAC,uBAAuB,CAAC,CAAA;IACvC,CAAC;CACF;AA/DD,wCA+DC"}
@@ -0,0 +1,2 @@
1
+ export * from "@etohq/workflows-sdk/composer";
2
+ //# sourceMappingURL=composer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"composer.d.ts","sourceRoot":"","sources":["../../src/workflows-sdk/composer.ts"],"names":[],"mappings":"AAAA,cAAc,+BAA+B,CAAA"}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("@etohq/workflows-sdk/composer"), exports);
18
+ //# sourceMappingURL=composer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"composer.js","sourceRoot":"","sources":["../../src/workflows-sdk/composer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gEAA6C"}
@@ -0,0 +1,3 @@
1
+ import "../types/container";
2
+ export * from "@etohq/workflows-sdk";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/workflows-sdk/index.ts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,CAAA;AAE3B,cAAc,sBAAsB,CAAA"}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ require("../types/container");
18
+ __exportStar(require("@etohq/workflows-sdk"), exports);
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/workflows-sdk/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8BAA2B;AAE3B,uDAAoC"}
@@ -0,0 +1,2 @@
1
+ export * from "./zod-helpers";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/zod/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAA"}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./zod-helpers"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/zod/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA6B"}
@@ -0,0 +1,3 @@
1
+ import { z } from "zod";
2
+ export declare function zodValidator<T>(zodSchema: z.ZodObject<any, any> | z.ZodEffects<any, any>, body: T): Promise<z.ZodRawShape>;
3
+ //# sourceMappingURL=zod-helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"zod-helpers.d.ts","sourceRoot":"","sources":["../../src/zod/zod-helpers.ts"],"names":[],"mappings":"AACA,OAAO,EACL,CAAC,EAKF,MAAM,KAAK,CAAA;AAwGZ,wBAAsB,YAAY,CAAC,CAAC,EAClC,SAAS,EAAE,CAAC,CAAC,SAAS,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC,EACzD,IAAI,EAAE,CAAC,GACN,OAAO,CAAC,CAAC,CAAC,WAAW,CAAC,CAmBxB"}
@@ -0,0 +1,95 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.zodValidator = zodValidator;
4
+ const utils_1 = require("@etohq/framework/utils");
5
+ const zod_1 = require("zod");
6
+ const formatPath = (issue) => {
7
+ return issue.path.join(", ");
8
+ };
9
+ const formatInvalidType = (issues) => {
10
+ const expected = issues
11
+ .map((i) => {
12
+ // Unforutnately the zod library doesn't distinguish between a wrong type and a required field, which we want to handle differently
13
+ if (i.code === "invalid_type" && i.message !== "Required") {
14
+ return i.expected;
15
+ }
16
+ return;
17
+ })
18
+ .filter(Boolean);
19
+ if (!expected.length) {
20
+ return;
21
+ }
22
+ const received = issues?.[0]?.received;
23
+ return `Expected type: '${expected.join(", ")}' for field '${formatPath(issues[0])}', got: '${received}'`;
24
+ };
25
+ const formatRequiredField = (issues) => {
26
+ const expected = issues
27
+ .map((i) => {
28
+ if (i.code === "invalid_type" && i.message === "Required") {
29
+ return i.expected;
30
+ }
31
+ return;
32
+ })
33
+ .filter(Boolean);
34
+ if (!expected.length) {
35
+ return;
36
+ }
37
+ return `Field '${formatPath(issues[0])}' is required`;
38
+ };
39
+ const formatUnionError = (issue) => {
40
+ const issues = issue.unionErrors.flatMap((e) => e.issues);
41
+ return (formatInvalidType(issues) || formatRequiredField(issues) || issue.message);
42
+ };
43
+ const formatError = (err) => {
44
+ const issueMessages = err.issues.slice(0, 3).map((issue) => {
45
+ switch (issue.code) {
46
+ case "invalid_type":
47
+ return (formatInvalidType([issue]) ||
48
+ formatRequiredField([issue]) ||
49
+ issue.message);
50
+ case "invalid_literal":
51
+ return `Expected literal: '${issue.expected}' for field '${formatPath(issue)}', but got: '${issue.received}'`;
52
+ case "invalid_union":
53
+ return formatUnionError(issue);
54
+ case "invalid_enum_value":
55
+ return `Expected: '${issue.options.join(", ")}' for field '${formatPath(issue)}', but got: '${issue.received}'`;
56
+ case "unrecognized_keys":
57
+ return `Unrecognized fields: '${issue.keys.join(", ")}'`;
58
+ case "invalid_arguments":
59
+ return `Invalid arguments for '${issue.path.join(", ")}'`;
60
+ case "too_small":
61
+ return `Value for field '${formatPath(issue)}' too small, expected at least: '${issue.minimum}'`;
62
+ case "too_big":
63
+ return `Value for field '${formatPath(issue)}' too big, expected at most: '${issue.maximum}'`;
64
+ case "not_multiple_of":
65
+ return `Value for field '${formatPath(issue)}' not multiple of: '${issue.multipleOf}'`;
66
+ case "not_finite":
67
+ return `Value for field '${formatPath(issue)}' not finite: '${issue.message}'`;
68
+ case "invalid_union_discriminator":
69
+ case "invalid_return_type":
70
+ case "invalid_date":
71
+ case "invalid_string":
72
+ case "invalid_intersection_types":
73
+ default:
74
+ return issue.message;
75
+ }
76
+ });
77
+ return issueMessages.join("; ");
78
+ };
79
+ async function zodValidator(zodSchema, body) {
80
+ let strictSchema = zodSchema;
81
+ // ZodEffects doesn't support setting as strict, for all other schemas we want to enforce strictness.
82
+ if ("strict" in zodSchema) {
83
+ strictSchema = zodSchema.strict();
84
+ }
85
+ try {
86
+ return await strictSchema.parseAsync(body);
87
+ }
88
+ catch (err) {
89
+ if (err instanceof zod_1.ZodError) {
90
+ throw new utils_1.EtoError(utils_1.EtoError.Types.INVALID_DATA, `Invalid request: ${formatError(err)}`);
91
+ }
92
+ throw err;
93
+ }
94
+ }
95
+ //# sourceMappingURL=zod-helpers.js.map
@@ -0,0 +1 @@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