@etohq/framework 1.0.0 → 1.2.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 (132) hide show
  1. package/dist/build-tools/compiler.d.ts.map +1 -1
  2. package/dist/build-tools/compiler.js +38 -32
  3. package/dist/build-tools/compiler.js.map +1 -1
  4. package/dist/config/config.d.ts.map +1 -1
  5. package/dist/config/config.js +1 -0
  6. package/dist/config/config.js.map +1 -1
  7. package/dist/config/loader.d.ts +7 -2
  8. package/dist/config/loader.d.ts.map +1 -1
  9. package/dist/config/loader.js +28 -6
  10. package/dist/config/loader.js.map +1 -1
  11. package/dist/config/types.d.ts +4 -166
  12. package/dist/config/types.d.ts.map +1 -1
  13. package/dist/context/index.d.ts +6 -0
  14. package/dist/context/index.d.ts.map +1 -0
  15. package/dist/context/index.js +50 -0
  16. package/dist/context/index.js.map +1 -0
  17. package/dist/error/index.d.ts +205 -0
  18. package/dist/error/index.d.ts.map +1 -0
  19. package/dist/error/index.js +273 -0
  20. package/dist/error/index.js.map +1 -0
  21. package/dist/eto-app-loader.d.ts +6 -4
  22. package/dist/eto-app-loader.d.ts.map +1 -1
  23. package/dist/eto-app-loader.js +53 -11
  24. package/dist/eto-app-loader.js.map +1 -1
  25. package/dist/eto.d.ts +39 -0
  26. package/dist/eto.d.ts.map +1 -0
  27. package/dist/eto.js +148 -0
  28. package/dist/eto.js.map +1 -0
  29. package/dist/feature-flags/feature-flag-loader.d.ts +4 -3
  30. package/dist/feature-flags/feature-flag-loader.d.ts.map +1 -1
  31. package/dist/feature-flags/feature-flag-loader.js +36 -25
  32. package/dist/feature-flags/feature-flag-loader.js.map +1 -1
  33. package/dist/http/encore.d.ts +191 -0
  34. package/dist/http/encore.d.ts.map +1 -0
  35. package/dist/http/encore.js +3 -0
  36. package/dist/http/encore.js.map +1 -0
  37. package/dist/http/index.d.ts +1 -3
  38. package/dist/http/index.d.ts.map +1 -1
  39. package/dist/http/index.js +1 -3
  40. package/dist/http/index.js.map +1 -1
  41. package/dist/http/middlewares/apply-default-filters.d.ts +2 -2
  42. package/dist/http/middlewares/apply-default-filters.d.ts.map +1 -1
  43. package/dist/http/middlewares/apply-default-filters.js +8 -6
  44. package/dist/http/middlewares/apply-default-filters.js.map +1 -1
  45. package/dist/http/middlewares/apply-params-as-filters.d.ts +2 -2
  46. package/dist/http/middlewares/apply-params-as-filters.d.ts.map +1 -1
  47. package/dist/http/middlewares/apply-params-as-filters.js +7 -4
  48. package/dist/http/middlewares/apply-params-as-filters.js.map +1 -1
  49. package/dist/http/middlewares/authenticate-middleware.d.ts +2 -2
  50. package/dist/http/middlewares/authenticate-middleware.d.ts.map +1 -1
  51. package/dist/http/middlewares/authenticate-middleware.js +25 -22
  52. package/dist/http/middlewares/authenticate-middleware.js.map +1 -1
  53. package/dist/http/middlewares/clear-filters-by-key.d.ts +2 -2
  54. package/dist/http/middlewares/clear-filters-by-key.d.ts.map +1 -1
  55. package/dist/http/middlewares/clear-filters-by-key.js +2 -2
  56. package/dist/http/middlewares/clear-filters-by-key.js.map +1 -1
  57. package/dist/http/middlewares/ensure-publishable-api-key.d.ts +2 -2
  58. package/dist/http/middlewares/ensure-publishable-api-key.d.ts.map +1 -1
  59. package/dist/http/middlewares/ensure-publishable-api-key.js +7 -5
  60. package/dist/http/middlewares/ensure-publishable-api-key.js.map +1 -1
  61. package/dist/http/middlewares/error-handler.d.ts +2 -3
  62. package/dist/http/middlewares/error-handler.d.ts.map +1 -1
  63. package/dist/http/middlewares/error-handler.js +6 -3
  64. package/dist/http/middlewares/error-handler.js.map +1 -1
  65. package/dist/http/middlewares/set-context.d.ts +2 -2
  66. package/dist/http/middlewares/set-context.d.ts.map +1 -1
  67. package/dist/http/middlewares/set-context.js +4 -4
  68. package/dist/http/middlewares/set-context.js.map +1 -1
  69. package/dist/http/types.d.ts +41 -31
  70. package/dist/http/types.d.ts.map +1 -1
  71. package/dist/http/types.js.map +1 -1
  72. package/dist/http/utils/http-compression.d.ts +1 -4
  73. package/dist/http/utils/http-compression.d.ts.map +1 -1
  74. package/dist/http/utils/http-compression.js +35 -30
  75. package/dist/http/utils/http-compression.js.map +1 -1
  76. package/dist/http/utils/maybe-apply-link-filter.d.ts +2 -2
  77. package/dist/http/utils/maybe-apply-link-filter.d.ts.map +1 -1
  78. package/dist/http/utils/maybe-apply-link-filter.js +7 -6
  79. package/dist/http/utils/maybe-apply-link-filter.js.map +1 -1
  80. package/dist/http/utils/refetch-entities.d.ts +2 -2
  81. package/dist/http/utils/refetch-entities.d.ts.map +1 -1
  82. package/dist/http/utils/refetch-entities.js.map +1 -1
  83. package/dist/http/utils/unless-path.d.ts +4 -4
  84. package/dist/http/utils/unless-path.d.ts.map +1 -1
  85. package/dist/http/utils/unless-path.js +20 -11
  86. package/dist/http/utils/unless-path.js.map +1 -1
  87. package/dist/http/utils/validate-body.d.ts +1 -4
  88. package/dist/http/utils/validate-body.d.ts.map +1 -1
  89. package/dist/http/utils/validate-body.js +31 -20
  90. package/dist/http/utils/validate-body.js.map +1 -1
  91. package/dist/http/utils/validate-query.d.ts +9 -4
  92. package/dist/http/utils/validate-query.d.ts.map +1 -1
  93. package/dist/http/utils/validate-query.js +63 -20
  94. package/dist/http/utils/validate-query.js.map +1 -1
  95. package/dist/index.d.ts +4 -0
  96. package/dist/index.d.ts.map +1 -1
  97. package/dist/index.js +4 -0
  98. package/dist/index.js.map +1 -1
  99. package/dist/jobs/job-loader.d.ts +12 -4
  100. package/dist/jobs/job-loader.d.ts.map +1 -1
  101. package/dist/jobs/job-loader.js +56 -38
  102. package/dist/jobs/job-loader.js.map +1 -1
  103. package/dist/link-modules-sdk/index.d.ts +2 -0
  104. package/dist/link-modules-sdk/index.d.ts.map +1 -0
  105. package/dist/link-modules-sdk/index.js +18 -0
  106. package/dist/link-modules-sdk/index.js.map +1 -0
  107. package/dist/loader.d.ts +24 -0
  108. package/dist/loader.d.ts.map +1 -0
  109. package/dist/loader.js +104 -0
  110. package/dist/loader.js.map +1 -0
  111. package/dist/mikro-orm-cli/bin.js +0 -0
  112. package/dist/subscribers/subscriber-loader.d.ts +15 -1
  113. package/dist/subscribers/subscriber-loader.d.ts.map +1 -1
  114. package/dist/subscribers/subscriber-loader.js +44 -17
  115. package/dist/subscribers/subscriber-loader.js.map +1 -1
  116. package/dist/types/container.d.ts +2 -23
  117. package/dist/types/container.d.ts.map +1 -1
  118. package/dist/zod/zod-helpers.js +1 -1
  119. package/dist/zod/zod-helpers.js.map +1 -1
  120. package/package.json +12 -9
  121. package/dist/http/express-loader.d.ts +0 -8
  122. package/dist/http/express-loader.d.ts.map +0 -1
  123. package/dist/http/express-loader.js +0 -85
  124. package/dist/http/express-loader.js.map +0 -1
  125. package/dist/http/router.d.ts +0 -100
  126. package/dist/http/router.d.ts.map +0 -1
  127. package/dist/http/router.js +0 -764
  128. package/dist/http/router.js.map +0 -1
  129. package/dist/http/utils/define-middlewares.d.ts +0 -18
  130. package/dist/http/utils/define-middlewares.d.ts.map +0 -1
  131. package/dist/http/utils/define-middlewares.js +0 -40
  132. package/dist/http/utils/define-middlewares.js.map +0 -1
@@ -0,0 +1,205 @@
1
+ export declare class APIError extends Error {
2
+ /**
3
+ * The error code.
4
+ */
5
+ readonly code: ErrCode;
6
+ readonly details?: ErrDetails;
7
+ static canceled(msg: string, cause?: Error): APIError;
8
+ static unknown(msg: string, cause?: Error): APIError;
9
+ static invalidArgument(msg: string, cause?: Error): APIError;
10
+ static deadlineExceeded(msg: string, cause?: Error): APIError;
11
+ static notFound(msg: string, cause?: Error): APIError;
12
+ static alreadyExists(msg: string, cause?: Error): APIError;
13
+ static permissionDenied(msg: string, cause?: Error): APIError;
14
+ static resourceExhausted(msg: string, cause?: Error): APIError;
15
+ static failedPrecondition(msg: string, cause?: Error): APIError;
16
+ static aborted(msg: string, cause?: Error): APIError;
17
+ static outOfRange(msg: string, cause?: Error): APIError;
18
+ static unimplemented(msg: string, cause?: Error): APIError;
19
+ static internal(msg: string, cause?: Error): APIError;
20
+ static unavailable(msg: string, cause?: Error): APIError;
21
+ static dataLoss(msg: string, cause?: Error): APIError;
22
+ static unauthenticated(msg: string, cause?: Error): APIError;
23
+ withDetails(details: ErrDetails): APIError;
24
+ constructor(code: ErrCode, msg: string, cause?: Error, details?: ErrDetails);
25
+ }
26
+ export type ErrDetails = Record<string, any>;
27
+ export declare enum ErrCode {
28
+ /**
29
+ * OK indicates the operation was successful.
30
+ */
31
+ OK = "ok",
32
+ /**
33
+ * Canceled indicates the operation was canceled (typically by the caller).
34
+ *
35
+ * Encore will generate this error code when cancellation is requested.
36
+ */
37
+ Canceled = "canceled",
38
+ /**
39
+ * Unknown error. An example of where this error may be returned is
40
+ * if a Status value received from another address space belongs to
41
+ * an error-space that is not known in this address space. Also
42
+ * errors raised by APIs that do not return enough error information
43
+ * may be converted to this error.
44
+ *
45
+ * Encore will generate this error code in the above two mentioned cases.
46
+ */
47
+ Unknown = "unknown",
48
+ /**
49
+ * InvalidArgument indicates client specified an invalid argument.
50
+ * Note that this differs from FailedPrecondition. It indicates arguments
51
+ * that are problematic regardless of the state of the system
52
+ * (e.g., a malformed file name).
53
+ *
54
+ * This error code will not be generated by the gRPC framework.
55
+ */
56
+ InvalidArgument = "invalid_argument",
57
+ /**
58
+ * DeadlineExceeded means operation expired before completion.
59
+ * For operations that change the state of the system, this error may be
60
+ * returned even if the operation has completed successfully. For
61
+ * example, a successful response from a server could have been delayed
62
+ * long enough for the deadline to expire.
63
+ *
64
+ * The gRPC framework will generate this error code when the deadline is
65
+ * exceeded.
66
+ */
67
+ DeadlineExceeded = "deadline_exceeded",
68
+ /**
69
+ * NotFound means some requested entity (e.g., file or directory) was
70
+ * not found.
71
+ *
72
+ * This error code will not be generated by the gRPC framework.
73
+ */
74
+ NotFound = "not_found",
75
+ /**
76
+ * AlreadyExists means an attempt to create an entity failed because one
77
+ * already exists.
78
+ *
79
+ * This error code will not be generated by the gRPC framework.
80
+ */
81
+ AlreadyExists = "already_exists",
82
+ /**
83
+ * PermissionDenied indicates the caller does not have permission to
84
+ * execute the specified operation. It must not be used for rejections
85
+ * caused by exhausting some resource (use ResourceExhausted
86
+ * instead for those errors). It must not be
87
+ * used if the caller cannot be identified (use Unauthenticated
88
+ * instead for those errors).
89
+ *
90
+ * This error code will not be generated by the gRPC core framework,
91
+ * but expect authentication middleware to use it.
92
+ */
93
+ PermissionDenied = "permission_denied",
94
+ /**
95
+ * ResourceExhausted indicates some resource has been exhausted, perhaps
96
+ * a per-user quota, or perhaps the entire file system is out of space.
97
+ *
98
+ * This error code will be generated by the gRPC framework in
99
+ * out-of-memory and server overload situations, or when a message is
100
+ * larger than the configured maximum size.
101
+ */
102
+ ResourceExhausted = "resource_exhausted",
103
+ /**
104
+ * FailedPrecondition indicates operation was rejected because the
105
+ * system is not in a state required for the operation's execution.
106
+ * For example, directory to be deleted may be non-empty, an rmdir
107
+ * operation is applied to a non-directory, etc.
108
+ *
109
+ * A litmus test that may help a service implementor in deciding
110
+ * between FailedPrecondition, Aborted, and Unavailable:
111
+ * (a) Use Unavailable if the client can retry just the failing call.
112
+ * (b) Use Aborted if the client should retry at a higher-level
113
+ * (e.g., restarting a read-modify-write sequence).
114
+ * (c) Use FailedPrecondition if the client should not retry until
115
+ * the system state has been explicitly fixed. E.g., if an "rmdir"
116
+ * fails because the directory is non-empty, FailedPrecondition
117
+ * should be returned since the client should not retry unless
118
+ * they have first fixed up the directory by deleting files from it.
119
+ * (d) Use FailedPrecondition if the client performs conditional
120
+ * REST Get/Update/Delete on a resource and the resource on the
121
+ * server does not match the condition. E.g., conflicting
122
+ * read-modify-write on the same resource.
123
+ *
124
+ * This error code will not be generated by the gRPC framework.
125
+ */
126
+ FailedPrecondition = "failed_precondition",
127
+ /**
128
+ * Aborted indicates the operation was aborted, typically due to a
129
+ * concurrency issue like sequencer check failures, transaction aborts,
130
+ * etc.
131
+ *
132
+ * See litmus test above for deciding between FailedPrecondition,
133
+ * Aborted, and Unavailable.
134
+ */
135
+ Aborted = "aborted",
136
+ /**
137
+ * OutOfRange means operation was attempted past the valid range.
138
+ * E.g., seeking or reading past end of file.
139
+ *
140
+ * Unlike InvalidArgument, this error indicates a problem that may
141
+ * be fixed if the system state changes. For example, a 32-bit file
142
+ * system will generate InvalidArgument if asked to read at an
143
+ * offset that is not in the range [0,2^32-1], but it will generate
144
+ * OutOfRange if asked to read from an offset past the current
145
+ * file size.
146
+ *
147
+ * There is a fair bit of overlap between FailedPrecondition and
148
+ * OutOfRange. We recommend using OutOfRange (the more specific
149
+ * error) when it applies so that callers who are iterating through
150
+ * a space can easily look for an OutOfRange error to detect when
151
+ * they are done.
152
+ *
153
+ * This error code will not be generated by the gRPC framework.
154
+ */
155
+ OutOfRange = "out_of_range",
156
+ /**
157
+ * Unimplemented indicates operation is not implemented or not
158
+ * supported/enabled in this service.
159
+ *
160
+ * This error code will be generated by the gRPC framework. Most
161
+ * commonly, you will see this error code when a method implementation
162
+ * is missing on the server. It can also be generated for unknown
163
+ * compression algorithms or a disagreement as to whether an RPC should
164
+ * be streaming.
165
+ */
166
+ Unimplemented = "unimplemented",
167
+ /**
168
+ * Internal errors. Means some invariants expected by underlying
169
+ * system has been broken. If you see one of these errors,
170
+ * something is very broken.
171
+ *
172
+ * This error code will be generated by the gRPC framework in several
173
+ * internal error conditions.
174
+ */
175
+ Internal = "internal",
176
+ /**
177
+ * Unavailable indicates the service is currently unavailable.
178
+ * This is a most likely a transient condition and may be corrected
179
+ * by retrying with a backoff. Note that it is not always safe to retry
180
+ * non-idempotent operations.
181
+ *
182
+ * See litmus test above for deciding between FailedPrecondition,
183
+ * Aborted, and Unavailable.
184
+ *
185
+ * This error code will be generated by the gRPC framework during
186
+ * abrupt shutdown of a server process or network connection.
187
+ */
188
+ Unavailable = "unavailable",
189
+ /**
190
+ * DataLoss indicates unrecoverable data loss or corruption.
191
+ *
192
+ * This error code will not be generated by the gRPC framework.
193
+ */
194
+ DataLoss = "data_loss",
195
+ /**
196
+ * Unauthenticated indicates the request does not have valid
197
+ * authentication credentials for the operation.
198
+ *
199
+ * The gRPC framework will generate this error code when the
200
+ * authentication metadata is invalid or a Credentials callback fails,
201
+ * but also expect authentication middleware to generate it.
202
+ */
203
+ Unauthenticated = "unauthenticated"
204
+ }
205
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/error/index.ts"],"names":[],"mappings":"AAAA,qBAAa,QAAS,SAAQ,KAAK;IACjC;;OAEG;IACH,SAAgB,IAAI,EAAE,OAAO,CAAA;IAC7B,SAAgB,OAAO,CAAC,EAAE,UAAU,CAAA;IAGpC,MAAM,CAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK;IAK1C,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK;IAKzC,MAAM,CAAC,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK;IAKjD,MAAM,CAAC,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK;IAKlD,MAAM,CAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK;IAK1C,MAAM,CAAC,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK;IAK/C,MAAM,CAAC,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK;IAKlD,MAAM,CAAC,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK;IAKnD,MAAM,CAAC,kBAAkB,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK;IAKpD,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK;IAKzC,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,MA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AE/B;;;;;;;OAOG;IACH,QAAQ,aAAa;IAErB;;;;;;;;;;;OAWG;IACH,WAAW,gBAAgB;IAE3B;;;;OAIG;IACH,QAAQ,cAAc;IAEtB;;;;;;;OAOG;IACH,eAAe,oBAAoB;CACpC"}
@@ -0,0 +1,273 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ErrCode = exports.APIError = void 0;
4
+ class APIError extends Error {
5
+ // Constructs an APIError with the Canceled error code.
6
+ static canceled(msg, cause) {
7
+ return new APIError(ErrCode.Canceled, msg, cause);
8
+ }
9
+ // Constructs an APIError with the Unknown error code.
10
+ static unknown(msg, cause) {
11
+ return new APIError(ErrCode.Unknown, msg, cause);
12
+ }
13
+ // Constructs an APIError with the InvalidArgument error code.
14
+ static invalidArgument(msg, cause) {
15
+ return new APIError(ErrCode.InvalidArgument, msg, cause);
16
+ }
17
+ // Constructs an APIError with the DeadlineExceeded error code.
18
+ static deadlineExceeded(msg, cause) {
19
+ return new APIError(ErrCode.DeadlineExceeded, msg, cause);
20
+ }
21
+ // Constructs an APIError with the NotFound error code.
22
+ static notFound(msg, cause) {
23
+ return new APIError(ErrCode.NotFound, msg, cause);
24
+ }
25
+ // Constructs an APIError with the AlreadyExists error code.
26
+ static alreadyExists(msg, cause) {
27
+ return new APIError(ErrCode.AlreadyExists, msg, cause);
28
+ }
29
+ // Constructs an APIError with the PermissionDenied error code.
30
+ static permissionDenied(msg, cause) {
31
+ return new APIError(ErrCode.PermissionDenied, msg, cause);
32
+ }
33
+ // Constructs an APIError with the ResourceExhausted error code.
34
+ static resourceExhausted(msg, cause) {
35
+ return new APIError(ErrCode.ResourceExhausted, msg, cause);
36
+ }
37
+ // Constructs an APIError with the FailedPrecondition error code.
38
+ static failedPrecondition(msg, cause) {
39
+ return new APIError(ErrCode.FailedPrecondition, msg, cause);
40
+ }
41
+ // Constructs an APIError with the Aborted error code.
42
+ static aborted(msg, cause) {
43
+ return new APIError(ErrCode.Aborted, msg, cause);
44
+ }
45
+ // Constructs an APIError with the OutOfRange error code.
46
+ static outOfRange(msg, cause) {
47
+ return new APIError(ErrCode.OutOfRange, msg, cause);
48
+ }
49
+ // Constructs an APIError with the Unimplemented error code.
50
+ static unimplemented(msg, cause) {
51
+ return new APIError(ErrCode.Unimplemented, msg, cause);
52
+ }
53
+ // Constructs an APIError with the Internal error code.
54
+ static internal(msg, cause) {
55
+ return new APIError(ErrCode.Internal, msg, cause);
56
+ }
57
+ // Constructs an APIError with the Unavailable error code.
58
+ static unavailable(msg, cause) {
59
+ return new APIError(ErrCode.Unavailable, msg, cause);
60
+ }
61
+ // Constructs an APIError with the DataLoss error code.
62
+ static dataLoss(msg, cause) {
63
+ return new APIError(ErrCode.DataLoss, msg, cause);
64
+ }
65
+ // Constructs an APIError with the Unauthenticated error code.
66
+ static unauthenticated(msg, cause) {
67
+ return new APIError(ErrCode.Unauthenticated, msg, cause);
68
+ }
69
+ // Constructs a new APIError from the previous one with the provided details
70
+ withDetails(details) {
71
+ // @ts-ignore
72
+ return new APIError(this.code, this.message, this.cause, details);
73
+ }
74
+ // Constructs an APIError with the given error code, message, and (optionally) cause.
75
+ constructor(code, msg, cause, details) {
76
+ // extending errors causes issues after you construct them, unless you apply the following fixes
77
+ // @ts-ignore
78
+ super(msg, { cause });
79
+ this.code = code;
80
+ this.details = details;
81
+ // set error name as constructor name, make it not enumerable to keep native Error behavior
82
+ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/new.target#new.target_in_constructors
83
+ Object.defineProperty(this, "name", {
84
+ value: "APIError",
85
+ enumerable: false,
86
+ configurable: true,
87
+ });
88
+ // Fix the prototype chain, capture stack trace.
89
+ Object.setPrototypeOf(this, APIError.prototype);
90
+ Error.captureStackTrace(this, this.constructor);
91
+ }
92
+ }
93
+ exports.APIError = APIError;
94
+ var ErrCode;
95
+ (function (ErrCode) {
96
+ /**
97
+ * OK indicates the operation was successful.
98
+ */
99
+ ErrCode["OK"] = "ok";
100
+ /**
101
+ * Canceled indicates the operation was canceled (typically by the caller).
102
+ *
103
+ * Encore will generate this error code when cancellation is requested.
104
+ */
105
+ ErrCode["Canceled"] = "canceled";
106
+ /**
107
+ * Unknown error. An example of where this error may be returned is
108
+ * if a Status value received from another address space belongs to
109
+ * an error-space that is not known in this address space. Also
110
+ * errors raised by APIs that do not return enough error information
111
+ * may be converted to this error.
112
+ *
113
+ * Encore will generate this error code in the above two mentioned cases.
114
+ */
115
+ ErrCode["Unknown"] = "unknown";
116
+ /**
117
+ * InvalidArgument indicates client specified an invalid argument.
118
+ * Note that this differs from FailedPrecondition. It indicates arguments
119
+ * that are problematic regardless of the state of the system
120
+ * (e.g., a malformed file name).
121
+ *
122
+ * This error code will not be generated by the gRPC framework.
123
+ */
124
+ ErrCode["InvalidArgument"] = "invalid_argument";
125
+ /**
126
+ * DeadlineExceeded means operation expired before completion.
127
+ * For operations that change the state of the system, this error may be
128
+ * returned even if the operation has completed successfully. For
129
+ * example, a successful response from a server could have been delayed
130
+ * long enough for the deadline to expire.
131
+ *
132
+ * The gRPC framework will generate this error code when the deadline is
133
+ * exceeded.
134
+ */
135
+ ErrCode["DeadlineExceeded"] = "deadline_exceeded";
136
+ /**
137
+ * NotFound means some requested entity (e.g., file or directory) was
138
+ * not found.
139
+ *
140
+ * This error code will not be generated by the gRPC framework.
141
+ */
142
+ ErrCode["NotFound"] = "not_found";
143
+ /**
144
+ * AlreadyExists means an attempt to create an entity failed because one
145
+ * already exists.
146
+ *
147
+ * This error code will not be generated by the gRPC framework.
148
+ */
149
+ ErrCode["AlreadyExists"] = "already_exists";
150
+ /**
151
+ * PermissionDenied indicates the caller does not have permission to
152
+ * execute the specified operation. It must not be used for rejections
153
+ * caused by exhausting some resource (use ResourceExhausted
154
+ * instead for those errors). It must not be
155
+ * used if the caller cannot be identified (use Unauthenticated
156
+ * instead for those errors).
157
+ *
158
+ * This error code will not be generated by the gRPC core framework,
159
+ * but expect authentication middleware to use it.
160
+ */
161
+ ErrCode["PermissionDenied"] = "permission_denied";
162
+ /**
163
+ * ResourceExhausted indicates some resource has been exhausted, perhaps
164
+ * a per-user quota, or perhaps the entire file system is out of space.
165
+ *
166
+ * This error code will be generated by the gRPC framework in
167
+ * out-of-memory and server overload situations, or when a message is
168
+ * larger than the configured maximum size.
169
+ */
170
+ ErrCode["ResourceExhausted"] = "resource_exhausted";
171
+ /**
172
+ * FailedPrecondition indicates operation was rejected because the
173
+ * system is not in a state required for the operation's execution.
174
+ * For example, directory to be deleted may be non-empty, an rmdir
175
+ * operation is applied to a non-directory, etc.
176
+ *
177
+ * A litmus test that may help a service implementor in deciding
178
+ * between FailedPrecondition, Aborted, and Unavailable:
179
+ * (a) Use Unavailable if the client can retry just the failing call.
180
+ * (b) Use Aborted if the client should retry at a higher-level
181
+ * (e.g., restarting a read-modify-write sequence).
182
+ * (c) Use FailedPrecondition if the client should not retry until
183
+ * the system state has been explicitly fixed. E.g., if an "rmdir"
184
+ * fails because the directory is non-empty, FailedPrecondition
185
+ * should be returned since the client should not retry unless
186
+ * they have first fixed up the directory by deleting files from it.
187
+ * (d) Use FailedPrecondition if the client performs conditional
188
+ * REST Get/Update/Delete on a resource and the resource on the
189
+ * server does not match the condition. E.g., conflicting
190
+ * read-modify-write on the same resource.
191
+ *
192
+ * This error code will not be generated by the gRPC framework.
193
+ */
194
+ ErrCode["FailedPrecondition"] = "failed_precondition";
195
+ /**
196
+ * Aborted indicates the operation was aborted, typically due to a
197
+ * concurrency issue like sequencer check failures, transaction aborts,
198
+ * etc.
199
+ *
200
+ * See litmus test above for deciding between FailedPrecondition,
201
+ * Aborted, and Unavailable.
202
+ */
203
+ ErrCode["Aborted"] = "aborted";
204
+ /**
205
+ * OutOfRange means operation was attempted past the valid range.
206
+ * E.g., seeking or reading past end of file.
207
+ *
208
+ * Unlike InvalidArgument, this error indicates a problem that may
209
+ * be fixed if the system state changes. For example, a 32-bit file
210
+ * system will generate InvalidArgument if asked to read at an
211
+ * offset that is not in the range [0,2^32-1], but it will generate
212
+ * OutOfRange if asked to read from an offset past the current
213
+ * file size.
214
+ *
215
+ * There is a fair bit of overlap between FailedPrecondition and
216
+ * OutOfRange. We recommend using OutOfRange (the more specific
217
+ * error) when it applies so that callers who are iterating through
218
+ * a space can easily look for an OutOfRange error to detect when
219
+ * they are done.
220
+ *
221
+ * This error code will not be generated by the gRPC framework.
222
+ */
223
+ ErrCode["OutOfRange"] = "out_of_range";
224
+ /**
225
+ * Unimplemented indicates operation is not implemented or not
226
+ * supported/enabled in this service.
227
+ *
228
+ * This error code will be generated by the gRPC framework. Most
229
+ * commonly, you will see this error code when a method implementation
230
+ * is missing on the server. It can also be generated for unknown
231
+ * compression algorithms or a disagreement as to whether an RPC should
232
+ * be streaming.
233
+ */
234
+ ErrCode["Unimplemented"] = "unimplemented";
235
+ /**
236
+ * Internal errors. Means some invariants expected by underlying
237
+ * system has been broken. If you see one of these errors,
238
+ * something is very broken.
239
+ *
240
+ * This error code will be generated by the gRPC framework in several
241
+ * internal error conditions.
242
+ */
243
+ ErrCode["Internal"] = "internal";
244
+ /**
245
+ * Unavailable indicates the service is currently unavailable.
246
+ * This is a most likely a transient condition and may be corrected
247
+ * by retrying with a backoff. Note that it is not always safe to retry
248
+ * non-idempotent operations.
249
+ *
250
+ * See litmus test above for deciding between FailedPrecondition,
251
+ * Aborted, and Unavailable.
252
+ *
253
+ * This error code will be generated by the gRPC framework during
254
+ * abrupt shutdown of a server process or network connection.
255
+ */
256
+ ErrCode["Unavailable"] = "unavailable";
257
+ /**
258
+ * DataLoss indicates unrecoverable data loss or corruption.
259
+ *
260
+ * This error code will not be generated by the gRPC framework.
261
+ */
262
+ ErrCode["DataLoss"] = "data_loss";
263
+ /**
264
+ * Unauthenticated indicates the request does not have valid
265
+ * authentication credentials for the operation.
266
+ *
267
+ * The gRPC framework will generate this error code when the
268
+ * authentication metadata is invalid or a Credentials callback fails,
269
+ * but also expect authentication middleware to generate it.
270
+ */
271
+ ErrCode["Unauthenticated"] = "unauthenticated";
272
+ })(ErrCode || (exports.ErrCode = ErrCode = {}));
273
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/error/index.ts"],"names":[],"mappings":";;;AAAA,MAAa,QAAS,SAAQ,KAAK;IAOjC,uDAAuD;IACvD,MAAM,CAAC,QAAQ,CAAC,GAAW,EAAE,KAAa;QACxC,OAAO,IAAI,QAAQ,CAAC,OAAO,CAAC,QAAQ,EAAE,GAAG,EAAE,KAAK,CAAC,CAAA;IACnD,CAAC;IAED,sDAAsD;IACtD,MAAM,CAAC,OAAO,CAAC,GAAW,EAAE,KAAa;QACvC,OAAO,IAAI,QAAQ,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,EAAE,KAAK,CAAC,CAAA;IAClD,CAAC;IAED,8DAA8D;IAC9D,MAAM,CAAC,eAAe,CAAC,GAAW,EAAE,KAAa;QAC/C,OAAO,IAAI,QAAQ,CAAC,OAAO,CAAC,eAAe,EAAE,GAAG,EAAE,KAAK,CAAC,CAAA;IAC1D,CAAC;IAED,+DAA+D;IAC/D,MAAM,CAAC,gBAAgB,CAAC,GAAW,EAAE,KAAa;QAChD,OAAO,IAAI,QAAQ,CAAC,OAAO,CAAC,gBAAgB,EAAE,GAAG,EAAE,KAAK,CAAC,CAAA;IAC3D,CAAC;IAED,uDAAuD;IACvD,MAAM,CAAC,QAAQ,CAAC,GAAW,EAAE,KAAa;QACxC,OAAO,IAAI,QAAQ,CAAC,OAAO,CAAC,QAAQ,EAAE,GAAG,EAAE,KAAK,CAAC,CAAA;IACnD,CAAC;IAED,4DAA4D;IAC5D,MAAM,CAAC,aAAa,CAAC,GAAW,EAAE,KAAa;QAC7C,OAAO,IAAI,QAAQ,CAAC,OAAO,CAAC,aAAa,EAAE,GAAG,EAAE,KAAK,CAAC,CAAA;IACxD,CAAC;IAED,+DAA+D;IAC/D,MAAM,CAAC,gBAAgB,CAAC,GAAW,EAAE,KAAa;QAChD,OAAO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;IACH,8BAAmB,CAAA;IAEnB;;;;;;;OAOG;IACH,+CAAoC,CAAA;IAEpC;;;;;;;;;OASG;IACH,iDAAsC,CAAA;IAEtC;;;;;OAKG;IACH,iCAAsB,CAAA;IAEtB;;;;;OAKG;IACH,2CAAgC,CAAA;IAEhC;;;;;;;;;;OAUG;IACH,iDAAsC,CAAA;IAEtC;;;;;;;OAOG;IACH,mDAAwC,CAAA;IAExC;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,qDAA0C,CAAA;IAE1C;;;;;;;OAOG;IACH,8BAAmB,CAAA;IAEnB;;;;;;;;;;;;;;;;;;OAkBG;IACH,sCAA2B,CAAA;IAE3B;;;;;;;;;OASG;IACH,0CAA+B,CAAA;IAE/B;;;;;;;OAOG;IACH,gCAAqB,CAAA;IAErB;;;;;;;;;;;OAWG;IACH,sCAA2B,CAAA;IAE3B;;;;OAIG;IACH,iCAAsB,CAAA;IAEtB;;;;;;;OAOG;IACH,8CAAmC,CAAA;AACrC,CAAC,EAjMW,OAAO,uBAAP,OAAO,QAiMlB"}
@@ -1,10 +1,12 @@
1
1
  import { EtoAppOutput, RegisterModuleJoinerConfig } from "@etohq/modules-sdk";
2
- import { CommonTypes, ILinkMigrationsPlanner, InternalModuleDeclaration, ModuleServiceInitializeOptions } from "@etohq/types";
3
- import { EtoContainer } from "./container";
2
+ import { CommonTypes, DefaultModulesDefinition, ILinkMigrationsPlanner, InternalModuleDeclaration, ModuleServiceInitializeOptions } from "@etohq/types";
4
3
  import type { Knex } from "@mikro-orm/knex";
5
- export declare class EtoAppLoader {
4
+ import { EtoContainer } from "./container";
5
+ export declare class EtoAppLoader<TKey extends string = string> {
6
6
  #private;
7
- constructor({ container, customLinksModules, }?: {
7
+ constructor({ modulesDefinition, linkModule, container, customLinksModules, }: {
8
+ modulesDefinition: DefaultModulesDefinition<TKey>;
9
+ linkModule: any;
8
10
  container?: EtoContainer;
9
11
  customLinksModules?: RegisterModuleJoinerConfig | RegisterModuleJoinerConfig[];
10
12
  });
@@ -1 +1 @@
1
- {"version":3,"file":"eto-app-loader.d.ts","sourceRoot":"","sources":["../src/eto-app-loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,YAAY,EAEZ,0BAA0B,EAC3B,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EACL,WAAW,EAEX,sBAAsB,EACtB,yBAAyB,EAGzB,8BAA8B,EAC/B,MAAM,cAAc,CAAA;AAYrB,OAAO,EAGL,YAAY,EACb,MAAM,aAAa,CAAA;AACpB,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAA;AAE3C,qBAAa,YAAY;;gBAkBX,EACV,SAAS,EACT,kBAAkB,GACnB,GAAE;QACD,SAAS,CAAC,EAAE,YAAY,CAAA;QACxB,kBAAkB,CAAC,EACf,0BAA0B,GAC1B,0BAA0B,EAAE,CAAA;KAC5B;IAKN,SAAS,CAAC,mBAAmB,CAC3B,aAAa,EAAE,WAAW,CAAC,YAAY,CAAC,SAAS,CAAC;;;IAsCpD,SAAS,CAAC,6BAA6B;;;;;;;IA6BvC;;;;;;OAMG;IACG,oBAAoB,CACxB,EACE,WAAW,EACX,MAAc,GACf,GACG;QACE,WAAW,CAAC,EAAE,KAAK,CAAA;QACnB,MAAM,EAAE,KAAK,CAAA;KACd,GACD;QACE,WAAW,EAAE,MAAM,EAAE,CAAA;QACrB,MAAM,EAAE,QAAQ,GAAG,UAAU,CAAA;KAGlC,GACA,OAAO,CAAC,IAAI,CAAC;IAuBhB;;OAEG;IACG,wBAAwB,IAAI,OAAO,CAAC,sBAAsB,CAAC;IAgBjE;;OAEG;IACG,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC;IAevC;;;OAGG;IACG,IAAI,CAAC,MAAM;;KAAgC,GAAG,OAAO,CAAC,YAAY,CAAC;CAqE1E"}
1
+ {"version":3,"file":"eto-app-loader.d.ts","sourceRoot":"","sources":["../src/eto-app-loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,YAAY,EACZ,0BAA0B,EAC3B,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EACL,WAAW,EAEX,wBAAwB,EACxB,sBAAsB,EACtB,yBAAyB,EAGzB,8BAA8B,EAC/B,MAAM,cAAc,CAAA;AAUrB,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAA;AAG3C,OAAO,EACL,YAAY,EAGb,MAAM,aAAa,CAAA;AAEpB,qBAAa,YAAY,CAAC,IAAI,SAAS,MAAM,GAAG,MAAM;;gBA6BxC,EACV,iBAAiB,EACjB,UAAU,EACV,SAAS,EACT,kBAAkB,GACnB,EAAE;QACD,iBAAiB,EAAE,wBAAwB,CAAC,IAAI,CAAC,CAAA;QACjD,UAAU,EAAE,GAAG,CAAA;QACf,SAAS,CAAC,EAAE,YAAY,CAAA;QACxB,kBAAkB,CAAC,EACf,0BAA0B,GAC1B,0BAA0B,EAAE,CAAA;KACjC;IAQD,SAAS,CAAC,mBAAmB,CAC3B,aAAa,EAAE,WAAW,CAAC,YAAY,CAAC,SAAS,CAAC;;;IAsEpD,SAAS,CAAC,6BAA6B;;;;;;;IA6BvC;;;;;;OAMG;IACG,oBAAoB,CACxB,EACE,WAAW,EACX,MAAc,GACf,GACG;QACE,WAAW,CAAC,EAAE,KAAK,CAAA;QACnB,MAAM,EAAE,KAAK,CAAA;KACd,GACD;QACE,WAAW,EAAE,MAAM,EAAE,CAAA;QACrB,MAAM,EAAE,QAAQ,GAAG,UAAU,CAAA;KAGlC,GACA,OAAO,CAAC,IAAI,CAAC;IAuBhB;;OAEG;IACG,wBAAwB,IAAI,OAAO,CAAC,sBAAsB,CAAC;IAgBjE;;OAEG;IACG,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC;IAevC;;;OAGG;IACG,IAAI,CAAC,MAAM;;KAAgC,GAAG,OAAO,CAAC,YAAY,CAAC;CAwE1E"}
@@ -10,7 +10,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
10
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
11
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
12
  };
13
- var _EtoAppLoader_container, _EtoAppLoader_customLinksModules;
13
+ var _EtoAppLoader_defaultModulesDefinition, _EtoAppLoader_container, _EtoAppLoader_linkModule, _EtoAppLoader_customLinksModules;
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.EtoAppLoader = void 0;
16
16
  const modules_sdk_1 = require("@etohq/modules-sdk");
@@ -22,35 +22,49 @@ class EtoAppLoader {
22
22
  // TODO: Adjust all loaders to accept an optional container such that in test env it is possible if needed to provide a specific container otherwise use the main container
23
23
  // Maybe also adjust the different places to resolve the config from the container instead of the configManager for the same reason
24
24
  // To be discussed
25
- constructor({ container, customLinksModules, } = {}) {
25
+ constructor({ modulesDefinition, linkModule, container, customLinksModules, }) {
26
+ /**
27
+ * Default module override eto base default.
28
+ * @private
29
+ */
30
+ _EtoAppLoader_defaultModulesDefinition.set(this, void 0);
26
31
  /**
27
32
  * Container from where to resolve resources
28
33
  * @private
29
34
  */
30
35
  _EtoAppLoader_container.set(this, void 0);
36
+ /**
37
+ * link module.
38
+ * @private
39
+ */
40
+ _EtoAppLoader_linkModule.set(this, void 0); // todo fix type.
31
41
  /**
32
42
  * Extra links modules config which should be added manually to the links to be loaded
33
43
  * @private
34
44
  */
35
45
  _EtoAppLoader_customLinksModules.set(this, void 0);
46
+ __classPrivateFieldSet(this, _EtoAppLoader_defaultModulesDefinition, modulesDefinition, "f");
36
47
  __classPrivateFieldSet(this, _EtoAppLoader_container, container ?? container_1.container, "f");
48
+ __classPrivateFieldSet(this, _EtoAppLoader_linkModule, linkModule, "f");
37
49
  __classPrivateFieldSet(this, _EtoAppLoader_customLinksModules, customLinksModules ?? [], "f");
38
50
  }
51
+ // todo this should move up to generateModulesDefinition so modules from it will be used directly...
39
52
  mergeDefaultModules(modulesConfig) {
40
- const defaultModules = Object.values(modules_sdk_1.ModulesDefinition).filter((definition) => {
53
+ const filteredDefaultModules = Object.values(__classPrivateFieldGet(this, _EtoAppLoader_defaultModulesDefinition, "f")).filter((definition) => {
41
54
  return !!definition.defaultPackage;
42
55
  });
43
56
  const configModules = { ...modulesConfig };
44
- for (const defaultModule of defaultModules) {
57
+ for (const defaultModule of filteredDefaultModules) {
45
58
  configModules[defaultModule.key] ??=
46
59
  defaultModule.defaultModuleDeclaration;
47
60
  }
48
61
  for (const [key, value] of Object.entries(configModules)) {
49
62
  const def = {};
50
63
  def.key ??= key;
51
- def.label ??= modules_sdk_1.ModulesDefinition[key]?.label ?? (0, utils_1.upperCaseFirst)(key);
52
- def.isQueryable = modules_sdk_1.ModulesDefinition[key]?.isQueryable ?? true;
53
- const orignalDef = value?.definition ?? modules_sdk_1.ModulesDefinition[key];
64
+ def.label ??=
65
+ __classPrivateFieldGet(this, _EtoAppLoader_defaultModulesDefinition, "f")[key]?.label ?? (0, utils_1.upperCaseFirst)(key);
66
+ def.isQueryable = __classPrivateFieldGet(this, _EtoAppLoader_defaultModulesDefinition, "f")[key]?.isQueryable ?? true;
67
+ const orignalDef = value?.definition ?? __classPrivateFieldGet(this, _EtoAppLoader_defaultModulesDefinition, "f")[key];
54
68
  if (!(0, utils_1.isBoolean)(value) &&
55
69
  ((0, utils_1.isObject)(orignalDef) || !(0, utils_1.isPresent)(value.definition))) {
56
70
  value.definition = {
@@ -58,6 +72,33 @@ class EtoAppLoader {
58
72
  ...orignalDef,
59
73
  };
60
74
  }
75
+ // base from loader
76
+ // {
77
+ // scope: 'internal',
78
+ // resolve: { default: [Getter], discoveryPath: [Getter], __esModule: [Getter] },
79
+ // definition: {
80
+ // key: 'inventory',
81
+ // label: 'Inventory',
82
+ // isQueryable: true,
83
+ // dependencies: [ 'event_bus' ]
84
+ // }
85
+ // }
86
+ // imported from builder ()
87
+ // {
88
+ // resolve: { default: [Getter], discoveryPath: [Getter], __esModule: [Getter] },
89
+ // options: { providers: [ [Object] ] },
90
+ // definition: {
91
+ // key: 'auth',
92
+ // label: 'Auth',
93
+ // isQueryable: true,
94
+ // defaultPackage: '/Users/solarsoft0/workspace/obigtech/shopabox/shopabox-platform-api/ts/node_modules/@etohq/auth/dist/index.js',
95
+ // dependencies: [ 'cache', 'logger' ],
96
+ // defaultModuleDeclaration: { scope: 'internal', resolve: [Object] },
97
+ // isRequired: true
98
+ // }
99
+ // }
100
+ // todo normalize
101
+ // console.log(value, "from ETOAPPLOADER")
61
102
  }
62
103
  return configModules;
63
104
  }
@@ -147,9 +188,10 @@ class EtoAppLoader {
147
188
  __classPrivateFieldGet(this, _EtoAppLoader_container, "f").register(utils_1.ContainerRegistrationKeys.REMOTE_QUERY, (0, awilix_1.asValue)(undefined));
148
189
  __classPrivateFieldGet(this, _EtoAppLoader_container, "f").register(utils_1.ContainerRegistrationKeys.QUERY, (0, awilix_1.asValue)(undefined));
149
190
  __classPrivateFieldGet(this, _EtoAppLoader_container, "f").register(utils_1.ContainerRegistrationKeys.LINK, (0, awilix_1.asValue)(undefined));
150
- __classPrivateFieldGet(this, _EtoAppLoader_container, "f").register(utils_1.ContainerRegistrationKeys.REMOTE_LINK, (0, awilix_1.aliasTo)(utils_1.ContainerRegistrationKeys.LINK));
191
+ __classPrivateFieldGet(this, _EtoAppLoader_container, "f").register(utils_1.ContainerRegistrationKeys.LINK, (0, awilix_1.aliasTo)(utils_1.ContainerRegistrationKeys.LINK));
151
192
  const configModules = this.mergeDefaultModules(configModule.modules);
152
193
  const etoApp = await (0, modules_sdk_1.EtoApp)({
194
+ linkModule: __classPrivateFieldGet(this, _EtoAppLoader_linkModule, "f"),
153
195
  workerMode: configModule.projectConfig.workerMode,
154
196
  modulesConfig: configModules,
155
197
  sharedContainer: __classPrivateFieldGet(this, _EtoAppLoader_container, "f"),
@@ -161,7 +203,7 @@ class EtoAppLoader {
161
203
  return etoApp;
162
204
  }
163
205
  __classPrivateFieldGet(this, _EtoAppLoader_container, "f").register(utils_1.ContainerRegistrationKeys.LINK, (0, awilix_1.asValue)(etoApp.link));
164
- __classPrivateFieldGet(this, _EtoAppLoader_container, "f").register(utils_1.ContainerRegistrationKeys.REMOTE_LINK, (0, awilix_1.aliasTo)(utils_1.ContainerRegistrationKeys.LINK));
206
+ __classPrivateFieldGet(this, _EtoAppLoader_container, "f").register(utils_1.ContainerRegistrationKeys.LINK, (0, awilix_1.aliasTo)(utils_1.ContainerRegistrationKeys.LINK));
165
207
  __classPrivateFieldGet(this, _EtoAppLoader_container, "f").register(utils_1.ContainerRegistrationKeys.REMOTE_QUERY, (0, awilix_1.asValue)(etoApp.query));
166
208
  __classPrivateFieldGet(this, _EtoAppLoader_container, "f").register(utils_1.ContainerRegistrationKeys.QUERY, (0, awilix_1.asValue)(etoApp.query));
167
209
  for (const moduleService of Object.values(etoApp.modules)) {
@@ -170,7 +212,7 @@ class EtoAppLoader {
170
212
  }
171
213
  // Register all unresolved modules as undefined to be present in the container with undefined value by default
172
214
  // but still resolvable
173
- for (const moduleDefinition of Object.values(modules_sdk_1.ModulesDefinition)) {
215
+ for (const moduleDefinition of Object.values(__classPrivateFieldGet(this, _EtoAppLoader_defaultModulesDefinition, "f"))) {
174
216
  if (!container_1.container.hasRegistration(moduleDefinition.key)) {
175
217
  container_1.container.register(moduleDefinition.key, (0, awilix_1.asValue)(undefined));
176
218
  }
@@ -179,5 +221,5 @@ class EtoAppLoader {
179
221
  }
180
222
  }
181
223
  exports.EtoAppLoader = EtoAppLoader;
182
- _EtoAppLoader_container = new WeakMap(), _EtoAppLoader_customLinksModules = new WeakMap();
224
+ _EtoAppLoader_defaultModulesDefinition = new WeakMap(), _EtoAppLoader_container = new WeakMap(), _EtoAppLoader_linkModule = new WeakMap(), _EtoAppLoader_customLinksModules = new WeakMap();
183
225
  //# sourceMappingURL=eto-app-loader.js.map