@amerged/ohmyhost-sdk 0.1.39 → 0.1.41

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amerged/ohmyhost-sdk",
3
- "version": "0.1.39",
3
+ "version": "0.1.41",
4
4
  "type": "module",
5
5
  "engines": {
6
6
  "node": ">=22"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ohmyhost/sdk-ts",
3
- "version": "0.1.39",
3
+ "version": "0.1.41",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "exports": {
@@ -1930,7 +1930,7 @@ export const createOrganization = <ThrowOnError extends boolean = true>(
1930
1930
  /**
1931
1931
  * Create or resume an owner's hosted Stripe Checkout
1932
1932
  *
1933
- * Returns a human payment URL, never charges a saved card. Paid is USD 10/month; each top-up pack is USD 10 before tax; a purchase grants 100 credits per dollar up to USD 100 and 125 credits per dollar for the part above, so 10 packs grant 10000 and 20 packs grant 22500 credits. Top-ups require active Paid access and have no time limit during uninterrupted Paid membership; remaining top-ups expire when the workspace returns to Free. Monthly Paid credits expire at billing-period end without rollover. Retry the same offer, packs and Idempotency-Key after uncertainty. Browser return is not payment proof; read this checkout and the organization balance. A conflicting or existing subscription returns billing_purchase_conflict (409); read the original checkout or request an owner billing portal URL instead of another purchase. Works at zero credits.
1933
+ * Returns a human payment URL, never charges a saved card. Paid is USD 10/month; each top-up pack is USD 10 before tax; a purchase grants 100 credits per dollar up to USD 100 and 125 credits per dollar for the part above, so 10 packs grant 10000 and 20 packs grant 22500 credits. Top-ups require active Paid access and never expire, also after the workspace returns to Free. Monthly Paid credits expire at billing-period end without rollover. Retry the same offer, packs and Idempotency-Key after uncertainty. Browser return is not payment proof; read this checkout and the organization balance. A conflicting or existing subscription returns billing_purchase_conflict (409); read the original checkout or request an owner billing portal URL instead of another purchase. Works at zero credits.
1934
1934
  */
1935
1935
  export const createBillingCheckout = <ThrowOnError extends boolean = true>(
1936
1936
  parameters: {
@@ -1983,7 +1983,7 @@ export const createBillingCheckout = <ThrowOnError extends boolean = true>(
1983
1983
  /**
1984
1984
  * Observe and reconcile an owner's original checkout
1985
1985
  *
1986
- * Reads Stripe and reconciles confirmed credits/refunds idempotently. payment_confirmed describes the original Checkout, not spendable credit or current Paid entitlement. Read organization credits for available funding and the organization account's effective plan for Paid coverage; paid_until is the paid Stripe period end, not the end of renewal grace. No new purchase intent or payment is created; an uncertain original Checkout can resume using its stored identity.
1986
+ * Reads Stripe and reconciles confirmed credits/refunds idempotently. payment_confirmed describes the original Checkout, not spendable credit or current Paid entitlement. Read organization credits for available funding and the organization account's effective plan for Paid coverage; paid_until is the end of paid coverage, the paid Stripe period end plus its 14-day renewal grace. No new purchase intent or payment is created; an uncertain original Checkout can resume using its stored identity.
1987
1987
  */
1988
1988
  export const getBillingCheckout = <ThrowOnError extends boolean = true>(
1989
1989
  parameters: {
@@ -2105,7 +2105,7 @@ export const getBillingRecharge = <ThrowOnError extends boolean = true>(
2105
2105
  /**
2106
2106
  * Enable or disable explicitly authorized auto-recharge
2107
2107
  *
2108
- * Owner-only. An agent must obtain explicit approval for off-session charges and the gross monthly spending cap before enabling. Each refill costs USD 9 before tax for 1000 top-up credits when available credits fall below 100. Active Paid access is required to enable recharge and initiate a payment; remaining refill credits expire on downgrade to Free. A saved Stripe card is required; follow setup_url if returned. Current revision prevents stale edits; retry the original Idempotency-Key and payload after uncertainty. Disable prevents new charge initiation; already initiated payments may complete. No subscription or Paid features are created.
2108
+ * Owner-only. An agent must obtain explicit approval for off-session charges and the gross monthly spending cap before enabling. Each refill costs USD 9 before tax for 1000 top-up credits when available credits fall below 100. Active Paid access is required to enable recharge and initiate a payment; bought credits never expire, also after a downgrade to Free. A saved Stripe card is required; follow setup_url if returned. Current revision prevents stale edits; retry the original Idempotency-Key and payload after uncertainty. Disable prevents new charge initiation; already initiated payments may complete. No subscription or Paid features are created.
2109
2109
  */
2110
2110
  export const configureBillingRecharge = <ThrowOnError extends boolean = true>(
2111
2111
  parameters: {
@@ -2162,7 +2162,7 @@ export const configureBillingRecharge = <ThrowOnError extends boolean = true>(
2162
2162
  /**
2163
2163
  * Read the owner's shared organization credit pool
2164
2164
  *
2165
- * Returns posted credits and reservations, in microcredits (one credit is 1000000 microcredits). Monthly entitlement posting is idempotent. Only the organization Owner may read this balance. active_meters names the currently billed sources; unreported usage is not included. platform_overrun_micros is recorded platform exposure, not customer debt. Remains available at zero credit.
2165
+ * Returns the spendable credit and the open reservations, in microcredits (one credit is 1000000 microcredits). available_micros is the monthly credit plus the one-time credit minus the reservations, never below zero. Only the organization Owner may read this balance. active_meters names the currently billed sources; usage that is not billed yet is not included. When the credit is used up, grace_started_at and grace_expires_at name the seven days that keep existing services running. Remains available at zero credit.
2166
2166
  */
2167
2167
  export const getOrganizationCredits = <ThrowOnError extends boolean = true>(
2168
2168
  parameters: {
@@ -2202,16 +2202,14 @@ export const getOrganizationCredits = <ThrowOnError extends boolean = true>(
2202
2202
  };
2203
2203
 
2204
2204
  /**
2205
- * Read monthly measured usage by project and meter
2205
+ * Read recent measured usage by day, project and meter
2206
2206
  *
2207
- * Owner-only event-month ledger totals, including signed corrections posted by as_of. Returns up to 20 projects per page in ID order; use next_cursor with the same month. Current unresolved reservations are separate from measured consumption. Null environment_id means project-shared cost, never guessed Dev allocation. Only posted measurements are included; this is not a complete provider invoice or zero-usage guarantee. Billing may arrive later. No credit is granted or charged by this read; it remains usable at zero credits.
2207
+ * Owner-only. days holds the credit-log charges of the last up to 14 UTC days (today included, oldest first), grouped by day, project and meter. projects holds what each project has used so far in the current UTC month. A null environment_id means a project-shared cost, never a guessed Dev allocation. Only billed usage is included; charges may arrive later, so this is not a complete provider invoice or a zero-usage guarantee. No credit is granted or charged by this read; it remains usable at zero credits.
2208
2208
  */
2209
2209
  export const getOrganizationCreditUsage = <ThrowOnError extends boolean = true>(
2210
2210
  parameters: {
2211
2211
  "X-Request-Id"?: string;
2212
2212
  organization_id: Ulid;
2213
- month: string;
2214
- cursor?: Ulid;
2215
2213
  },
2216
2214
  options?: Options<never, ThrowOnError>,
2217
2215
  ): RequestResult<
@@ -2227,8 +2225,6 @@ export const getOrganizationCreditUsage = <ThrowOnError extends boolean = true>(
2227
2225
  args: [
2228
2226
  { in: "headers", key: "X-Request-Id" },
2229
2227
  { in: "path", key: "organization_id" },
2230
- { in: "query", key: "month" },
2231
- { in: "query", key: "cursor" },
2232
2228
  ],
2233
2229
  },
2234
2230
  ],
@@ -321,15 +321,12 @@ export type OrganizationCredits = {
321
321
  as_of: string;
322
322
  available_micros: CreditMicros;
323
323
  reserved_micros: CreditMicros;
324
- spent_micros: CreditMicros;
325
- expired_micros: CreditMicros;
326
- platform_overrun_micros: CreditMicros;
327
324
  /**
328
- * First confirmed exhaustion in this continuous period; null while funded.
325
+ * When the credit was used up; null while funded or after the monthly credit renewed.
329
326
  */
330
327
  grace_started_at: string | null;
331
328
  /**
332
- * Seven days after first confirmed exhaustion. Existing services and domains are retained during this grace; no automatic data deletion. Explicit project stop budgets are separate.
329
+ * Seven days after the credit was used up. Existing services and domains are retained during this grace; no automatic data deletion. Explicit project stop budgets are separate.
333
330
  */
334
331
  grace_expires_at: string | null;
335
332
  active_meters: Array<string>;
@@ -346,22 +343,38 @@ export type UsageTotal = string;
346
343
 
347
344
  export type OrganizationCreditUsage = {
348
345
  organization_id: Ulid;
349
- month: string;
350
346
  as_of: string;
351
347
  unit: "microcredits";
352
- next_cursor: Ulid | null;
353
- data: Array<{
348
+ /**
349
+ * The UTC month that projects[].used_micros counts.
350
+ */
351
+ period: string;
352
+ /**
353
+ * The start of the oldest UTC day in days.
354
+ */
355
+ from: string;
356
+ /**
357
+ * What each project has used so far in period, in ID order; projects without use are left out.
358
+ */
359
+ projects: Array<{
354
360
  project_id: Ulid;
355
- reserved_micros: UsageTotal;
356
- meters: Array<{
357
- environment_id: Ulid | null;
358
- meter: string;
359
- unit: string;
360
- rate_card_id: string;
361
- quantity: UsageTotal;
362
- charged_micros: UsageTotal;
363
- funded_micros: UsageTotal;
364
- platform_overrun_micros: UsageTotal;
361
+ used_micros: UsageTotal;
362
+ }>;
363
+ /**
364
+ * Billed charges of the last up to 14 UTC days, oldest first.
365
+ */
366
+ days: Array<{
367
+ day: string;
368
+ projects: Array<{
369
+ project_id: Ulid;
370
+ meters: Array<{
371
+ environment_id: Ulid | null;
372
+ meter: string;
373
+ unit: string;
374
+ rate_card_id: string;
375
+ quantity: string;
376
+ charged_micros: UsageTotal;
377
+ }>;
365
378
  }>;
366
379
  }>;
367
380
  };
@@ -384,6 +397,9 @@ export type PublishedCreditRateCard = {
384
397
  };
385
398
 
386
399
  export type SetProjectCreditBudgetRequest = {
400
+ /**
401
+ * The monthly budget, at most 9007199254740991 microcredits (about 9 billion credits); null removes it.
402
+ */
387
403
  amount_micros: CreditMicros | null;
388
404
  mode: "continue" | "stop";
389
405
  };
@@ -1264,13 +1280,28 @@ export type OrganizationAccount = {
1264
1280
  plan: "free" | "paid";
1265
1281
  plan_source: "free" | "stripe" | "granted" | "manual";
1266
1282
  /**
1267
- * End of the paid Stripe billing period or the applicable grant; null on Free or for an unbounded grant. During an unpaid renewal the effective Paid plan may remain available for up to 14 days after this Stripe period end, without new monthly credits.
1283
+ * End of the paid coverage: the Stripe billing period plus its 14-day renewal grace, or the end of the grant; null on Free. Paid features stay available until this instant.
1268
1284
  */
1269
1285
  paid_until: string | null;
1286
+ /**
1287
+ * Spendable credit: monthly plus one-time credit minus the open reservations, never below zero.
1288
+ */
1270
1289
  available_micros: CreditMicros;
1290
+ /**
1291
+ * The monthly credit, which ends at next_expiry; the Free allowance is 200 credits and the Paid allowance 1000 credits per period.
1292
+ */
1271
1293
  monthly_micros: CreditMicros;
1294
+ /**
1295
+ * Top-up, bonus and referral credit. It does not expire.
1296
+ */
1272
1297
  one_time_micros: CreditMicros;
1298
+ /**
1299
+ * Credit held for open builds; it is part of the monthly and one-time credit until the build settles.
1300
+ */
1273
1301
  reserved_micros: CreditMicros;
1302
+ /**
1303
+ * When the monthly credit ends and renews; null when none is left.
1304
+ */
1274
1305
  next_expiry: string | null;
1275
1306
  as_of: string;
1276
1307
  };
@@ -4396,10 +4427,7 @@ export type GetOrganizationCreditUsageData = {
4396
4427
  path: {
4397
4428
  organization_id: Ulid;
4398
4429
  };
4399
- query: {
4400
- month: string;
4401
- cursor?: Ulid;
4402
- };
4430
+ query?: never;
4403
4431
  url: "/v1/organizations/{organization_id}/credit-usage";
4404
4432
  };
4405
4433
 
@@ -4431,7 +4459,7 @@ export type GetOrganizationCreditUsageError =
4431
4459
 
4432
4460
  export type GetOrganizationCreditUsageResponses = {
4433
4461
  /**
4434
- * Current posted usage for the selected UTC month and project page.
4462
+ * Recent billed usage of the organization.
4435
4463
  */
4436
4464
  200: OrganizationCreditUsage;
4437
4465
  };