@decocms/start 1.6.0 → 1.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/sdk/setupApps.ts +16 -7
package/package.json
CHANGED
package/src/sdk/setupApps.ts
CHANGED
|
@@ -209,19 +209,28 @@ export async function setupApps(
|
|
|
209
209
|
registerAppCommerceHandlers(appWithHandlers.handlers);
|
|
210
210
|
}
|
|
211
211
|
|
|
212
|
-
// 2. Flatten manifest modules → individual invoke handlers
|
|
213
|
-
//
|
|
214
|
-
//
|
|
212
|
+
// 2. Flatten manifest modules → individual invoke handlers.
|
|
213
|
+
//
|
|
214
|
+
// Convention (mirrors legacy deco-cx/apps):
|
|
215
|
+
// - `default` export is registered at the moduleKey itself.
|
|
216
|
+
// shopify/loaders/ProductList.ts (default) → key "shopify/loaders/ProductList"
|
|
217
|
+
// - Named function exports are registered at `${moduleKey}/${fnName}`.
|
|
218
|
+
// vtex/actions/checkout.ts ({ getOrCreateCart, addItemsToCart })
|
|
219
|
+
// → keys "vtex/actions/checkout/getOrCreateCart", ".../addItemsToCart"
|
|
220
|
+
// - Each key also gets a `.ts` sibling for callers that include the
|
|
221
|
+
// extension (admin invoke path, some __resolveType producers).
|
|
215
222
|
for (const category of ["loaders", "actions"] as const) {
|
|
216
223
|
const modules = app.manifest[category];
|
|
217
224
|
if (!modules) continue;
|
|
218
225
|
|
|
219
226
|
for (const [moduleKey, moduleExports] of Object.entries(modules)) {
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
)) {
|
|
227
|
+
const exports = moduleExports as Record<string, unknown>;
|
|
228
|
+
|
|
229
|
+
for (const [fnName, fn] of Object.entries(exports)) {
|
|
223
230
|
if (typeof fn !== "function") continue;
|
|
224
|
-
const key =
|
|
231
|
+
const key = fnName === "default"
|
|
232
|
+
? moduleKey
|
|
233
|
+
: `${moduleKey}/${fnName}`;
|
|
225
234
|
const handler = (props: any, req: Request) =>
|
|
226
235
|
(fn as Function)(props, req);
|
|
227
236
|
registerInvokeHandlers({
|