@opengeni/config 3.2.1 → 3.2.2
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/claude-subscription-capacity.d.ts +9 -0
- package/dist/claude-subscription-usage.d.ts +4 -2
- package/dist/credit-promotions.d.ts +25 -0
- package/dist/index.d.ts +1546 -65
- package/dist/index.js +3490 -644
- package/dist/index.js.map +1 -1
- package/dist/realtime-voice-pricing.d.ts +30 -0
- package/dist/subscription-account-selection.d.ts +17 -0
- package/dist/web-search.d.ts +177 -0
- package/package.json +5 -5
- package/src/claude-subscription-capacity.ts +129 -0
- package/src/claude-subscription-usage.ts +225 -5
- package/src/credit-promotions.ts +68 -0
- package/src/index.ts +3373 -203
- package/src/realtime-voice-pricing.ts +87 -0
- package/src/subscription-account-selection.ts +36 -0
- package/src/web-search.ts +606 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { PromotionalCreditScope } from "@opengeni/contracts";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
|
|
4
|
+
const ModelIds = PromotionalCreditScope.shape.eligibleModelIds.transform((ids) => [
|
|
5
|
+
...new Set(ids),
|
|
6
|
+
]);
|
|
7
|
+
|
|
8
|
+
/** Operator configuration only. Keys are Stripe coupon IDs, never customer account IDs. */
|
|
9
|
+
export const CreditPromotionPolicy = z
|
|
10
|
+
.object({
|
|
11
|
+
defaultModelIds: ModelIds.optional(),
|
|
12
|
+
signupModelIds: ModelIds.optional(),
|
|
13
|
+
offers: z
|
|
14
|
+
.record(
|
|
15
|
+
z.string().min(1),
|
|
16
|
+
z
|
|
17
|
+
.object({
|
|
18
|
+
label: PromotionalCreditScope.shape.label,
|
|
19
|
+
eligibleModelIds: ModelIds.optional(),
|
|
20
|
+
})
|
|
21
|
+
.strict(),
|
|
22
|
+
)
|
|
23
|
+
.default({}),
|
|
24
|
+
})
|
|
25
|
+
.strict()
|
|
26
|
+
.superRefine((policy, ctx) => {
|
|
27
|
+
for (const [id, offer] of Object.entries(policy.offers)) {
|
|
28
|
+
if (!offer.eligibleModelIds && !policy.defaultModelIds) {
|
|
29
|
+
ctx.addIssue({
|
|
30
|
+
code: "custom",
|
|
31
|
+
path: ["offers", id],
|
|
32
|
+
message: "Offer requires eligibleModelIds or defaultModelIds",
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
export const EnvCreditPromotionPolicy = z.preprocess(
|
|
39
|
+
(value) => {
|
|
40
|
+
if (typeof value !== "string") return value;
|
|
41
|
+
try {
|
|
42
|
+
return JSON.parse(value);
|
|
43
|
+
} catch {
|
|
44
|
+
return value;
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
CreditPromotionPolicy.default({ offers: {} }),
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
export function signupCreditModelIds(settings: {
|
|
51
|
+
creditPromotionPolicy: z.infer<typeof CreditPromotionPolicy>;
|
|
52
|
+
}) {
|
|
53
|
+
return (
|
|
54
|
+
settings.creditPromotionPolicy.signupModelIds ?? settings.creditPromotionPolicy.defaultModelIds
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function promotionalCreditScope(
|
|
59
|
+
settings: { creditPromotionPolicy: z.infer<typeof CreditPromotionPolicy> },
|
|
60
|
+
couponId: string,
|
|
61
|
+
): PromotionalCreditScope | undefined {
|
|
62
|
+
const policy = settings.creditPromotionPolicy;
|
|
63
|
+
const offer = policy.offers[couponId];
|
|
64
|
+
const eligibleModelIds = offer?.eligibleModelIds ?? policy.defaultModelIds;
|
|
65
|
+
return eligibleModelIds
|
|
66
|
+
? { label: offer?.label ?? "Promotional credits", eligibleModelIds }
|
|
67
|
+
: undefined;
|
|
68
|
+
}
|