fix: update / create feature with empty ID / name

This commit is contained in:
John Yeo
2025-11-22 13:29:47 +00:00
parent 304a0ec258
commit f6ed67b723
4 changed files with 16 additions and 4 deletions

View File

@@ -12,6 +12,7 @@ export const ADMIN_USER_IDs = [
"user_2tMgAiPsQzX8JTHjZZh9m0VdvUv", // a
"user_2sB3tBXsnVVLlTKliQIqvvM2xfB", // j
"ZsDswIXyOGMP9y1V1At4dAZNaiggClSs", // t
"NqNuL3MtS7MR2WYoqx2b28iY9vmfAs8h", // c
];
// process.env.ENV === "production" || process.env.NODE_ENV === "production"
// ? [

View File

@@ -71,5 +71,12 @@ describe(`${chalk.yellowBright("temp: Testing add ons")}`, () => {
customer_id: customerId,
product_id: oneOff.id,
});
await autumn.attach({
customer_id: customerId,
product_id: oneOff.id,
});
const customer = await autumn.customers.get(customerId);
console.log("Customer:", customer);
});
});

View File

@@ -19,8 +19,12 @@ const featureDescriptions = {
// Create Feature Params
export const CreateFeatureV1ParamsSchema = z
.object({
id: z.string().meta({ description: featureDescriptions.id }),
name: z.string().nullish().meta({ description: featureDescriptions.name }),
id: z.string().nonempty().meta({ description: featureDescriptions.id }),
name: z
.string()
.nonempty()
.nullish()
.meta({ description: featureDescriptions.name }),
type: z.enum(FeatureType).meta({ description: featureDescriptions.type }),
consumable: z.boolean().optional(),

View File

@@ -53,8 +53,8 @@ function UpdateFeatureSheet({
try {
await FeatureService.updateFeature(axiosInstance, selectedFeature.id, {
...feature,
id: feature.id,
name: feature.name,
id: feature.id || undefined,
name: feature.name || undefined,
type: feature.type,
consumable: feature.config?.usage_type === FeatureUsageType.Single,
event_names: feature.event_names,