@zuplo/runtime 6.67.9 → 6.67.12

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.
@@ -586,6 +586,82 @@ export declare interface ApiAuthKeyInboundPolicyOptions {
586
586
  */
587
587
  declare type APIKey = string;
588
588
 
589
+ /**
590
+ * Represents a consumer in the API Key service.
591
+ * @public
592
+ */
593
+ export declare interface ApiKeyConsumer {
594
+ /** The unique consumer identifier, e.g. csmr_f9HGke8lQHi2HgxFa4OIst9W */
595
+ id: string;
596
+ /** The consumer name */
597
+ name: string;
598
+ /** Optional description of the consumer */
599
+ description?: string;
600
+ /** Custom metadata stored with the consumer */
601
+ metadata?: unknown;
602
+ /** ISO timestamp when the consumer was created */
603
+ createdOn: string;
604
+ /** ISO timestamp when the consumer was last updated */
605
+ updatedOn: string;
606
+ }
607
+
608
+ /**
609
+ * A client for retrieving consumer data from the Zuplo API key service.
610
+ *
611
+ * @example
612
+ * ```typescript
613
+ * import { ApiKeyConsumerClient, ZuploContext, ZuploRequest } from "@zuplo/runtime";
614
+ *
615
+ * // Configure once (e.g., at module level)
616
+ * const consumers = new ApiKeyConsumerClient({
617
+ * cacheDurationSeconds: 300,
618
+ * });
619
+ *
620
+ * export async function myHandler(request: ZuploRequest, context: ZuploContext) {
621
+ * const consumer = await consumers.get("csmr_f9HGke8lQHi2HgxFa4OIst9W");
622
+ *
623
+ * context.log.info(`Consumer: ${consumer.name}`);
624
+ * const metadata = consumer.metadata as { plan: string };
625
+ *
626
+ * return Response.json({ consumer });
627
+ * }
628
+ * ```
629
+ *
630
+ * @beta
631
+ * @public
632
+ */
633
+ export declare class ApiKeyConsumerClient {
634
+ private readonly bucketId;
635
+ private readonly cacheDurationSeconds;
636
+ private cacheNamePromise;
637
+ constructor(options?: ApiKeyConsumerClientOptions);
638
+ private getCacheName;
639
+ /**
640
+ * Get consumer data by consumer ID.
641
+ *
642
+ * @param consumerId - The unique identifier of the consumer
643
+ * @returns The consumer data including metadata
644
+ */
645
+ get(consumerId: string): Promise<ApiKeyConsumer>;
646
+ }
647
+
648
+ /**
649
+ * Configuration options for {@link ApiKeyConsumerClient}.
650
+ * @public
651
+ */
652
+ export declare interface ApiKeyConsumerClientOptions {
653
+ /**
654
+ * The bucket ID for the API key service.
655
+ * Defaults to the ZUPLO_SERVICE_BUCKET_ID environment variable.
656
+ */
657
+ bucketId?: string;
658
+ /**
659
+ * Cache duration in seconds. Set to 0 to disable caching.
660
+ * Defaults to 60.
661
+ */
662
+ cacheDurationSeconds?: number;
663
+ }
664
+
589
665
  /**
590
666
  * Authenticates requests based on API Keys using Zuplo's built-in API key management.
591
667
  * This policy validates API keys against Zuplo's key storage, caches results for performance,
@@ -5836,10 +5912,6 @@ export declare interface MonetizationInboundPolicyOptions {
5836
5912
  * A list of successful status codes and ranges "200-299, 304" that should trigger a metering call.
5837
5913
  */
5838
5914
  meterOnStatusCodes?: string | number[];
5839
- /**
5840
- * The maximum number of days a subscription can have overdue payments before requests are blocked, even if the subscription has valid meters and balance. Set to 0 to block immediately when payment is overdue. Defaults to 3 days.
5841
- */
5842
- maxPendingPaymentDays?: number;
5843
5915
  }
5844
5916
 
5845
5917
  export declare interface MonetizationSubscription {
@@ -5871,6 +5943,13 @@ export declare interface MonetizationSubscription {
5871
5943
  usage: number;
5872
5944
  }
5873
5945
  >;
5946
+ /**
5947
+ * The maximum number of days a subscription can have overdue payments
5948
+ * before requests are blocked, even if the subscription has valid meters and
5949
+ * balance. Set to 0 to block immediately when payment is overdue.
5950
+ * Defaults to 3 days.
5951
+ */
5952
+ maxPaymentOverdueDays: number;
5874
5953
  createdAt: string;
5875
5954
  updatedAt: string;
5876
5955
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@zuplo/runtime",
3
3
  "type": "module",
4
- "version": "6.67.9",
4
+ "version": "6.67.12",
5
5
  "repository": "https://github.com/zuplo/zuplo",
6
6
  "author": "Zuplo, Inc.",
7
7
  "exports": {