Skip to content

Commit

Permalink
regression: Fix issue where marketplace would not fetch the apps (Roc…
Browse files Browse the repository at this point in the history
  • Loading branch information
Gustrb authored Feb 20, 2025
1 parent 282b2bf commit bec532a
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 28 deletions.
10 changes: 10 additions & 0 deletions apps/meteor/ee/server/apps/communication/rest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,11 @@ export class AppsRestApi {
return API.v1.failure({ error: err.message });
}

if (err instanceof ZodError) {
orchestrator.getRocketChatLogger().error('Error parsing the Marketplace Apps:', err.issues);
return API.v1.failure({ error: i18n.t('Marketplace_Failed_To_Fetch_Apps') });
}

return API.v1.internalError();
}
},
Expand Down Expand Up @@ -228,6 +233,11 @@ export class AppsRestApi {
return API.v1.failure({ error: e.message });
}

if (e instanceof ZodError) {
orchestrator.getRocketChatLogger().error('Error parsing the Marketplace Apps:', e.issues);
return API.v1.failure({ error: i18n.t('Marketplace_Failed_To_Fetch_Apps') });
}

return API.v1.internalError();
}
}
Expand Down
58 changes: 30 additions & 28 deletions apps/meteor/ee/server/apps/marketplace/fetchMarketplaceApps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ type FetchMarketplaceAppsParams = {
};

const markdownObject = z.object({
raw: z.string(),
rendered: z.string(),
raw: z.string().optional(),
rendered: z.string().optional(),
});

const fetchMarketplaceAppsSchema = z.array(
Expand Down Expand Up @@ -53,7 +53,7 @@ const fetchMarketplaceAppsSchema = z.array(
classFile: z.string(),
iconFile: z.string(),
iconFileData: z.string(),
status: z.enum(['submitted', 'author-rejected', 'author-approved', 'rejected', 'approved']),
status: z.enum(['submitted', 'author-rejected', 'author-approved', 'rejected', 'approved', 'published']),
reviewedNote: z.string().optional(),
rejectionNote: z.string().optional(),
changesNote: z.string().optional(),
Expand All @@ -66,20 +66,20 @@ const fetchMarketplaceAppsSchema = z.array(
addonId: z.string().optional(),
isEnterpriseOnly: z.boolean(),
isBundle: z.boolean(),
bundedAppIds: z.array(z.string()),
bundledAppsIn: z.array(z.string()).optional(),
bundledIn: z.array(
z.object({
bundleId: z.string(),
bundleName: z.string(),
addonTierId: z.string(),
addonTierId: z.string().optional(),
}),
),
isPurchased: z.boolean(),
isSubscribed: z.boolean(),
subscriptionInfo: z
.object({
typeOf: z.enum(['app', 'service']),
status: z.enum(['trialing', 'active', 'cancelled', 'cancelling', 'pastDue']),
typeOf: z.enum(['app', 'service', '']),
status: z.enum(['trialing', 'active', 'cancelled', 'cancelling', 'pastDue', '']),
statusFromBilling: z.boolean(),
isSeatBased: z.boolean(),
seats: z.number(),
Expand All @@ -98,27 +98,29 @@ const fetchMarketplaceAppsSchema = z.array(
.optional(),
price: z.number(),
purchaseType: z.enum(['', 'buy', 'subscription']),
pricingPlans: z.array(
z.object({
id: z.string(),
enabled: z.boolean(),
price: z.number(),
trialDays: z.number(),
strategy: z.enum(['once', 'monthly', 'yearly']),
isPerSeat: z.boolean(),
tiers: z
.array(
z.object({
perUnit: z.boolean(),
minimum: z.number(),
maximum: z.number(),
price: z.number(),
refId: z.string().optional(),
}),
)
.optional(),
}),
),
pricingPlans: z
.array(
z.object({
id: z.string(),
enabled: z.boolean(),
price: z.number(),
trialDays: z.number(),
strategy: z.enum(['once', 'monthly', 'yearly']),
isPerSeat: z.boolean(),
tiers: z
.array(
z.object({
perUnit: z.boolean(),
minimum: z.number(),
maximum: z.number(),
price: z.number(),
refId: z.string().optional(),
}),
)
.optional(),
}),
)
.optional(),
isUsageBased: z.boolean().optional(),
requestedEndUser: z.boolean().optional(),
requested: z.boolean().optional(),
Expand Down

0 comments on commit bec532a

Please sign in to comment.