@zuplo/runtime 6.51.4 → 6.51.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.
@@ -22,4 +22,4 @@
22
22
  * DEALINGS IN THE SOFTWARE.
23
23
  *--------------------------------------------------------------------------------------------*/
24
24
 
25
- import{a as n}from"../chunk-PPV7V43C.js";function p(s={request:new Request("https://api.example.com")}){let e=[];function o(t){e.push(Promise.resolve(t))}return n(o,"waitUntil"),{context:new i({event:{waitUntil:o},route:s.route}),invokeResponse:n(async()=>{await Promise.all(e)},"invokeResponse")}}n(p,"createMockContext");var l={path:"/",methods:["GET"],handler:{module:{},export:"default"},raw:n(()=>({}),"raw")},i=class extends EventTarget{static{n(this,"MockZuploContext")}#e;requestId;log;route;custom;incomingRequestProperties;constructor({event:e,route:o=l}){super(),this.requestId=crypto.randomUUID(),this.log={info:console.info,log:console.log,debug:console.debug,warn:console.warn,error:console.error},this.custom={},this.route=o,this.incomingRequestProperties={asn:1234,asOrganization:"ORGANIZATION",city:"Seattle",region:"Washington",regionCode:"WA",colo:"SEA",continent:"NA",country:"US",postalCode:"98004",metroCode:"SEA",latitude:void 0,longitude:void 0,timezone:void 0,httpProtocol:void 0},this.#e=e}waitUntil(e){this.#e.waitUntil(e)}invokeInboundPolicy(e,o){throw new Error("Not implemented")}invokeOutboundPolicy(e,o,r){throw new Error("Not implemented")}addResponseSendingHook(e){throw new Error("Not implemented")}addResponseSendingFinalHook(e){throw new Error("Not implemented")}addEventListener(e,o,r){let u=n(t=>{try{typeof o=="function"?o(t):o.handleEvent(t)}catch(d){throw this.log.error(`Error invoking event ${e}. See following logs for details.`),d}},"wrapped");super.addEventListener(e,u,r)}};export{i as MockZuploContext,p as createMockContext};
25
+ import{a as t}from"../chunk-PPV7V43C.js";function l(s={request:new Request("https://api.example.com")}){let e=[];function o(r){e.push(Promise.resolve(r))}return t(o,"waitUntil"),{context:new i({event:{waitUntil:o},route:s.route}),invokeResponse:t(async()=>{await Promise.all(e)},"invokeResponse")}}t(l,"createMockContext");var p={path:"/",methods:["GET"],handler:{module:{},export:"default"},raw:t(()=>({}),"raw")},i=class extends EventTarget{static{t(this,"MockZuploContext")}#e;contextId;requestId;log;route;custom;incomingRequestProperties;parentContext;constructor({event:e,route:o=p,parentContext:n}){super(),this.requestId=crypto.randomUUID(),this.contextId=crypto.randomUUID(),this.log={info:console.info,log:console.log,debug:console.debug,warn:console.warn,error:console.error},this.custom={},this.route=o,this.incomingRequestProperties={asn:1234,asOrganization:"ORGANIZATION",city:"Seattle",region:"Washington",regionCode:"WA",colo:"SEA",continent:"NA",country:"US",postalCode:"98004",metroCode:"SEA",latitude:void 0,longitude:void 0,timezone:void 0,httpProtocol:void 0},this.parentContext=n,this.#e=e}waitUntil(e){this.#e.waitUntil(e)}invokeInboundPolicy(e,o){throw new Error("Not implemented")}invokeOutboundPolicy(e,o,n){throw new Error("Not implemented")}invokeRoute(e,o){throw new Error("Not implemented")}addResponseSendingHook(e){throw new Error("Not implemented")}addResponseSendingFinalHook(e){throw new Error("Not implemented")}addEventListener(e,o,n){let u=t(r=>{try{typeof o=="function"?o(r):o.handleEvent(r)}catch(d){throw this.log.error(`Error invoking event ${e}. See following logs for details.`),d}},"wrapped");super.addEventListener(e,u,n)}};export{i as MockZuploContext,l as createMockContext};
@@ -1868,6 +1868,10 @@ export declare interface HandlerDefinition {
1868
1868
  options?: unknown;
1869
1869
  }
1870
1870
 
1871
+ declare interface HandleRequestOptions {
1872
+ parentContext?: ZuploContext;
1873
+ }
1874
+
1871
1875
  /**
1872
1876
  * Request header authentication.
1873
1877
  */
@@ -3314,7 +3318,10 @@ declare interface MetricsData {
3314
3318
  statusCode: number;
3315
3319
  requestContentLength?: number;
3316
3320
  responseContentLength?: number;
3321
+ contextId: string;
3322
+ parentContextId?: string;
3317
3323
  requestId: string;
3324
+ parentRequestId?: string;
3318
3325
  routePath: string;
3319
3326
  systemRouteName?: string;
3320
3327
  method: HttpMethod;
@@ -4973,18 +4980,12 @@ export declare type ResponsesDefinition = Record<HttpStatusCode | HttpStatusCode
4973
4980
  };
4974
4981
  }>>;
4975
4982
 
4976
- /**
4977
- * @beta
4978
- */
4979
4983
  export declare class ResponseSendingEvent extends Event {
4980
4984
  constructor(request: ZuploRequest, response: Response);
4981
4985
  readonly request: ZuploRequest;
4982
4986
  mutableResponse: Response | Promise<Response>;
4983
4987
  }
4984
4988
 
4985
- /**
4986
- * @beta
4987
- */
4988
4989
  export declare class ResponseSentEvent extends Event {
4989
4990
  constructor(request: ZuploRequest, response: Response);
4990
4991
  readonly request: ZuploRequest;
@@ -6101,10 +6102,11 @@ export declare class ZoneCache<T = any> {
6101
6102
  logDebug(...messages: unknown[]): void;
6102
6103
  }
6103
6104
 
6104
- /**
6105
- * @beta
6106
- */
6107
6105
  export declare interface ZuploContext extends EventTarget {
6106
+ /**
6107
+ * The unique identifier of this context
6108
+ */
6109
+ readonly contextId: Readonly<string>;
6108
6110
  /**
6109
6111
  * The unique identifier of the incoming request
6110
6112
  */
@@ -6113,14 +6115,27 @@ export declare interface ZuploContext extends EventTarget {
6113
6115
  * Request based logger
6114
6116
  */
6115
6117
  readonly log: Readonly<Logger>;
6118
+ /**
6119
+ * The route that is being processed
6120
+ */
6116
6121
  readonly route: Readonly<RouteConfiguration>;
6117
6122
  /**
6118
6123
  * Custom data stored on the ZuploContext
6119
6124
  */
6120
6125
  readonly custom: Record<string, any>;
6121
6126
  readonly incomingRequestProperties: IncomingRequestProperties;
6127
+ /**
6128
+ * The parent context that spawned this context
6129
+ * @beta
6130
+ */
6131
+ readonly parentContext: ZuploContext | undefined;
6122
6132
  readonly invokeInboundPolicy: (policyName: string, request: ZuploRequest) => Promise<Response | ZuploRequest>;
6123
6133
  readonly invokeOutboundPolicy: (policyName: string, response: Response, request: ZuploRequest) => Promise<Response>;
6134
+ /**
6135
+ * Invokes a route based on a Request without going back out to HTTP
6136
+ * @beta
6137
+ */
6138
+ readonly invokeRoute: <TOptions extends RequestGeneric = RequestGeneric>(input: string | URL | Request, init?: ZuploRequestInit<TOptions>) => Promise<Response>;
6124
6139
  readonly waitUntil: WaitUntilFunc;
6125
6140
  /**
6126
6141
  * Fires just before the response is sent. Response can be modified.
@@ -6163,7 +6178,7 @@ export declare interface ZuploContext extends EventTarget {
6163
6178
  */
6164
6179
  export declare class ZuploRequest<TOptions extends RequestGeneric = RequestGeneric> extends Request {
6165
6180
  #private;
6166
- constructor(input: string | Request, init?: ZuploRequestInit<TOptions>);
6181
+ constructor(input: string | URL | Request, init?: ZuploRequestInit<TOptions>);
6167
6182
  /**
6168
6183
  * A dictionary of query-string values
6169
6184
  *
@@ -467,18 +467,22 @@ declare interface Logger {
467
467
 
468
468
  export declare class MockZuploContext extends EventTarget implements ZuploContext {
469
469
  #private;
470
+ readonly contextId: string;
470
471
  readonly requestId: string;
471
472
  readonly log: Logger;
472
473
  readonly route: RouteConfiguration;
473
474
  readonly custom: Record<string, any>;
474
475
  readonly incomingRequestProperties: IncomingRequestProperties;
475
- constructor({ event, route, }: {
476
+ readonly parentContext: ZuploContext | undefined;
477
+ constructor({ event, route, parentContext, }: {
476
478
  event: ZuploEventContext;
477
479
  route?: RouteConfiguration;
480
+ parentContext?: ZuploContext | undefined;
478
481
  });
479
482
  waitUntil(promise: Promise<any>): void;
480
483
  invokeInboundPolicy(policyName: string, request: ZuploRequest): Promise<ZuploRequest | Response>;
481
484
  invokeOutboundPolicy(policyName: string, response: Response, request: ZuploRequest): Promise<Response>;
485
+ invokeRoute<TOptions extends RequestGeneric = RequestGeneric>(input: string | URL | Request, init?: ZuploRequestInit<TOptions>): Promise<Response>;
482
486
  /**
483
487
  * Fires just before the response is sent. Response can be modified.
484
488
  */
@@ -1064,10 +1068,11 @@ declare interface WaitUntilFunc {
1064
1068
  (promise: Promise<any>): void;
1065
1069
  }
1066
1070
 
1067
- /**
1068
- * @beta
1069
- */
1070
1071
  declare interface ZuploContext extends EventTarget {
1072
+ /**
1073
+ * The unique identifier of this context
1074
+ */
1075
+ readonly contextId: Readonly<string>;
1071
1076
  /**
1072
1077
  * The unique identifier of the incoming request
1073
1078
  */
@@ -1076,14 +1081,27 @@ declare interface ZuploContext extends EventTarget {
1076
1081
  * Request based logger
1077
1082
  */
1078
1083
  readonly log: Readonly<Logger>;
1084
+ /**
1085
+ * The route that is being processed
1086
+ */
1079
1087
  readonly route: Readonly<RouteConfiguration>;
1080
1088
  /**
1081
1089
  * Custom data stored on the ZuploContext
1082
1090
  */
1083
1091
  readonly custom: Record<string, any>;
1084
1092
  readonly incomingRequestProperties: IncomingRequestProperties;
1093
+ /**
1094
+ * The parent context that spawned this context
1095
+ * @beta
1096
+ */
1097
+ readonly parentContext: ZuploContext | undefined;
1085
1098
  readonly invokeInboundPolicy: (policyName: string, request: ZuploRequest) => Promise<Response | ZuploRequest>;
1086
1099
  readonly invokeOutboundPolicy: (policyName: string, response: Response, request: ZuploRequest) => Promise<Response>;
1100
+ /**
1101
+ * Invokes a route based on a Request without going back out to HTTP
1102
+ * @beta
1103
+ */
1104
+ readonly invokeRoute: <TOptions extends RequestGeneric = RequestGeneric>(input: string | URL | Request, init?: ZuploRequestInit<TOptions>) => Promise<Response>;
1087
1105
  readonly waitUntil: WaitUntilFunc;
1088
1106
  /**
1089
1107
  * Fires just before the response is sent. Response can be modified.
@@ -1126,7 +1144,7 @@ declare interface ZuploContext extends EventTarget {
1126
1144
  */
1127
1145
  declare class ZuploRequest<TOptions extends RequestGeneric = RequestGeneric> extends Request {
1128
1146
  #private;
1129
- constructor(input: string | Request, init?: ZuploRequestInit<TOptions>);
1147
+ constructor(input: string | URL | Request, init?: ZuploRequestInit<TOptions>);
1130
1148
  /**
1131
1149
  * A dictionary of query-string values
1132
1150
  *
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@zuplo/runtime",
3
3
  "type": "module",
4
- "version": "6.51.4",
4
+ "version": "6.51.5",
5
5
  "repository": "https://github.com/zuplo/zuplo",
6
6
  "author": "Zuplo, Inc.",
7
7
  "exports": {