@zuplo/runtime 6.52.3 → 6.52.5

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.
@@ -1,5 +1,8 @@
1
1
  /* Excluded from this release type: BuildEnvironment */
2
2
 
3
+ /**
4
+ * @public
5
+ */
3
6
  declare interface BuildRouteConfiguration {
4
7
  path: string;
5
8
  methods: HttpMethod[];
@@ -93,8 +96,14 @@ declare interface CompatibilityFlags {
93
96
  useForwardRedirectsPropOnUrlForwardHandler: boolean;
94
97
  }
95
98
 
99
+ /**
100
+ * @public
101
+ */
96
102
  declare type CorsPolicy = string | "anything-goes" | "none";
97
103
 
104
+ /**
105
+ * @public
106
+ */
98
107
  declare interface CorsPolicyConfiguration {
99
108
  name: string;
100
109
  allowCredentials?: boolean;
@@ -107,20 +116,26 @@ declare interface CorsPolicyConfiguration {
107
116
 
108
117
  /* Excluded from this release type: DevPortalRuntimeConfig */
109
118
 
110
- export declare function getIdForParameterSchema(path: string, operation: string, type: string, name: string): string;
119
+ /* Excluded from this release type: getIdForParameterSchema */
111
120
 
112
- export declare function getIdForRefSchema(oasFileName: string, ref: string): string;
121
+ /* Excluded from this release type: getIdForRefSchema */
113
122
 
114
- export declare function getIdForRequestBodySchema(path: string, operation: string, contentType: string): string;
123
+ /* Excluded from this release type: getIdForRequestBodySchema */
115
124
 
116
- export declare function getRawOperationDataIdentifierName(oasFileName: string, path: string, operation: string): string;
125
+ /* Excluded from this release type: getRawOperationDataIdentifierName */
117
126
 
127
+ /**
128
+ * @public
129
+ */
118
130
  declare interface HandlerDefinition {
119
131
  module: any;
120
132
  export: string;
121
133
  options?: unknown;
122
134
  }
123
135
 
136
+ /**
137
+ * @public
138
+ */
124
139
  export declare type HttpMethod = "GET" | "HEAD" | "POST" | "PUT" | "DELETE" | "CONNECT" | "OPTIONS" | "TRACE" | "PATCH";
125
140
 
126
141
  /**
@@ -461,7 +476,7 @@ declare type HttpStatusCodeRangeDefinition = "1XX" | "2XX" | "3XX" | "4XX" | "5X
461
476
 
462
477
  /* Excluded from this release type: isRestrictedEnvVariableName */
463
478
 
464
- export declare function isZuploReadableEnvVariableName(name: string): boolean;
479
+ /* Excluded from this release type: isZuploReadableEnvVariableName */
465
480
 
466
481
  declare type Modify<T, R> = Omit<T, keyof R> & R;
467
482
 
@@ -928,20 +943,25 @@ declare namespace OpenAPIV3_1 {
928
943
  }
929
944
 
930
945
  /**
931
- * @beta
946
+ * Base object for parameter definitions
947
+ * @public
932
948
  */
933
949
  declare type ParameterBaseObject = Modify<Omit<OpenAPIV3_1.ParameterBaseObject, "content" | "allowEmptyValue" | "style" | "allowReserved" | "explode" | "example" | "examples">, {
934
950
  schema: OpenAPIV3_1.SchemaObject;
935
951
  }>;
936
952
 
937
953
  /**
938
- * @beta
954
+ * Definition of a parameter
955
+ * @public
939
956
  */
940
957
  declare interface ParameterDefinition extends ParameterBaseObject {
941
958
  name: string;
942
959
  in: string;
943
960
  }
944
961
 
962
+ /**
963
+ * @public
964
+ */
945
965
  declare interface PolicyConfiguration {
946
966
  name: string;
947
967
  policyType: string;
@@ -950,7 +970,8 @@ declare interface PolicyConfiguration {
950
970
  }
951
971
 
952
972
  /**
953
- * @beta
973
+ * Definition of responses for a route
974
+ * @public
954
975
  */
955
976
  export declare type ResponsesDefinition = Record<HttpStatusCode | HttpStatusCodeRangeDefinition, Modify<Omit<OpenAPIV3_1.ResponseObject, "links">, {
956
977
  headers?: {
@@ -958,6 +979,9 @@ export declare type ResponsesDefinition = Record<HttpStatusCode | HttpStatusCode
958
979
  };
959
980
  }>>;
960
981
 
982
+ /**
983
+ * @public
984
+ */
961
985
  export declare interface RouteConfiguration extends Omit<BuildRouteConfiguration, "raw"> {
962
986
  /**
963
987
  * @deprecated Please switch to "raw().operationId"
@@ -985,6 +1009,9 @@ export declare interface RouteConfiguration extends Omit<BuildRouteConfiguration
985
1009
  raw<T = any>(): T;
986
1010
  }
987
1011
 
1012
+ /**
1013
+ * @public
1014
+ */
988
1015
  export declare interface RouteData {
989
1016
  /**
990
1017
  * @deprecated This property is not used and will be removed in future versions
@@ -995,7 +1022,7 @@ export declare interface RouteData {
995
1022
  corsPolicies: CorsPolicyConfiguration[];
996
1023
  }
997
1024
 
998
- export declare function sanitizedIdentifierName(name: string): string;
1025
+ /* Excluded from this release type: sanitizedIdentifierName */
999
1026
 
1000
1027
  /* Excluded from this release type: StandardEnv */
1001
1028
 
@@ -1,3 +1,6 @@
1
+ /**
2
+ * @public
3
+ */
1
4
  declare interface BuildRouteConfiguration {
2
5
  path: string;
3
6
  methods: HttpMethod[];
@@ -39,11 +42,21 @@ declare interface BuildRouteConfiguration {
39
42
  /* Excluded from this release type: raw */
40
43
  }
41
44
 
42
- /** The 2-letter continent codes Cloudflare uses */
45
+ /**
46
+ * The 2-letter continent codes Cloudflare uses
47
+ * @public
48
+ */
43
49
  declare type ContinentCode = "AF" | "AN" | "AS" | "EU" | "NA" | "OC" | "SA";
44
50
 
51
+ /**
52
+ * @public
53
+ */
45
54
  declare type CorsPolicy = string | "anything-goes" | "none";
46
55
 
56
+ /**
57
+ * Creates a mock Zuplo context for testing
58
+ * @public
59
+ */
47
60
  export declare function createMockContext(options?: {
48
61
  request?: Request;
49
62
  route?: RouteConfiguration;
@@ -52,12 +65,18 @@ export declare function createMockContext(options?: {
52
65
  invokeResponse: () => Promise<void>;
53
66
  };
54
67
 
68
+ /**
69
+ * @public
70
+ */
55
71
  declare interface HandlerDefinition {
56
72
  module: any;
57
73
  export: string;
58
74
  options?: unknown;
59
75
  }
60
76
 
77
+ /**
78
+ * @public
79
+ */
61
80
  declare type HttpMethod = "GET" | "HEAD" | "POST" | "PUT" | "DELETE" | "CONNECT" | "OPTIONS" | "TRACE" | "PATCH";
62
81
 
63
82
  /**
@@ -396,6 +415,9 @@ declare enum HttpStatusCode {
396
415
 
397
416
  declare type HttpStatusCodeRangeDefinition = "1XX" | "2XX" | "3XX" | "4XX" | "5XX";
398
417
 
418
+ /**
419
+ * @public
420
+ */
399
421
  declare interface IncomingRequestProperties {
400
422
  /**
401
423
  * ASN of the incoming request, for example, 395747.
@@ -463,7 +485,10 @@ declare interface IncomingRequestProperties {
463
485
  readonly httpProtocol: string | undefined;
464
486
  }
465
487
 
466
- /** ISO 3166-1 Alpha-2 codes */
488
+ /**
489
+ * ISO 3166-1 Alpha-2 codes
490
+ * @public
491
+ */
467
492
  declare type Iso3166Alpha2Code = "AD" | "AE" | "AF" | "AG" | "AI" | "AL" | "AM" | "AO" | "AQ" | "AR" | "AS" | "AT" | "AU" | "AW" | "AX" | "AZ" | "BA" | "BB" | "BD" | "BE" | "BF" | "BG" | "BH" | "BI" | "BJ" | "BL" | "BM" | "BN" | "BO" | "BQ" | "BR" | "BS" | "BT" | "BV" | "BW" | "BY" | "BZ" | "CA" | "CC" | "CD" | "CF" | "CG" | "CH" | "CI" | "CK" | "CL" | "CM" | "CN" | "CO" | "CR" | "CU" | "CV" | "CW" | "CX" | "CY" | "CZ" | "DE" | "DJ" | "DK" | "DM" | "DO" | "DZ" | "EC" | "EE" | "EG" | "EH" | "ER" | "ES" | "ET" | "FI" | "FJ" | "FK" | "FM" | "FO" | "FR" | "GA" | "GB" | "GD" | "GE" | "GF" | "GG" | "GH" | "GI" | "GL" | "GM" | "GN" | "GP" | "GQ" | "GR" | "GS" | "GT" | "GU" | "GW" | "GY" | "HK" | "HM" | "HN" | "HR" | "HT" | "HU" | "ID" | "IE" | "IL" | "IM" | "IN" | "IO" | "IQ" | "IR" | "IS" | "IT" | "JE" | "JM" | "JO" | "JP" | "KE" | "KG" | "KH" | "KI" | "KM" | "KN" | "KP" | "KR" | "KW" | "KY" | "KZ" | "LA" | "LB" | "LC" | "LI" | "LK" | "LR" | "LS" | "LT" | "LU" | "LV" | "LY" | "MA" | "MC" | "MD" | "ME" | "MF" | "MG" | "MH" | "MK" | "ML" | "MM" | "MN" | "MO" | "MP" | "MQ" | "MR" | "MS" | "MT" | "MU" | "MV" | "MW" | "MX" | "MY" | "MZ" | "NA" | "NC" | "NE" | "NF" | "NG" | "NI" | "NL" | "NO" | "NP" | "NR" | "NU" | "NZ" | "OM" | "PA" | "PE" | "PF" | "PG" | "PH" | "PK" | "PL" | "PM" | "PN" | "PR" | "PS" | "PT" | "PW" | "PY" | "QA" | "RE" | "RO" | "RS" | "RU" | "RW" | "SA" | "SB" | "SC" | "SD" | "SE" | "SG" | "SH" | "SI" | "SJ" | "SK" | "SL" | "SM" | "SN" | "SO" | "SR" | "SS" | "ST" | "SV" | "SX" | "SY" | "SZ" | "TC" | "TD" | "TF" | "TG" | "TH" | "TJ" | "TK" | "TL" | "TM" | "TN" | "TO" | "TR" | "TT" | "TV" | "TW" | "TZ" | "UA" | "UG" | "UM" | "US" | "UY" | "UZ" | "VA" | "VC" | "VE" | "VG" | "VI" | "VN" | "VU" | "WF" | "WS" | "YE" | "YT" | "ZA" | "ZM" | "ZW";
468
493
 
469
494
  /**
@@ -477,6 +502,10 @@ declare interface Logger {
477
502
  error(...messages: unknown[]): void;
478
503
  }
479
504
 
505
+ /**
506
+ * Mock implementation of ZuploContext for testing
507
+ * @public
508
+ */
480
509
  export declare class MockZuploContext extends EventTarget implements ZuploContext {
481
510
  #private;
482
511
  readonly contextId: string;
@@ -985,14 +1014,16 @@ declare namespace OpenAPIV3_1 {
985
1014
  }
986
1015
 
987
1016
  /**
988
- * @beta
1017
+ * Base object for parameter definitions
1018
+ * @public
989
1019
  */
990
1020
  declare type ParameterBaseObject = Modify<Omit<OpenAPIV3_1.ParameterBaseObject, "content" | "allowEmptyValue" | "style" | "allowReserved" | "explode" | "example" | "examples">, {
991
1021
  schema: OpenAPIV3_1.SchemaObject;
992
1022
  }>;
993
1023
 
994
1024
  /**
995
- * @beta
1025
+ * Definition of a parameter
1026
+ * @public
996
1027
  */
997
1028
  declare interface ParameterDefinition extends ParameterBaseObject {
998
1029
  name: string;
@@ -1000,7 +1031,8 @@ declare interface ParameterDefinition extends ParameterBaseObject {
1000
1031
  }
1001
1032
 
1002
1033
  /**
1003
- * The types of the properties in a request
1034
+ * Generic type parameters for a request.
1035
+ * Extends RequestInitGeneric and adds query parameter typing.
1004
1036
  * @public
1005
1037
  */
1006
1038
  declare interface RequestGeneric extends RequestInitGeneric {
@@ -1008,7 +1040,8 @@ declare interface RequestGeneric extends RequestInitGeneric {
1008
1040
  }
1009
1041
 
1010
1042
  /**
1011
- * The types of the properties in a request init object
1043
+ * Generic type parameters for request initialization.
1044
+ * Used to strongly type the user data and path parameters.
1012
1045
  * @public
1013
1046
  */
1014
1047
  declare interface RequestInitGeneric {
@@ -1021,8 +1054,24 @@ declare type RequestParamsDefault = Record<string, string>;
1021
1054
  declare type RequestQueryDefault = Record<string, string>;
1022
1055
 
1023
1056
  /**
1024
- * The authorized identity on the incoming request
1057
+ * Represents an authenticated user on the request.
1058
+ * Set by authentication policies like API key, JWT, or OAuth.
1059
+ *
1025
1060
  * @public
1061
+ * @example
1062
+ * ```typescript
1063
+ * // Access user info in a handler
1064
+ * export function myHandler(request: ZuploRequest, context: ZuploContext) {
1065
+ * if (!request.user) {
1066
+ * return new Response("Unauthorized", { status: 401 });
1067
+ * }
1068
+ *
1069
+ * const userId = request.user.sub;
1070
+ * const customData = request.user.data as { role: string; tenantId: string };
1071
+ *
1072
+ * context.log.info(`Request from user ${userId} with role ${customData.role}`);
1073
+ * }
1074
+ * ```
1026
1075
  */
1027
1076
  declare interface RequestUser<TUserData> {
1028
1077
  sub: string;
@@ -1036,7 +1085,8 @@ declare type ResolveRequestQuery<TQuery extends RequestQueryDefault | undefined>
1036
1085
  declare type ResolveUserData<TUserData extends UserDataDefault | undefined> = TUserData extends UserDataDefault ? TUserData : UserDataDefault;
1037
1086
 
1038
1087
  /**
1039
- * @beta
1088
+ * Definition of responses for a route
1089
+ * @public
1040
1090
  */
1041
1091
  declare type ResponsesDefinition = Record<HttpStatusCode | HttpStatusCodeRangeDefinition, Modify<Omit<OpenAPIV3_1.ResponseObject, "links">, {
1042
1092
  headers?: {
@@ -1044,6 +1094,9 @@ declare type ResponsesDefinition = Record<HttpStatusCode | HttpStatusCodeRangeDe
1044
1094
  };
1045
1095
  }>>;
1046
1096
 
1097
+ /**
1098
+ * @public
1099
+ */
1047
1100
  declare interface RouteConfiguration extends Omit<BuildRouteConfiguration, "raw"> {
1048
1101
  /**
1049
1102
  * @deprecated Please switch to "raw().operationId"
@@ -1080,6 +1133,10 @@ declare interface WaitUntilFunc {
1080
1133
  (promise: Promise<any>): void;
1081
1134
  }
1082
1135
 
1136
+ /**
1137
+ * The ZuploContext provides information about the current request and helper methods.
1138
+ * @public
1139
+ */
1083
1140
  declare interface ZuploContext extends EventTarget {
1084
1141
  /**
1085
1142
  * The unique identifier of this context
@@ -1152,10 +1209,70 @@ declare interface ZuploContext extends EventTarget {
1152
1209
  /* Excluded from this release type: ZuploEventContext */
1153
1210
 
1154
1211
  /**
1155
- * ZuploRequest includes various parsed objects from the
1156
- * incoming Request. This object inherits from the web
1157
- * standard {@link https://developer.mozilla.org/en-US/docs/Web/API/Request | Request}.
1212
+ * Enhanced Request class that extends the standard Web Request API with
1213
+ * convenient properties for accessing path parameters, query strings, and user data.
1214
+ * This is the request type passed to all handlers and policies in Zuplo.
1215
+ *
1158
1216
  * @public
1217
+ * @example
1218
+ * ```typescript
1219
+ * import { ZuploRequest, ZuploContext } from "@zuplo/runtime";
1220
+ *
1221
+ * export function myHandler(request: ZuploRequest, context: ZuploContext) {
1222
+ * // Access query parameters
1223
+ * const page = request.query.page || "1";
1224
+ * const limit = request.query.limit || "10";
1225
+ *
1226
+ * // Access path parameters (e.g., from /users/:userId)
1227
+ * const userId = request.params.userId;
1228
+ *
1229
+ * // Access authenticated user
1230
+ * const user = request.user;
1231
+ *
1232
+ * // Standard Request properties still available
1233
+ * const contentType = request.headers.get("content-type");
1234
+ * const method = request.method;
1235
+ *
1236
+ * return Response.json({
1237
+ * userId,
1238
+ * page,
1239
+ * limit,
1240
+ * authenticated: !!user
1241
+ * });
1242
+ * }
1243
+ * ```
1244
+ *
1245
+ * @example
1246
+ * ```typescript
1247
+ * // Strongly typed request parameters
1248
+ * interface MyParams {
1249
+ * userId: string;
1250
+ * orderId: string;
1251
+ * }
1252
+ *
1253
+ * interface MyQuery {
1254
+ * include?: string;
1255
+ * format?: "json" | "xml";
1256
+ * }
1257
+ *
1258
+ * interface MyUserData {
1259
+ * role: "admin" | "user";
1260
+ * tenantId: string;
1261
+ * }
1262
+ *
1263
+ * type MyRequest = ZuploRequest<{
1264
+ * Params: MyParams;
1265
+ * Query: MyQuery;
1266
+ * UserData: MyUserData;
1267
+ * }>;
1268
+ *
1269
+ * export function typedHandler(request: MyRequest, context: ZuploContext) {
1270
+ * // All properties are now strongly typed
1271
+ * const userId = request.params.userId; // string
1272
+ * const format = request.query.format; // "json" | "xml" | undefined
1273
+ * const role = request.user?.data.role; // "admin" | "user" | undefined
1274
+ * }
1275
+ * ```
1159
1276
  */
1160
1277
  declare class ZuploRequest<TOptions extends RequestGeneric = RequestGeneric> extends Request {
1161
1278
  #private;
@@ -1208,7 +1325,8 @@ declare class ZuploRequest<TOptions extends RequestGeneric = RequestGeneric> ext
1208
1325
  }
1209
1326
 
1210
1327
  /**
1211
- * The initialization values of a request
1328
+ * Options for creating a new ZuploRequest.
1329
+ * Extends the standard RequestInit with Zuplo-specific properties.
1212
1330
  * @public
1213
1331
  */
1214
1332
  declare interface ZuploRequestInit<TOptions extends RequestInitGeneric = RequestInitGeneric> extends RequestInit {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@zuplo/runtime",
3
3
  "type": "module",
4
- "version": "6.52.3",
4
+ "version": "6.52.5",
5
5
  "repository": "https://github.com/zuplo/zuplo",
6
6
  "author": "Zuplo, Inc.",
7
7
  "exports": {