@symbo.ls/sdk 2.33.37 → 2.33.39
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/dist/cjs/services/PlanService.js +85 -29
- package/dist/esm/index.js +85 -29
- package/dist/esm/services/PlanService.js +85 -29
- package/dist/esm/services/index.js +85 -29
- package/dist/node/services/PlanService.js +85 -29
- package/package.json +8 -8
- package/src/services/PlanService.js +93 -31
- package/src/services/tests/PlanService/createPlanWithValidation.test.js +57 -0
|
@@ -54,7 +54,9 @@ class PlanService extends import_BaseService.BaseService {
|
|
|
54
54
|
}
|
|
55
55
|
throw new Error(response.message);
|
|
56
56
|
} catch (error) {
|
|
57
|
-
throw new Error(`Failed to get plans with pricing: ${error.message}`, {
|
|
57
|
+
throw new Error(`Failed to get plans with pricing: ${error.message}`, {
|
|
58
|
+
cause: error
|
|
59
|
+
});
|
|
58
60
|
}
|
|
59
61
|
}
|
|
60
62
|
/**
|
|
@@ -93,7 +95,9 @@ class PlanService extends import_BaseService.BaseService {
|
|
|
93
95
|
}
|
|
94
96
|
throw new Error(response.message);
|
|
95
97
|
} catch (error) {
|
|
96
|
-
throw new Error(`Failed to get admin plans: ${error.message}`, {
|
|
98
|
+
throw new Error(`Failed to get admin plans: ${error.message}`, {
|
|
99
|
+
cause: error
|
|
100
|
+
});
|
|
97
101
|
}
|
|
98
102
|
}
|
|
99
103
|
/**
|
|
@@ -115,7 +119,9 @@ class PlanService extends import_BaseService.BaseService {
|
|
|
115
119
|
}
|
|
116
120
|
throw new Error(response.message);
|
|
117
121
|
} catch (error) {
|
|
118
|
-
throw new Error(`Failed to create plan: ${error.message}`, {
|
|
122
|
+
throw new Error(`Failed to create plan: ${error.message}`, {
|
|
123
|
+
cause: error
|
|
124
|
+
});
|
|
119
125
|
}
|
|
120
126
|
}
|
|
121
127
|
/**
|
|
@@ -140,7 +146,9 @@ class PlanService extends import_BaseService.BaseService {
|
|
|
140
146
|
}
|
|
141
147
|
throw new Error(response.message);
|
|
142
148
|
} catch (error) {
|
|
143
|
-
throw new Error(`Failed to update plan: ${error.message}`, {
|
|
149
|
+
throw new Error(`Failed to update plan: ${error.message}`, {
|
|
150
|
+
cause: error
|
|
151
|
+
});
|
|
144
152
|
}
|
|
145
153
|
}
|
|
146
154
|
/**
|
|
@@ -161,7 +169,9 @@ class PlanService extends import_BaseService.BaseService {
|
|
|
161
169
|
}
|
|
162
170
|
throw new Error(response.message);
|
|
163
171
|
} catch (error) {
|
|
164
|
-
throw new Error(`Failed to delete plan: ${error.message}`, {
|
|
172
|
+
throw new Error(`Failed to delete plan: ${error.message}`, {
|
|
173
|
+
cause: error
|
|
174
|
+
});
|
|
165
175
|
}
|
|
166
176
|
}
|
|
167
177
|
/**
|
|
@@ -179,7 +189,9 @@ class PlanService extends import_BaseService.BaseService {
|
|
|
179
189
|
}
|
|
180
190
|
throw new Error(response.message);
|
|
181
191
|
} catch (error) {
|
|
182
|
-
throw new Error(`Failed to initialize plans: ${error.message}`, {
|
|
192
|
+
throw new Error(`Failed to initialize plans: ${error.message}`, {
|
|
193
|
+
cause: error
|
|
194
|
+
});
|
|
183
195
|
}
|
|
184
196
|
}
|
|
185
197
|
// ==================== PLAN HELPER METHODS ====================
|
|
@@ -194,7 +206,9 @@ class PlanService extends import_BaseService.BaseService {
|
|
|
194
206
|
}
|
|
195
207
|
return plans;
|
|
196
208
|
} catch (error) {
|
|
197
|
-
throw new Error(`Failed to get plans with validation: ${error.message}`, {
|
|
209
|
+
throw new Error(`Failed to get plans with validation: ${error.message}`, {
|
|
210
|
+
cause: error
|
|
211
|
+
});
|
|
198
212
|
}
|
|
199
213
|
}
|
|
200
214
|
/**
|
|
@@ -211,7 +225,9 @@ class PlanService extends import_BaseService.BaseService {
|
|
|
211
225
|
}
|
|
212
226
|
return plan;
|
|
213
227
|
} catch (error) {
|
|
214
|
-
throw new Error(`Failed to get plan with validation: ${error.message}`, {
|
|
228
|
+
throw new Error(`Failed to get plan with validation: ${error.message}`, {
|
|
229
|
+
cause: error
|
|
230
|
+
});
|
|
215
231
|
}
|
|
216
232
|
}
|
|
217
233
|
/**
|
|
@@ -228,11 +244,15 @@ class PlanService extends import_BaseService.BaseService {
|
|
|
228
244
|
}
|
|
229
245
|
}
|
|
230
246
|
if (Object.hasOwn(planData, "price")) {
|
|
231
|
-
throw new Error(
|
|
247
|
+
throw new Error(
|
|
248
|
+
'Field "price" is no longer supported. Use unified "pricingOptions" with "amount" instead.'
|
|
249
|
+
);
|
|
232
250
|
}
|
|
233
251
|
if (planData.pricingOptions != null) {
|
|
234
252
|
if (!Array.isArray(planData.pricingOptions) || planData.pricingOptions.length === 0) {
|
|
235
|
-
throw new Error(
|
|
253
|
+
throw new Error(
|
|
254
|
+
"pricingOptions must be a non-empty array when provided"
|
|
255
|
+
);
|
|
236
256
|
}
|
|
237
257
|
const allowedIntervals = /* @__PURE__ */ new Set(["month", "year", "week", "day", null]);
|
|
238
258
|
planData.pricingOptions.forEach((option, index) => {
|
|
@@ -241,29 +261,41 @@ class PlanService extends import_BaseService.BaseService {
|
|
|
241
261
|
}
|
|
242
262
|
const { key, displayName, amount, interval, lookupKey } = option;
|
|
243
263
|
if (!key || typeof key !== "string") {
|
|
244
|
-
throw new Error(
|
|
264
|
+
throw new Error(
|
|
265
|
+
`Pricing option at index ${index} is missing required field 'key'`
|
|
266
|
+
);
|
|
245
267
|
}
|
|
246
268
|
if (!/^[a-z0-9-]+$/u.test(key)) {
|
|
247
|
-
throw new Error(
|
|
269
|
+
throw new Error(
|
|
270
|
+
`Pricing option key '${key}' must contain only lowercase letters, numbers, and hyphens`
|
|
271
|
+
);
|
|
248
272
|
}
|
|
249
273
|
if (!displayName || typeof displayName !== "string") {
|
|
250
|
-
throw new Error(
|
|
274
|
+
throw new Error(
|
|
275
|
+
`Pricing option '${key}' is missing required field 'displayName'`
|
|
276
|
+
);
|
|
251
277
|
}
|
|
252
278
|
if (typeof amount !== "number" || amount < 0) {
|
|
253
|
-
throw new Error(
|
|
279
|
+
throw new Error(
|
|
280
|
+
`Pricing option '${key}' must have a non-negative numeric 'amount'`
|
|
281
|
+
);
|
|
254
282
|
}
|
|
255
|
-
if (interval
|
|
283
|
+
if (interval !== null && !allowedIntervals.has(interval)) {
|
|
256
284
|
throw new Error(
|
|
257
285
|
`Pricing option '${key}' has invalid interval '${interval}'. Allowed: month, year, week, day or null`
|
|
258
286
|
);
|
|
259
287
|
}
|
|
260
288
|
if (!lookupKey || typeof lookupKey !== "string") {
|
|
261
|
-
throw new Error(
|
|
289
|
+
throw new Error(
|
|
290
|
+
`Pricing option '${key}' is missing required field 'lookupKey'`
|
|
291
|
+
);
|
|
262
292
|
}
|
|
263
293
|
});
|
|
264
294
|
}
|
|
265
295
|
if (planData.key && !/^[a-z0-9-]+$/u.test(planData.key)) {
|
|
266
|
-
throw new Error(
|
|
296
|
+
throw new Error(
|
|
297
|
+
"Plan key must contain only lowercase letters, numbers, and hyphens"
|
|
298
|
+
);
|
|
267
299
|
}
|
|
268
300
|
return await this.createPlan(planData);
|
|
269
301
|
}
|
|
@@ -278,11 +310,15 @@ class PlanService extends import_BaseService.BaseService {
|
|
|
278
310
|
throw new Error("Plan data must be a valid object");
|
|
279
311
|
}
|
|
280
312
|
if (Object.hasOwn(planData, "price")) {
|
|
281
|
-
throw new Error(
|
|
313
|
+
throw new Error(
|
|
314
|
+
'Field "price" is no longer supported. Use unified "pricingOptions" with "amount" instead.'
|
|
315
|
+
);
|
|
282
316
|
}
|
|
283
317
|
if (planData.pricingOptions != null) {
|
|
284
318
|
if (!Array.isArray(planData.pricingOptions) || planData.pricingOptions.length === 0) {
|
|
285
|
-
throw new Error(
|
|
319
|
+
throw new Error(
|
|
320
|
+
"pricingOptions must be a non-empty array when provided"
|
|
321
|
+
);
|
|
286
322
|
}
|
|
287
323
|
const allowedIntervals = /* @__PURE__ */ new Set(["month", "year", "week", "day", null]);
|
|
288
324
|
planData.pricingOptions.forEach((option, index) => {
|
|
@@ -291,16 +327,24 @@ class PlanService extends import_BaseService.BaseService {
|
|
|
291
327
|
}
|
|
292
328
|
const { key, displayName, amount, interval, lookupKey } = option;
|
|
293
329
|
if (!key || typeof key !== "string") {
|
|
294
|
-
throw new Error(
|
|
330
|
+
throw new Error(
|
|
331
|
+
`Pricing option at index ${index} is missing required field 'key'`
|
|
332
|
+
);
|
|
295
333
|
}
|
|
296
334
|
if (!/^[a-z0-9-]+$/u.test(key)) {
|
|
297
|
-
throw new Error(
|
|
335
|
+
throw new Error(
|
|
336
|
+
`Pricing option key '${key}' must contain only lowercase letters, numbers, and hyphens`
|
|
337
|
+
);
|
|
298
338
|
}
|
|
299
339
|
if (!displayName || typeof displayName !== "string") {
|
|
300
|
-
throw new Error(
|
|
340
|
+
throw new Error(
|
|
341
|
+
`Pricing option '${key}' is missing required field 'displayName'`
|
|
342
|
+
);
|
|
301
343
|
}
|
|
302
344
|
if (typeof amount !== "number" || amount < 0) {
|
|
303
|
-
throw new Error(
|
|
345
|
+
throw new Error(
|
|
346
|
+
`Pricing option '${key}' must have a non-negative numeric 'amount'`
|
|
347
|
+
);
|
|
304
348
|
}
|
|
305
349
|
if (interval != null && !allowedIntervals.has(interval)) {
|
|
306
350
|
throw new Error(
|
|
@@ -308,12 +352,16 @@ class PlanService extends import_BaseService.BaseService {
|
|
|
308
352
|
);
|
|
309
353
|
}
|
|
310
354
|
if (!lookupKey || typeof lookupKey !== "string") {
|
|
311
|
-
throw new Error(
|
|
355
|
+
throw new Error(
|
|
356
|
+
`Pricing option '${key}' is missing required field 'lookupKey'`
|
|
357
|
+
);
|
|
312
358
|
}
|
|
313
359
|
});
|
|
314
360
|
}
|
|
315
361
|
if (planData.key && !/^[a-z0-9-]+$/u.test(planData.key)) {
|
|
316
|
-
throw new Error(
|
|
362
|
+
throw new Error(
|
|
363
|
+
"Plan key must contain only lowercase letters, numbers, and hyphens"
|
|
364
|
+
);
|
|
317
365
|
}
|
|
318
366
|
return await this.updatePlan(planId, planData);
|
|
319
367
|
}
|
|
@@ -323,9 +371,13 @@ class PlanService extends import_BaseService.BaseService {
|
|
|
323
371
|
async getActivePlans() {
|
|
324
372
|
try {
|
|
325
373
|
const plans = await this.getPlans();
|
|
326
|
-
return plans.filter(
|
|
374
|
+
return plans.filter(
|
|
375
|
+
(plan) => plan.status === "active" && plan.isVisible !== false
|
|
376
|
+
);
|
|
327
377
|
} catch (error) {
|
|
328
|
-
throw new Error(`Failed to get active plans: ${error.message}`, {
|
|
378
|
+
throw new Error(`Failed to get active plans: ${error.message}`, {
|
|
379
|
+
cause: error
|
|
380
|
+
});
|
|
329
381
|
}
|
|
330
382
|
}
|
|
331
383
|
/**
|
|
@@ -340,7 +392,9 @@ class PlanService extends import_BaseService.BaseService {
|
|
|
340
392
|
return price >= minPrice && price <= maxPrice;
|
|
341
393
|
});
|
|
342
394
|
} catch (error) {
|
|
343
|
-
throw new Error(`Failed to get plans by price range: ${error.message}`, {
|
|
395
|
+
throw new Error(`Failed to get plans by price range: ${error.message}`, {
|
|
396
|
+
cause: error
|
|
397
|
+
});
|
|
344
398
|
}
|
|
345
399
|
}
|
|
346
400
|
/**
|
|
@@ -358,7 +412,9 @@ class PlanService extends import_BaseService.BaseService {
|
|
|
358
412
|
}
|
|
359
413
|
return plan;
|
|
360
414
|
} catch (error) {
|
|
361
|
-
throw new Error(`Failed to get plan by key: ${error.message}`, {
|
|
415
|
+
throw new Error(`Failed to get plan by key: ${error.message}`, {
|
|
416
|
+
cause: error
|
|
417
|
+
});
|
|
362
418
|
}
|
|
363
419
|
}
|
|
364
420
|
}
|
package/dist/esm/index.js
CHANGED
|
@@ -45051,7 +45051,9 @@ var PlanService = class extends BaseService {
|
|
|
45051
45051
|
}
|
|
45052
45052
|
throw new Error(response.message);
|
|
45053
45053
|
} catch (error) {
|
|
45054
|
-
throw new Error(`Failed to get plans with pricing: ${error.message}`, {
|
|
45054
|
+
throw new Error(`Failed to get plans with pricing: ${error.message}`, {
|
|
45055
|
+
cause: error
|
|
45056
|
+
});
|
|
45055
45057
|
}
|
|
45056
45058
|
}
|
|
45057
45059
|
/**
|
|
@@ -45090,7 +45092,9 @@ var PlanService = class extends BaseService {
|
|
|
45090
45092
|
}
|
|
45091
45093
|
throw new Error(response.message);
|
|
45092
45094
|
} catch (error) {
|
|
45093
|
-
throw new Error(`Failed to get admin plans: ${error.message}`, {
|
|
45095
|
+
throw new Error(`Failed to get admin plans: ${error.message}`, {
|
|
45096
|
+
cause: error
|
|
45097
|
+
});
|
|
45094
45098
|
}
|
|
45095
45099
|
}
|
|
45096
45100
|
/**
|
|
@@ -45112,7 +45116,9 @@ var PlanService = class extends BaseService {
|
|
|
45112
45116
|
}
|
|
45113
45117
|
throw new Error(response.message);
|
|
45114
45118
|
} catch (error) {
|
|
45115
|
-
throw new Error(`Failed to create plan: ${error.message}`, {
|
|
45119
|
+
throw new Error(`Failed to create plan: ${error.message}`, {
|
|
45120
|
+
cause: error
|
|
45121
|
+
});
|
|
45116
45122
|
}
|
|
45117
45123
|
}
|
|
45118
45124
|
/**
|
|
@@ -45137,7 +45143,9 @@ var PlanService = class extends BaseService {
|
|
|
45137
45143
|
}
|
|
45138
45144
|
throw new Error(response.message);
|
|
45139
45145
|
} catch (error) {
|
|
45140
|
-
throw new Error(`Failed to update plan: ${error.message}`, {
|
|
45146
|
+
throw new Error(`Failed to update plan: ${error.message}`, {
|
|
45147
|
+
cause: error
|
|
45148
|
+
});
|
|
45141
45149
|
}
|
|
45142
45150
|
}
|
|
45143
45151
|
/**
|
|
@@ -45158,7 +45166,9 @@ var PlanService = class extends BaseService {
|
|
|
45158
45166
|
}
|
|
45159
45167
|
throw new Error(response.message);
|
|
45160
45168
|
} catch (error) {
|
|
45161
|
-
throw new Error(`Failed to delete plan: ${error.message}`, {
|
|
45169
|
+
throw new Error(`Failed to delete plan: ${error.message}`, {
|
|
45170
|
+
cause: error
|
|
45171
|
+
});
|
|
45162
45172
|
}
|
|
45163
45173
|
}
|
|
45164
45174
|
/**
|
|
@@ -45176,7 +45186,9 @@ var PlanService = class extends BaseService {
|
|
|
45176
45186
|
}
|
|
45177
45187
|
throw new Error(response.message);
|
|
45178
45188
|
} catch (error) {
|
|
45179
|
-
throw new Error(`Failed to initialize plans: ${error.message}`, {
|
|
45189
|
+
throw new Error(`Failed to initialize plans: ${error.message}`, {
|
|
45190
|
+
cause: error
|
|
45191
|
+
});
|
|
45180
45192
|
}
|
|
45181
45193
|
}
|
|
45182
45194
|
// ==================== PLAN HELPER METHODS ====================
|
|
@@ -45191,7 +45203,9 @@ var PlanService = class extends BaseService {
|
|
|
45191
45203
|
}
|
|
45192
45204
|
return plans;
|
|
45193
45205
|
} catch (error) {
|
|
45194
|
-
throw new Error(`Failed to get plans with validation: ${error.message}`, {
|
|
45206
|
+
throw new Error(`Failed to get plans with validation: ${error.message}`, {
|
|
45207
|
+
cause: error
|
|
45208
|
+
});
|
|
45195
45209
|
}
|
|
45196
45210
|
}
|
|
45197
45211
|
/**
|
|
@@ -45208,7 +45222,9 @@ var PlanService = class extends BaseService {
|
|
|
45208
45222
|
}
|
|
45209
45223
|
return plan;
|
|
45210
45224
|
} catch (error) {
|
|
45211
|
-
throw new Error(`Failed to get plan with validation: ${error.message}`, {
|
|
45225
|
+
throw new Error(`Failed to get plan with validation: ${error.message}`, {
|
|
45226
|
+
cause: error
|
|
45227
|
+
});
|
|
45212
45228
|
}
|
|
45213
45229
|
}
|
|
45214
45230
|
/**
|
|
@@ -45225,11 +45241,15 @@ var PlanService = class extends BaseService {
|
|
|
45225
45241
|
}
|
|
45226
45242
|
}
|
|
45227
45243
|
if (Object.hasOwn(planData, "price")) {
|
|
45228
|
-
throw new Error(
|
|
45244
|
+
throw new Error(
|
|
45245
|
+
'Field "price" is no longer supported. Use unified "pricingOptions" with "amount" instead.'
|
|
45246
|
+
);
|
|
45229
45247
|
}
|
|
45230
45248
|
if (planData.pricingOptions != null) {
|
|
45231
45249
|
if (!Array.isArray(planData.pricingOptions) || planData.pricingOptions.length === 0) {
|
|
45232
|
-
throw new Error(
|
|
45250
|
+
throw new Error(
|
|
45251
|
+
"pricingOptions must be a non-empty array when provided"
|
|
45252
|
+
);
|
|
45233
45253
|
}
|
|
45234
45254
|
const allowedIntervals = /* @__PURE__ */ new Set(["month", "year", "week", "day", null]);
|
|
45235
45255
|
planData.pricingOptions.forEach((option, index) => {
|
|
@@ -45238,29 +45258,41 @@ var PlanService = class extends BaseService {
|
|
|
45238
45258
|
}
|
|
45239
45259
|
const { key, displayName, amount, interval, lookupKey } = option;
|
|
45240
45260
|
if (!key || typeof key !== "string") {
|
|
45241
|
-
throw new Error(
|
|
45261
|
+
throw new Error(
|
|
45262
|
+
`Pricing option at index ${index} is missing required field 'key'`
|
|
45263
|
+
);
|
|
45242
45264
|
}
|
|
45243
45265
|
if (!/^[a-z0-9-]+$/u.test(key)) {
|
|
45244
|
-
throw new Error(
|
|
45266
|
+
throw new Error(
|
|
45267
|
+
`Pricing option key '${key}' must contain only lowercase letters, numbers, and hyphens`
|
|
45268
|
+
);
|
|
45245
45269
|
}
|
|
45246
45270
|
if (!displayName || typeof displayName !== "string") {
|
|
45247
|
-
throw new Error(
|
|
45271
|
+
throw new Error(
|
|
45272
|
+
`Pricing option '${key}' is missing required field 'displayName'`
|
|
45273
|
+
);
|
|
45248
45274
|
}
|
|
45249
45275
|
if (typeof amount !== "number" || amount < 0) {
|
|
45250
|
-
throw new Error(
|
|
45276
|
+
throw new Error(
|
|
45277
|
+
`Pricing option '${key}' must have a non-negative numeric 'amount'`
|
|
45278
|
+
);
|
|
45251
45279
|
}
|
|
45252
|
-
if (interval
|
|
45280
|
+
if (interval !== null && !allowedIntervals.has(interval)) {
|
|
45253
45281
|
throw new Error(
|
|
45254
45282
|
`Pricing option '${key}' has invalid interval '${interval}'. Allowed: month, year, week, day or null`
|
|
45255
45283
|
);
|
|
45256
45284
|
}
|
|
45257
45285
|
if (!lookupKey || typeof lookupKey !== "string") {
|
|
45258
|
-
throw new Error(
|
|
45286
|
+
throw new Error(
|
|
45287
|
+
`Pricing option '${key}' is missing required field 'lookupKey'`
|
|
45288
|
+
);
|
|
45259
45289
|
}
|
|
45260
45290
|
});
|
|
45261
45291
|
}
|
|
45262
45292
|
if (planData.key && !/^[a-z0-9-]+$/u.test(planData.key)) {
|
|
45263
|
-
throw new Error(
|
|
45293
|
+
throw new Error(
|
|
45294
|
+
"Plan key must contain only lowercase letters, numbers, and hyphens"
|
|
45295
|
+
);
|
|
45264
45296
|
}
|
|
45265
45297
|
return await this.createPlan(planData);
|
|
45266
45298
|
}
|
|
@@ -45275,11 +45307,15 @@ var PlanService = class extends BaseService {
|
|
|
45275
45307
|
throw new Error("Plan data must be a valid object");
|
|
45276
45308
|
}
|
|
45277
45309
|
if (Object.hasOwn(planData, "price")) {
|
|
45278
|
-
throw new Error(
|
|
45310
|
+
throw new Error(
|
|
45311
|
+
'Field "price" is no longer supported. Use unified "pricingOptions" with "amount" instead.'
|
|
45312
|
+
);
|
|
45279
45313
|
}
|
|
45280
45314
|
if (planData.pricingOptions != null) {
|
|
45281
45315
|
if (!Array.isArray(planData.pricingOptions) || planData.pricingOptions.length === 0) {
|
|
45282
|
-
throw new Error(
|
|
45316
|
+
throw new Error(
|
|
45317
|
+
"pricingOptions must be a non-empty array when provided"
|
|
45318
|
+
);
|
|
45283
45319
|
}
|
|
45284
45320
|
const allowedIntervals = /* @__PURE__ */ new Set(["month", "year", "week", "day", null]);
|
|
45285
45321
|
planData.pricingOptions.forEach((option, index) => {
|
|
@@ -45288,16 +45324,24 @@ var PlanService = class extends BaseService {
|
|
|
45288
45324
|
}
|
|
45289
45325
|
const { key, displayName, amount, interval, lookupKey } = option;
|
|
45290
45326
|
if (!key || typeof key !== "string") {
|
|
45291
|
-
throw new Error(
|
|
45327
|
+
throw new Error(
|
|
45328
|
+
`Pricing option at index ${index} is missing required field 'key'`
|
|
45329
|
+
);
|
|
45292
45330
|
}
|
|
45293
45331
|
if (!/^[a-z0-9-]+$/u.test(key)) {
|
|
45294
|
-
throw new Error(
|
|
45332
|
+
throw new Error(
|
|
45333
|
+
`Pricing option key '${key}' must contain only lowercase letters, numbers, and hyphens`
|
|
45334
|
+
);
|
|
45295
45335
|
}
|
|
45296
45336
|
if (!displayName || typeof displayName !== "string") {
|
|
45297
|
-
throw new Error(
|
|
45337
|
+
throw new Error(
|
|
45338
|
+
`Pricing option '${key}' is missing required field 'displayName'`
|
|
45339
|
+
);
|
|
45298
45340
|
}
|
|
45299
45341
|
if (typeof amount !== "number" || amount < 0) {
|
|
45300
|
-
throw new Error(
|
|
45342
|
+
throw new Error(
|
|
45343
|
+
`Pricing option '${key}' must have a non-negative numeric 'amount'`
|
|
45344
|
+
);
|
|
45301
45345
|
}
|
|
45302
45346
|
if (interval != null && !allowedIntervals.has(interval)) {
|
|
45303
45347
|
throw new Error(
|
|
@@ -45305,12 +45349,16 @@ var PlanService = class extends BaseService {
|
|
|
45305
45349
|
);
|
|
45306
45350
|
}
|
|
45307
45351
|
if (!lookupKey || typeof lookupKey !== "string") {
|
|
45308
|
-
throw new Error(
|
|
45352
|
+
throw new Error(
|
|
45353
|
+
`Pricing option '${key}' is missing required field 'lookupKey'`
|
|
45354
|
+
);
|
|
45309
45355
|
}
|
|
45310
45356
|
});
|
|
45311
45357
|
}
|
|
45312
45358
|
if (planData.key && !/^[a-z0-9-]+$/u.test(planData.key)) {
|
|
45313
|
-
throw new Error(
|
|
45359
|
+
throw new Error(
|
|
45360
|
+
"Plan key must contain only lowercase letters, numbers, and hyphens"
|
|
45361
|
+
);
|
|
45314
45362
|
}
|
|
45315
45363
|
return await this.updatePlan(planId, planData);
|
|
45316
45364
|
}
|
|
@@ -45320,9 +45368,13 @@ var PlanService = class extends BaseService {
|
|
|
45320
45368
|
async getActivePlans() {
|
|
45321
45369
|
try {
|
|
45322
45370
|
const plans = await this.getPlans();
|
|
45323
|
-
return plans.filter(
|
|
45371
|
+
return plans.filter(
|
|
45372
|
+
(plan) => plan.status === "active" && plan.isVisible !== false
|
|
45373
|
+
);
|
|
45324
45374
|
} catch (error) {
|
|
45325
|
-
throw new Error(`Failed to get active plans: ${error.message}`, {
|
|
45375
|
+
throw new Error(`Failed to get active plans: ${error.message}`, {
|
|
45376
|
+
cause: error
|
|
45377
|
+
});
|
|
45326
45378
|
}
|
|
45327
45379
|
}
|
|
45328
45380
|
/**
|
|
@@ -45337,7 +45389,9 @@ var PlanService = class extends BaseService {
|
|
|
45337
45389
|
return price >= minPrice && price <= maxPrice;
|
|
45338
45390
|
});
|
|
45339
45391
|
} catch (error) {
|
|
45340
|
-
throw new Error(`Failed to get plans by price range: ${error.message}`, {
|
|
45392
|
+
throw new Error(`Failed to get plans by price range: ${error.message}`, {
|
|
45393
|
+
cause: error
|
|
45394
|
+
});
|
|
45341
45395
|
}
|
|
45342
45396
|
}
|
|
45343
45397
|
/**
|
|
@@ -45355,7 +45409,9 @@ var PlanService = class extends BaseService {
|
|
|
45355
45409
|
}
|
|
45356
45410
|
return plan;
|
|
45357
45411
|
} catch (error) {
|
|
45358
|
-
throw new Error(`Failed to get plan by key: ${error.message}`, {
|
|
45412
|
+
throw new Error(`Failed to get plan by key: ${error.message}`, {
|
|
45413
|
+
cause: error
|
|
45414
|
+
});
|
|
45359
45415
|
}
|
|
45360
45416
|
}
|
|
45361
45417
|
};
|