@carrierllc/sdk 0.2.15 → 0.2.16

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.
@@ -14,6 +14,16 @@ export interface StorefrontBrandInput {
14
14
  tagline?: string;
15
15
  supportEmail?: string;
16
16
  legalName?: string;
17
+ address?: string;
18
+ locale?: "en" | "nl";
19
+ intro?: string;
20
+ ctaLabel?: string;
21
+ howHeading?: string;
22
+ plansHeading?: string;
23
+ buyLabel?: string;
24
+ emptyPlansText?: string;
25
+ searchHeading?: string;
26
+ searchPlaceholder?: string;
17
27
  }
18
28
  export interface StorefrontPlanInput {
19
29
  productId?: string;
@@ -32,6 +42,12 @@ export interface StorefrontPlanInput {
32
42
  active?: boolean;
33
43
  /** Display order on the storefront (ascending). Defaults to 0; ties fall back to slug. */
34
44
  sortOrder?: number;
45
+ /** Optional display section/group on the storefront. */
46
+ group?: string | null;
47
+ /** Optional ISO-8601 start timestamp from which the plan is visible. */
48
+ availableFrom?: string | null;
49
+ /** Optional ISO-8601 end timestamp until which the plan is visible. */
50
+ availableUntil?: string | null;
35
51
  /** Existing Stripe Price id (`price_…`), stored, not yet charged. Null clears the id and the mode. Set with stripePriceMode. */
36
52
  stripePriceId?: string | null;
37
53
  /** `test` or `live`. Null clears the id and the mode. Set with stripePriceId. */
@@ -56,6 +72,9 @@ export interface StorefrontPlanBody {
56
72
  description?: string;
57
73
  active?: boolean;
58
74
  sort_order?: number;
75
+ group?: string | null;
76
+ available_from?: string | null;
77
+ available_until?: string | null;
59
78
  stripe_price_id?: string | null;
60
79
  stripe_price_mode?: "test" | "live" | null;
61
80
  }
@@ -18,6 +18,16 @@ const COPY_FIELDS = [
18
18
  ["tagline", "tagline"],
19
19
  ["supportEmail", "supportEmail"],
20
20
  ["legalName", "legalName"],
21
+ ["address", "address"],
22
+ ["locale", "locale"],
23
+ ["intro", "intro"],
24
+ ["ctaLabel", "ctaLabel"],
25
+ ["howHeading", "howHeading"],
26
+ ["plansHeading", "plansHeading"],
27
+ ["buyLabel", "buyLabel"],
28
+ ["emptyPlansText", "emptyPlansText"],
29
+ ["searchHeading", "searchHeading"],
30
+ ["searchPlaceholder", "searchPlaceholder"],
21
31
  ];
22
32
  export function storefrontBrandPatch(input, existing) {
23
33
  const theme = overlay(existing?.theme, input, THEME_FIELDS);
@@ -45,6 +55,9 @@ export function completePlanInput(input, plans) {
45
55
  input.description,
46
56
  input.active,
47
57
  input.sortOrder,
58
+ input.group,
59
+ input.availableFrom,
60
+ input.availableUntil,
48
61
  input.stripePriceId,
49
62
  input.stripePriceMode,
50
63
  ].some((value) => value !== undefined);
@@ -79,6 +92,9 @@ export function storefrontPlanBody(input) {
79
92
  const stripe = stripePriceFields(input.stripePriceId, input.stripePriceMode);
80
93
  if (stripe && "error" in stripe)
81
94
  return stripe;
95
+ const windowFields = planWindowFields(input);
96
+ if (windowFields && "error" in windowFields)
97
+ return windowFields;
82
98
  const productId = input.productId?.trim() ?? "";
83
99
  if (productId !== "") {
84
100
  const body = { product_id: productId };
@@ -90,7 +106,7 @@ export function storefrontPlanBody(input) {
90
106
  body.active = input.active;
91
107
  if (input.sortOrder !== undefined)
92
108
  body.sort_order = input.sortOrder;
93
- return stripe ? { ...body, ...stripe } : body;
109
+ return { ...body, ...(windowFields ?? {}), ...(stripe ?? {}) };
94
110
  }
95
111
  const touched = [
96
112
  input.slug,
@@ -106,6 +122,9 @@ export function storefrontPlanBody(input) {
106
122
  input.description,
107
123
  input.active,
108
124
  input.sortOrder,
125
+ input.group,
126
+ input.availableFrom,
127
+ input.availableUntil,
109
128
  input.stripePriceId,
110
129
  input.stripePriceMode,
111
130
  ].some((value) => value !== undefined);
@@ -144,7 +163,45 @@ export function storefrontPlanBody(input) {
144
163
  body.active = input.active;
145
164
  if (input.sortOrder !== undefined)
146
165
  body.sort_order = input.sortOrder;
147
- return stripe ? { ...body, ...stripe } : body;
166
+ return { ...body, ...(windowFields ?? {}), ...(stripe ?? {}) };
167
+ }
168
+ function planWindowFields(input) {
169
+ const out = {};
170
+ let touched = false;
171
+ if (input.group !== undefined) {
172
+ out.group = input.group === null || input.group.trim() === "" ? null : input.group.trim().slice(0, 80);
173
+ touched = true;
174
+ }
175
+ if (input.availableFrom !== undefined) {
176
+ if (input.availableFrom === null || input.availableFrom.trim() === "") {
177
+ out.available_from = null;
178
+ }
179
+ else {
180
+ const ms = Date.parse(input.availableFrom.trim());
181
+ if (!Number.isFinite(ms))
182
+ return { error: "available_from must be an ISO-8601 date or timestamp." };
183
+ out.available_from = new Date(ms).toISOString();
184
+ }
185
+ touched = true;
186
+ }
187
+ if (input.availableUntil !== undefined) {
188
+ if (input.availableUntil === null || input.availableUntil.trim() === "") {
189
+ out.available_until = null;
190
+ }
191
+ else {
192
+ const trimmed = input.availableUntil.trim();
193
+ const expanded = /^\d{4}-\d{2}-\d{2}$/.test(trimmed) ? `${trimmed}T23:59:59.999Z` : trimmed;
194
+ const ms = Date.parse(expanded);
195
+ if (!Number.isFinite(ms))
196
+ return { error: "available_until must be an ISO-8601 date or timestamp." };
197
+ out.available_until = new Date(ms).toISOString();
198
+ }
199
+ touched = true;
200
+ }
201
+ if (out.available_from && out.available_until && Date.parse(out.available_from) > Date.parse(out.available_until)) {
202
+ return { error: "available_from must not be after available_until." };
203
+ }
204
+ return touched ? out : undefined;
148
205
  }
149
206
  /** Null clears both fields. A Price id and its mode are sent together. */
150
207
  function stripePriceFields(id, mode) {
package/dist/version.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  /** Published version. Keep this equal to package.json. */
2
- export declare const SDK_VERSION = "0.2.15";
3
- export declare const USER_AGENT = "@carrierllc/sdk/0.2.15";
2
+ export declare const SDK_VERSION = "0.2.16";
3
+ export declare const USER_AGENT = "@carrierllc/sdk/0.2.16";
package/dist/version.js CHANGED
@@ -1,3 +1,3 @@
1
1
  /** Published version. Keep this equal to package.json. */
2
- export const SDK_VERSION = "0.2.15";
2
+ export const SDK_VERSION = "0.2.16";
3
3
  export const USER_AGENT = `@carrierllc/sdk/${SDK_VERSION}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@carrierllc/sdk",
3
- "version": "0.2.15",
3
+ "version": "0.2.16",
4
4
  "description": "TypeScript client for the Carrier API, MCP server, and CLI.",
5
5
  "license": "MIT",
6
6
  "type": "module",