@zuplo/cli 6.73.24 → 6.73.25

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.
Files changed (49) hide show
  1. package/node_modules/@posthog/core/dist/surveys/activation.d.ts +8 -0
  2. package/node_modules/@posthog/core/dist/surveys/activation.d.ts.map +1 -1
  3. package/node_modules/@posthog/core/dist/surveys/activation.js +7 -1
  4. package/node_modules/@posthog/core/dist/surveys/activation.mjs +4 -1
  5. package/node_modules/@posthog/core/dist/surveys/index.d.ts +1 -1
  6. package/node_modules/@posthog/core/dist/surveys/index.d.ts.map +1 -1
  7. package/node_modules/@posthog/core/dist/surveys/index.js +3 -0
  8. package/node_modules/@posthog/core/dist/surveys/index.mjs +2 -2
  9. package/node_modules/@posthog/core/package.json +1 -1
  10. package/node_modules/@posthog/core/src/surveys/activation.ts +12 -0
  11. package/node_modules/@posthog/core/src/surveys/index.ts +1 -1
  12. package/node_modules/@zuplo/core/customer.cli.minified.js +205 -205
  13. package/node_modules/@zuplo/core/index.minified.js +210 -210
  14. package/node_modules/@zuplo/core/package.json +1 -1
  15. package/node_modules/@zuplo/graphql/package.json +1 -1
  16. package/node_modules/@zuplo/openapi-tools/package.json +1 -1
  17. package/node_modules/@zuplo/otel/package.json +1 -1
  18. package/node_modules/@zuplo/runtime/out/esm/chunk-A3425Z75.js +26 -0
  19. package/node_modules/@zuplo/runtime/out/esm/chunk-A3425Z75.js.map +1 -0
  20. package/node_modules/@zuplo/runtime/out/esm/{chunk-FPZAMUNA.js → chunk-PEUB7LX7.js} +2 -2
  21. package/node_modules/@zuplo/runtime/out/esm/chunk-PEUB7LX7.js.map +1 -0
  22. package/node_modules/@zuplo/runtime/out/esm/chunk-RB2LCXBX.js +26 -0
  23. package/node_modules/@zuplo/runtime/out/esm/chunk-RB2LCXBX.js.map +1 -0
  24. package/node_modules/@zuplo/runtime/out/esm/{chunk-SNZSLL63.js → chunk-SL6SOWIV.js} +2 -2
  25. package/node_modules/@zuplo/runtime/out/esm/chunk-TRBIM47E.js +26 -0
  26. package/node_modules/@zuplo/runtime/out/esm/chunk-TRBIM47E.js.map +1 -0
  27. package/node_modules/@zuplo/runtime/out/esm/{chunk-QWO5UTVQ.js → chunk-V4X24KCQ.js} +4 -4
  28. package/node_modules/@zuplo/runtime/out/esm/chunk-V4X24KCQ.js.map +1 -0
  29. package/node_modules/@zuplo/runtime/out/esm/{chunk-R7PMDIH4.js → chunk-WK5G5RKI.js} +108 -108
  30. package/node_modules/@zuplo/runtime/out/esm/chunk-WK5G5RKI.js.map +1 -0
  31. package/node_modules/@zuplo/runtime/out/esm/index.js +1 -1
  32. package/node_modules/@zuplo/runtime/out/esm/index.js.map +1 -1
  33. package/node_modules/@zuplo/runtime/out/esm/internal/index.js +1 -1
  34. package/node_modules/@zuplo/runtime/out/esm/mcp/messages/index.js +1 -1
  35. package/node_modules/@zuplo/runtime/out/esm/mcp-gateway/index.js +1 -1
  36. package/node_modules/@zuplo/runtime/out/esm/mcp-gateway/index.js.map +1 -1
  37. package/node_modules/@zuplo/runtime/out/esm/sdks/aws/index.js +1 -1
  38. package/node_modules/@zuplo/runtime/out/esm/sdks/aws/index.js.map +1 -1
  39. package/node_modules/@zuplo/runtime/out/types/index.d.ts +28 -21
  40. package/node_modules/@zuplo/runtime/out/types/internal/index.d.ts +787 -0
  41. package/node_modules/@zuplo/runtime/package.json +2 -2
  42. package/package.json +6 -6
  43. package/node_modules/@zuplo/runtime/out/esm/chunk-FPZAMUNA.js.map +0 -1
  44. package/node_modules/@zuplo/runtime/out/esm/chunk-QWO5UTVQ.js.map +0 -1
  45. package/node_modules/@zuplo/runtime/out/esm/chunk-R7PMDIH4.js.map +0 -1
  46. package/node_modules/@zuplo/runtime/out/esm/chunk-US6ITPGV.js +0 -26
  47. package/node_modules/@zuplo/runtime/out/esm/chunk-US6ITPGV.js.map +0 -1
  48. /package/node_modules/@zuplo/runtime/out/esm/{chunk-SNZSLL63.js.map → chunk-SL6SOWIV.js.map} +0 -0
  49. /package/node_modules/@zuplo/runtime/out/esm/{chunk-R7PMDIH4.js.LEGAL.txt → chunk-WK5G5RKI.js.LEGAL.txt} +0 -0
@@ -1,7 +1,21 @@
1
+ /* Excluded from this release type: AIGatewayConfiguration */
2
+
1
3
  export declare interface ApiRuntimeConfig {
2
4
  urls: UrlConfig | undefined;
3
5
  }
4
6
 
7
+ /**
8
+ * Base logger interface with methods for each log level.
9
+ * @beta
10
+ */
11
+ declare interface BaseLogger {
12
+ debug(...messages: unknown[]): void;
13
+ info(...messages: unknown[]): void;
14
+ log(...messages: unknown[]): void;
15
+ warn(...messages: unknown[]): void;
16
+ error(...messages: unknown[]): void;
17
+ }
18
+
5
19
  /* Excluded from this release type: BuildEnvironment */
6
20
 
7
21
  /**
@@ -130,6 +144,12 @@ declare interface CompatibilityFlags {
130
144
  return501ForUnsupportedHttpMethods: boolean;
131
145
  }
132
146
 
147
+ /**
148
+ * The 2-letter continent codes Cloudflare uses
149
+ * @public
150
+ */
151
+ declare type ContinentCode = "AF" | "AN" | "AS" | "EU" | "NA" | "OC" | "SA";
152
+
133
153
  /**
134
154
  * @public
135
155
  */
@@ -152,6 +172,46 @@ declare interface CorsPolicyConfiguration {
152
172
 
153
173
  export declare type DevPortalType = "legacy" | "zudoku";
154
174
 
175
+ declare const EventType: {
176
+ readonly AI_GATEWAY_COST_SUM: "ai_gateway_cost_sum";
177
+ readonly AI_GATEWAY_REQUEST_COUNT: "ai_gateway_request_count";
178
+ readonly AI_GATEWAY_TOKEN_SUM: "ai_gateway_token_sum";
179
+ readonly AI_GATEWAY_LATENCY_HISTOGRAM: "ai_gateway_latency_histogram";
180
+ readonly AI_GATEWAY_WARNING_COUNT: "ai_gateway_warning_count";
181
+ readonly AI_GATEWAY_BLOCKED_COUNT: "ai_gateway_blocked_count";
182
+ readonly AI_GATEWAY_FALLBACK_COUNT: "ai_gateway_fallback_count";
183
+ readonly MCP_REQUEST_RECEIVED: "mcp_request_received";
184
+ readonly MCP_REQUEST_COMPLETED: "mcp_request_completed";
185
+ readonly MCP_REQUEST_REJECTED: "mcp_request_rejected";
186
+ readonly MCP_INITIALIZE_NEGOTIATED: "mcp_initialize_negotiated";
187
+ readonly MCP_CLIENT_UNSUPPORTED_BEHAVIOR: "mcp_client_unsupported_behavior";
188
+ readonly MCP_CAPABILITY_LISTED: "mcp_capability_listed";
189
+ readonly MCP_CAPABILITY_INVOKED: "mcp_capability_invoked";
190
+ readonly MCP_CAPABILITY_COMPLETED: "mcp_capability_completed";
191
+ readonly MCP_CAPABILITY_FAILED: "mcp_capability_failed";
192
+ readonly MCP_CAPABILITY_CONNECT_REQUIRED: "mcp_capability_connect_required";
193
+ readonly MCP_AUTH_DOWNSTREAM_TOKEN_VALIDATED: "mcp_auth_downstream_token_validated";
194
+ readonly MCP_AUTH_DOWNSTREAM_TOKEN_REJECTED: "mcp_auth_downstream_token_rejected";
195
+ readonly MCP_OAUTH_CLIENT_REGISTERED: "mcp_oauth_client_registered";
196
+ readonly MCP_OAUTH_AUTHORIZE_STARTED: "mcp_oauth_authorize_started";
197
+ readonly MCP_OAUTH_AUTHORIZE_AWAITING_SETUP: "mcp_oauth_authorize_awaiting_setup";
198
+ readonly MCP_OAUTH_TOKEN_ISSUED: "mcp_oauth_token_issued";
199
+ readonly MCP_OAUTH_TOKEN_REFRESH_ROTATED: "mcp_oauth_token_refresh_rotated";
200
+ readonly MCP_OAUTH_TOKEN_REVOKED: "mcp_oauth_token_revoked";
201
+ readonly MCP_AUTH_UPSTREAM_CONNECT_REQUIRED: "mcp_auth_upstream_connect_required";
202
+ readonly MCP_AUTH_UPSTREAM_CONNECT_STARTED: "mcp_auth_upstream_connect_started";
203
+ readonly MCP_AUTH_UPSTREAM_CALLBACK_RECEIVED: "mcp_auth_upstream_callback_received";
204
+ readonly MCP_AUTH_UPSTREAM_TOKEN_EXCHANGE_SUCCEEDED: "mcp_auth_upstream_token_exchange_succeeded";
205
+ readonly MCP_AUTH_UPSTREAM_TOKEN_EXCHANGE_FAILED: "mcp_auth_upstream_token_exchange_failed";
206
+ readonly MCP_AUTH_UPSTREAM_CREDENTIAL_RESOLVED: "mcp_auth_upstream_credential_resolved";
207
+ readonly MCP_AUTH_UPSTREAM_CREDENTIAL_MISSING: "mcp_auth_upstream_credential_missing";
208
+ readonly MCP_AUTH_UPSTREAM_RECONSENT_REQUIRED: "mcp_auth_upstream_reconsent_required";
209
+ readonly GRAPHQL_OPERATION: "graphql_operation";
210
+ readonly CACHE_OPERATION: "cache_operation";
211
+ };
212
+
213
+ declare type EventType = (typeof EventType)[keyof typeof EventType];
214
+
155
215
  /* Excluded from this release type: getIdForParameterSchema */
156
216
 
157
217
  /* Excluded from this release type: getIdForRefSchema */
@@ -524,12 +584,417 @@ declare type HttpStatusCodeRangeDefinition =
524
584
  | "4XX"
525
585
  | "5XX";
526
586
 
587
+ /**
588
+ * @public
589
+ */
590
+ declare interface IncomingRequestProperties {
591
+ /**
592
+ * ASN of the incoming request, for example, 395747.
593
+ */
594
+ readonly asn: number | undefined;
595
+ /**
596
+ * The organization which owns the ASN of the incoming request,
597
+ * for example, Google Cloud.
598
+ */
599
+ readonly asOrganization: string | undefined;
600
+ /**
601
+ * City of the incoming request, for example, "Austin".
602
+ */
603
+ readonly city: string | undefined;
604
+ /**
605
+ * Continent of the incoming request, for example, "NA".
606
+ */
607
+ readonly continent: ContinentCode | undefined;
608
+ /**
609
+ * The two-letter country code in the request.
610
+ * @see {@link https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2|ISO 3166-1 alpha-2}
611
+ */
612
+ readonly country: Iso3166Alpha2Code | undefined;
613
+ /**
614
+ * Latitude of the incoming request, for example, "30.27130".
615
+ */
616
+ readonly latitude: string | undefined;
617
+ /**
618
+ * Longitude of the incoming request, for example, "-97.74260".
619
+ */
620
+ readonly longitude: string | undefined;
621
+ /**
622
+ * The three-letter IATA airport code of the data center that the request hit,
623
+ * for example, "DFW".
624
+ * @see {@link https://en.wikipedia.org/wiki/IATA_airport_code|IATA airport code}
625
+ */
626
+ readonly colo: string | undefined;
627
+ /**
628
+ * Postal code of the incoming request, for example, "78701".
629
+ */
630
+ readonly postalCode: string | undefined;
631
+ /**
632
+ * Metro code (DMA) of the incoming request, for example, "635".
633
+ */
634
+ readonly metroCode: string | undefined;
635
+ /**
636
+ * If known, the ISO 3166-2 name for the first level region associated with
637
+ * the IP address of the incoming request, for example, "Texas".
638
+ * @see {@link https://en.wikipedia.org/wiki/ISO_3166-2|ISO 3166-2}
639
+ */
640
+ readonly region: string | undefined;
641
+ /**
642
+ * If known, the ISO 3166-2 code for the first-level region associated with
643
+ * the IP address of the incoming request, for example, "TX".
644
+ * @see {@link https://en.wikipedia.org/wiki/ISO_3166-2|ISO 3166-2}
645
+ */
646
+ readonly regionCode: string | undefined;
647
+ /**
648
+ * Timezone of the incoming request, for example, "America/Chicago".
649
+ */
650
+ readonly timezone: string | undefined;
651
+ /**
652
+ * If available, the HTTP protocol of the incoming request, for example, "HTTP/1.1".
653
+ */
654
+ readonly httpProtocol: string | undefined;
655
+ /* Excluded from this release type: clientCert */
656
+ /* Excluded from this release type: clientMtlsVerificationStatus */
657
+ /* Excluded from this release type: clientMtlsVerificationReason */
658
+ /* Excluded from this release type: clientCertFingerprintSha256 */
659
+ /* Excluded from this release type: clientCertNotBefore */
660
+ /* Excluded from this release type: clientCertNotAfter */
661
+ /* Excluded from this release type: clientCertIssuerDn */
662
+ /* Excluded from this release type: clientCertSubjectDn */
663
+ }
664
+
665
+ /**
666
+ * ISO 3166-1 Alpha-2 codes
667
+ * @public
668
+ */
669
+ declare type Iso3166Alpha2Code =
670
+ | "AD"
671
+ | "AE"
672
+ | "AF"
673
+ | "AG"
674
+ | "AI"
675
+ | "AL"
676
+ | "AM"
677
+ | "AO"
678
+ | "AQ"
679
+ | "AR"
680
+ | "AS"
681
+ | "AT"
682
+ | "AU"
683
+ | "AW"
684
+ | "AX"
685
+ | "AZ"
686
+ | "BA"
687
+ | "BB"
688
+ | "BD"
689
+ | "BE"
690
+ | "BF"
691
+ | "BG"
692
+ | "BH"
693
+ | "BI"
694
+ | "BJ"
695
+ | "BL"
696
+ | "BM"
697
+ | "BN"
698
+ | "BO"
699
+ | "BQ"
700
+ | "BR"
701
+ | "BS"
702
+ | "BT"
703
+ | "BV"
704
+ | "BW"
705
+ | "BY"
706
+ | "BZ"
707
+ | "CA"
708
+ | "CC"
709
+ | "CD"
710
+ | "CF"
711
+ | "CG"
712
+ | "CH"
713
+ | "CI"
714
+ | "CK"
715
+ | "CL"
716
+ | "CM"
717
+ | "CN"
718
+ | "CO"
719
+ | "CR"
720
+ | "CU"
721
+ | "CV"
722
+ | "CW"
723
+ | "CX"
724
+ | "CY"
725
+ | "CZ"
726
+ | "DE"
727
+ | "DJ"
728
+ | "DK"
729
+ | "DM"
730
+ | "DO"
731
+ | "DZ"
732
+ | "EC"
733
+ | "EE"
734
+ | "EG"
735
+ | "EH"
736
+ | "ER"
737
+ | "ES"
738
+ | "ET"
739
+ | "FI"
740
+ | "FJ"
741
+ | "FK"
742
+ | "FM"
743
+ | "FO"
744
+ | "FR"
745
+ | "GA"
746
+ | "GB"
747
+ | "GD"
748
+ | "GE"
749
+ | "GF"
750
+ | "GG"
751
+ | "GH"
752
+ | "GI"
753
+ | "GL"
754
+ | "GM"
755
+ | "GN"
756
+ | "GP"
757
+ | "GQ"
758
+ | "GR"
759
+ | "GS"
760
+ | "GT"
761
+ | "GU"
762
+ | "GW"
763
+ | "GY"
764
+ | "HK"
765
+ | "HM"
766
+ | "HN"
767
+ | "HR"
768
+ | "HT"
769
+ | "HU"
770
+ | "ID"
771
+ | "IE"
772
+ | "IL"
773
+ | "IM"
774
+ | "IN"
775
+ | "IO"
776
+ | "IQ"
777
+ | "IR"
778
+ | "IS"
779
+ | "IT"
780
+ | "JE"
781
+ | "JM"
782
+ | "JO"
783
+ | "JP"
784
+ | "KE"
785
+ | "KG"
786
+ | "KH"
787
+ | "KI"
788
+ | "KM"
789
+ | "KN"
790
+ | "KP"
791
+ | "KR"
792
+ | "KW"
793
+ | "KY"
794
+ | "KZ"
795
+ | "LA"
796
+ | "LB"
797
+ | "LC"
798
+ | "LI"
799
+ | "LK"
800
+ | "LR"
801
+ | "LS"
802
+ | "LT"
803
+ | "LU"
804
+ | "LV"
805
+ | "LY"
806
+ | "MA"
807
+ | "MC"
808
+ | "MD"
809
+ | "ME"
810
+ | "MF"
811
+ | "MG"
812
+ | "MH"
813
+ | "MK"
814
+ | "ML"
815
+ | "MM"
816
+ | "MN"
817
+ | "MO"
818
+ | "MP"
819
+ | "MQ"
820
+ | "MR"
821
+ | "MS"
822
+ | "MT"
823
+ | "MU"
824
+ | "MV"
825
+ | "MW"
826
+ | "MX"
827
+ | "MY"
828
+ | "MZ"
829
+ | "NA"
830
+ | "NC"
831
+ | "NE"
832
+ | "NF"
833
+ | "NG"
834
+ | "NI"
835
+ | "NL"
836
+ | "NO"
837
+ | "NP"
838
+ | "NR"
839
+ | "NU"
840
+ | "NZ"
841
+ | "OM"
842
+ | "PA"
843
+ | "PE"
844
+ | "PF"
845
+ | "PG"
846
+ | "PH"
847
+ | "PK"
848
+ | "PL"
849
+ | "PM"
850
+ | "PN"
851
+ | "PR"
852
+ | "PS"
853
+ | "PT"
854
+ | "PW"
855
+ | "PY"
856
+ | "QA"
857
+ | "RE"
858
+ | "RO"
859
+ | "RS"
860
+ | "RU"
861
+ | "RW"
862
+ | "SA"
863
+ | "SB"
864
+ | "SC"
865
+ | "SD"
866
+ | "SE"
867
+ | "SG"
868
+ | "SH"
869
+ | "SI"
870
+ | "SJ"
871
+ | "SK"
872
+ | "SL"
873
+ | "SM"
874
+ | "SN"
875
+ | "SO"
876
+ | "SR"
877
+ | "SS"
878
+ | "ST"
879
+ | "SV"
880
+ | "SX"
881
+ | "SY"
882
+ | "SZ"
883
+ | "TC"
884
+ | "TD"
885
+ | "TF"
886
+ | "TG"
887
+ | "TH"
888
+ | "TJ"
889
+ | "TK"
890
+ | "TL"
891
+ | "TM"
892
+ | "TN"
893
+ | "TO"
894
+ | "TR"
895
+ | "TT"
896
+ | "TV"
897
+ | "TW"
898
+ | "TZ"
899
+ | "UA"
900
+ | "UG"
901
+ | "UM"
902
+ | "US"
903
+ | "UY"
904
+ | "UZ"
905
+ | "VA"
906
+ | "VC"
907
+ | "VE"
908
+ | "VG"
909
+ | "VI"
910
+ | "VN"
911
+ | "VU"
912
+ | "WF"
913
+ | "WS"
914
+ | "YE"
915
+ | "YT"
916
+ | "ZA"
917
+ | "ZM"
918
+ | "ZW";
919
+
527
920
  /* Excluded from this release type: isRestrictedEnvVariableName */
528
921
 
529
922
  /* Excluded from this release type: isZuploReadableEnvVariableName */
530
923
 
924
+ declare type JsonArray = JsonValue[] | readonly JsonValue[];
925
+
926
+ /**
927
+ Matches a JSON object.
928
+ This type can be useful to enforce some input to be JSON-compatible or as a super-type to be extended from. Don't use this as a direct return type as the user would have to double-cast it: `jsonObject as unknown as CustomResponse`. Instead, you could extend your CustomResponse type from it to ensure your type only uses JSON-compatible types: `interface CustomResponse extends JsonObject { … }`.
929
+ */
930
+ declare type JsonObject = {
931
+ [Key in string]: JsonValue;
932
+ } & {
933
+ [Key in string]?: JsonValue | undefined;
934
+ };
935
+
936
+ declare type JsonPrimitive = string | number | boolean | null;
937
+
938
+ /**
939
+ Matches any valid JSON value.
940
+ @see `Jsonify` if you need to transform a type to one that is assignable to `JsonValue`.
941
+ */
942
+ declare type JsonValue = JsonPrimitive | JsonObject | JsonArray;
943
+
944
+ /**
945
+ * Logger to be used in the runtime via context.log.
946
+ * You can set per-request properties that will be included in all log entries for this request.
947
+ * @beta
948
+ */
949
+ declare interface Logger extends BaseLogger {
950
+ /**
951
+ * Set properties that will be included in all subsequent log entries for this request.
952
+ * Properties are merged with existing properties and any static fields configured in the logging plugin.
953
+ * Per-request properties take precedence over static fields with the same name.
954
+ *
955
+ * @param properties - Key-value pairs to include in log entries. Values must be string, number, or boolean.
956
+ *
957
+ * @example
958
+ * ```ts
959
+ * export default async function (request: ZuploRequest, context: ZuploContext) {
960
+ * // Set properties that will be included in all logs for this request
961
+ * context.log.setLogProperties({ http_status_code: 400, user_id: "123" });
962
+ *
963
+ * context.log.error("Request failed"); // Will include http_status_code and user_id
964
+ *
965
+ * return new Response("Error", { status: 400 });
966
+ * }
967
+ * ```
968
+ */
969
+ setLogProperties?(
970
+ properties: Record<string, string | number | boolean>
971
+ ): void;
972
+ }
973
+
531
974
  declare type Modify<T, R> = Omit<T, keyof R> & R;
532
975
 
976
+ /**
977
+ * @public
978
+ */
979
+ declare interface OnResponseSendingFinalHook {
980
+ (
981
+ response: Response,
982
+ request: ZuploRequest,
983
+ context: ZuploContext
984
+ ): Promise<void> | void;
985
+ }
986
+
987
+ /**
988
+ * @public
989
+ */
990
+ declare interface OnResponseSendingHook {
991
+ (
992
+ response: Response,
993
+ request: ZuploRequest,
994
+ context: ZuploContext
995
+ ): Promise<Response> | Response;
996
+ }
997
+
533
998
  declare namespace OpenAPIV3 {
534
999
  interface Document<T extends {} = {}> {
535
1000
  openapi: string;
@@ -1099,6 +1564,65 @@ declare interface PolicyConfiguration {
1099
1564
  options?: unknown;
1100
1565
  }
1101
1566
 
1567
+ /**
1568
+ * Generic type parameters for a request.
1569
+ * Extends RequestInitGeneric and adds query parameter typing.
1570
+ * @public
1571
+ */
1572
+ declare interface RequestGeneric extends RequestInitGeneric {
1573
+ Query?: RequestQueryDefault;
1574
+ }
1575
+
1576
+ /**
1577
+ * Generic type parameters for request initialization.
1578
+ * Used to strongly type the user data and path parameters.
1579
+ * @public
1580
+ */
1581
+ declare interface RequestInitGeneric {
1582
+ UserData?: UserDataDefault;
1583
+ Params?: RequestParamsDefault;
1584
+ }
1585
+
1586
+ declare type RequestParamsDefault = Record<string, string>;
1587
+
1588
+ declare type RequestQueryDefault = Record<string, string>;
1589
+
1590
+ /**
1591
+ * Represents an authenticated user on the request.
1592
+ * Set by authentication policies like API key, JWT, or OAuth.
1593
+ *
1594
+ * @public
1595
+ * @example
1596
+ * ```typescript
1597
+ * // Access user info in a handler
1598
+ * export function myHandler(request: ZuploRequest, context: ZuploContext) {
1599
+ * if (!request.user) {
1600
+ * return new Response("Unauthorized", { status: 401 });
1601
+ * }
1602
+ *
1603
+ * const userId = request.user.sub;
1604
+ * const customData = request.user.data as { role: string; tenantId: string };
1605
+ *
1606
+ * context.log.info(`Request from user ${userId} with role ${customData.role}`);
1607
+ * }
1608
+ * ```
1609
+ */
1610
+ declare interface RequestUser<TUserData> {
1611
+ sub: string;
1612
+ data: TUserData;
1613
+ }
1614
+
1615
+ declare type ResolveRequestParams<
1616
+ TParams extends RequestParamsDefault | undefined,
1617
+ > = TParams extends RequestParamsDefault ? TParams : RequestParamsDefault;
1618
+
1619
+ declare type ResolveRequestQuery<
1620
+ TQuery extends RequestQueryDefault | undefined,
1621
+ > = TQuery extends RequestQueryDefault ? TQuery : RequestQueryDefault;
1622
+
1623
+ declare type ResolveUserData<TUserData extends UserDataDefault | undefined> =
1624
+ TUserData extends UserDataDefault ? TUserData : UserDataDefault;
1625
+
1102
1626
  /**
1103
1627
  * Definition of responses for a route
1104
1628
  * @public
@@ -1172,4 +1696,267 @@ declare interface UrlConfig {
1172
1696
  urls: string[];
1173
1697
  }
1174
1698
 
1699
+ declare type UserDataDefault = any;
1700
+
1701
+ /**
1702
+ * @public
1703
+ */
1704
+ declare interface WaitUntilFunc {
1705
+ (promise: Promise<any>): void;
1706
+ }
1707
+
1708
+ declare interface ZuploAnalyticsContext {
1709
+ addAnalyticsEvent(
1710
+ value: number,
1711
+ eventType: EventType,
1712
+ metadata: JsonObject,
1713
+ unit?: string,
1714
+ eventId?: string
1715
+ ): void;
1716
+ flushAnalyticsEvents(): ZuploAnalyticsEvent[];
1717
+ getAnalyticsEvents(): ZuploAnalyticsEvent[];
1718
+ }
1719
+
1720
+ declare interface ZuploAnalyticsEvent<T extends JsonObject = JsonObject> {
1721
+ eventId: string;
1722
+ requestId: string;
1723
+ timestamp: Date;
1724
+ accountName: string;
1725
+ projectName: string;
1726
+ deploymentName: string;
1727
+ eventType: EventType;
1728
+ metadata: T;
1729
+ unit?: string;
1730
+ value: number;
1731
+ }
1732
+
1733
+ /**
1734
+ * The ZuploContext provides information about the current request and helper methods.
1735
+ * @public
1736
+ */
1737
+ declare interface ZuploContext extends EventTarget {
1738
+ /**
1739
+ * The unique identifier of this context
1740
+ */
1741
+ readonly contextId: Readonly<string>;
1742
+ /**
1743
+ * The unique identifier of the incoming request
1744
+ */
1745
+ readonly requestId: Readonly<string>;
1746
+ /**
1747
+ * Request based logger
1748
+ */
1749
+ readonly log: Readonly<Logger>;
1750
+ /**
1751
+ * The route that is being processed
1752
+ */
1753
+ readonly route: Readonly<RouteConfiguration>;
1754
+ /**
1755
+ * Custom data stored on the ZuploContext
1756
+ */
1757
+ readonly custom: Record<string, any>;
1758
+ readonly incomingRequestProperties: IncomingRequestProperties;
1759
+ /**
1760
+ * The parent context that spawned this context
1761
+ * @beta
1762
+ */
1763
+ readonly parentContext: ZuploContext | undefined;
1764
+ /* Excluded from this release type: analyticsContext */
1765
+ readonly invokeInboundPolicy: (
1766
+ policyName: string,
1767
+ request: ZuploRequest
1768
+ ) => Promise<Response | ZuploRequest>;
1769
+ readonly invokeOutboundPolicy: (
1770
+ policyName: string,
1771
+ response: Response,
1772
+ request: ZuploRequest
1773
+ ) => Promise<Response>;
1774
+ /**
1775
+ * Invokes a route based on a Request without going back out to HTTP.
1776
+ * Can take a relative route path to invoke on the Gateway
1777
+ * Example: "/my/route" will invoke http://localhost/my/route on the Gateway
1778
+ * without having to rebuild the Request's protocol and host.
1779
+ * @beta
1780
+ */
1781
+ readonly invokeRoute: <TOptions extends RequestGeneric = RequestGeneric>(
1782
+ input: string | URL | Request,
1783
+ init?: ZuploRequestInit<TOptions>
1784
+ ) => Promise<Response>;
1785
+ readonly waitUntil: WaitUntilFunc;
1786
+ /**
1787
+ * Fires just before the response is sent. Response can be modified.
1788
+ */
1789
+ readonly addResponseSendingHook: (hook: OnResponseSendingHook) => void;
1790
+ /**
1791
+ * Fires immediately after the response is sent. Response cannot be modified.
1792
+ */
1793
+ readonly addResponseSendingFinalHook: (
1794
+ hook: OnResponseSendingFinalHook
1795
+ ) => void;
1796
+ /**
1797
+ * Appends an event listener for events whose type attribute value is type. The callback argument sets the callback that will be invoked when the event is dispatched.
1798
+ *
1799
+ * The options argument sets listener-specific options. For compatibility this can be a boolean, in which case the method behaves exactly as if the value was specified as options's capture.
1800
+ *
1801
+ * When set to true, options's capture prevents callback from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE. When false (or not present), callback will not be invoked when event's eventPhase attribute value is CAPTURING_PHASE. Either way, callback will be invoked if event's eventPhase attribute value is AT_TARGET.
1802
+ *
1803
+ * When set to true, options's passive indicates that the callback will not cancel the event by invoking preventDefault(). This is used to enable performance optimizations described in § 2.8 Observing event listeners.
1804
+ *
1805
+ * When set to true, options's once indicates that the callback will only be invoked once after which the event listener will be removed.
1806
+ *
1807
+ * If an AbortSignal is passed for options's signal, then the event listener will be removed when signal is aborted.
1808
+ *
1809
+ * The event listener is appended to target's event listener list and is not appended if it has the same type, callback, and capture.
1810
+ * @deprecated This will be removed in the future. Use hooks instead. See {@link https://zuplo.com/docs/programmable-api/runtime-extensions}
1811
+ */
1812
+ addEventListener<Type extends keyof Record<string, Event>>(
1813
+ type: Type,
1814
+ handler: EventListenerOrEventListenerObject,
1815
+ options?: AddEventListenerOptions | boolean
1816
+ ): void;
1817
+ /**
1818
+ * @deprecated This will be removed in the future. See {@link https://zuplo.com/docs/programmable-api/runtime-extensions}
1819
+ */
1820
+ removeEventListener<Type extends keyof Record<string, Event>>(
1821
+ type: Type,
1822
+ handler: EventListenerOrEventListenerObject,
1823
+ options?: AddEventListenerOptions | boolean
1824
+ ): void;
1825
+ }
1826
+
1827
+ /**
1828
+ * Enhanced Request class that extends the standard Web Request API with
1829
+ * convenient properties for accessing path parameters, query strings, and user data.
1830
+ * This is the request type passed to all handlers and policies in Zuplo.
1831
+ *
1832
+ * @public
1833
+ * @example
1834
+ * ```typescript
1835
+ * import { ZuploRequest, ZuploContext } from "@zuplo/runtime";
1836
+ *
1837
+ * export function myHandler(request: ZuploRequest, context: ZuploContext) {
1838
+ * // Access query parameters
1839
+ * const page = request.query.page || "1";
1840
+ * const limit = request.query.limit || "10";
1841
+ *
1842
+ * // Access path parameters (e.g., from /users/:userId)
1843
+ * const userId = request.params.userId;
1844
+ *
1845
+ * // Access authenticated user
1846
+ * const user = request.user;
1847
+ *
1848
+ * // Standard Request properties still available
1849
+ * const contentType = request.headers.get("content-type");
1850
+ * const method = request.method;
1851
+ *
1852
+ * return Response.json({
1853
+ * userId,
1854
+ * page,
1855
+ * limit,
1856
+ * authenticated: !!user
1857
+ * });
1858
+ * }
1859
+ * ```
1860
+ *
1861
+ * @example
1862
+ * ```typescript
1863
+ * // Strongly typed request parameters
1864
+ * interface MyParams {
1865
+ * userId: string;
1866
+ * orderId: string;
1867
+ * }
1868
+ *
1869
+ * interface MyQuery {
1870
+ * include?: string;
1871
+ * format?: "json" | "xml";
1872
+ * }
1873
+ *
1874
+ * interface MyUserData {
1875
+ * role: "admin" | "user";
1876
+ * tenantId: string;
1877
+ * }
1878
+ *
1879
+ * type MyRequest = ZuploRequest<{
1880
+ * Params: MyParams;
1881
+ * Query: MyQuery;
1882
+ * UserData: MyUserData;
1883
+ * }>;
1884
+ *
1885
+ * export function typedHandler(request: MyRequest, context: ZuploContext) {
1886
+ * // All properties are now strongly typed
1887
+ * const userId = request.params.userId; // string
1888
+ * const format = request.query.format; // "json" | "xml" | undefined
1889
+ * const role = request.user?.data.role; // "admin" | "user" | undefined
1890
+ * }
1891
+ * ```
1892
+ */
1893
+ declare class ZuploRequest<
1894
+ TOptions extends RequestGeneric = RequestGeneric,
1895
+ > extends Request {
1896
+ #private;
1897
+ constructor(
1898
+ input: string | URL | Request,
1899
+ init?: ZuploRequestInit<TOptions>,
1900
+ originalRequest?: Request
1901
+ );
1902
+ /* Excluded from this release type: originalRequest */
1903
+ /**
1904
+ * A dictionary of query-string values
1905
+ *
1906
+ * @example
1907
+ * The url `https://example.com?foo=bar` would return
1908
+ * the following query object:
1909
+ *
1910
+ * ```
1911
+ * const foo = request.query.foo;
1912
+ * ```
1913
+ *
1914
+ * @readonly
1915
+ */
1916
+ get query(): Readonly<ResolveRequestQuery<TOptions["Query"]>>;
1917
+ /**
1918
+ * If you use tokens in your route’s URL, they are
1919
+ * automatically parsed into properties on the params
1920
+ * property of your request.
1921
+ *
1922
+ * @example
1923
+ * The route `/products/:productId/vendors/:vendorId`
1924
+ * would include two params:
1925
+ *
1926
+ * ```
1927
+ * const productId = request.params.productId;
1928
+ * const vendorId = request.params.vendorId;
1929
+ * ```
1930
+ * @readonly
1931
+ */
1932
+ get params(): Readonly<ResolveRequestParams<TOptions["Params"]>>;
1933
+ /**
1934
+ * An optional object identifying a ‘user’.
1935
+ *
1936
+ * @remarks
1937
+ * If undefined this typically means the request is
1938
+ * anonymous. If present, the user object will have
1939
+ * a sub property that is a unique identifier for
1940
+ * that user. There is also an optional data property
1941
+ * that is of any type that typically contains other
1942
+ * information about the user. When using JWT tokens
1943
+ * you’ll usually find all the claims here.
1944
+ *
1945
+ * @readonly
1946
+ */
1947
+ user?: RequestUser<ResolveUserData<TOptions["UserData"]>>;
1948
+ }
1949
+
1950
+ /**
1951
+ * Options for creating a new ZuploRequest.
1952
+ * Extends the standard RequestInit with Zuplo-specific properties.
1953
+ * @public
1954
+ */
1955
+ declare interface ZuploRequestInit<
1956
+ TOptions extends RequestInitGeneric = RequestInitGeneric,
1957
+ > extends RequestInit {
1958
+ params?: ResolveRequestParams<TOptions["Params"]>;
1959
+ user?: ResolveUserData<TOptions["UserData"]>;
1960
+ }
1961
+
1175
1962
  export {};