@zuplo/cli 7.11.3 → 7.11.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.
- package/node_modules/@zuplo/core/package.json +1 -1
- package/node_modules/@zuplo/graphql/out/esm/index.js +22 -22
- package/node_modules/@zuplo/graphql/out/esm/index.js.map +1 -1
- package/node_modules/@zuplo/graphql/out/types/index.d.ts +2 -1
- package/node_modules/@zuplo/graphql/package.json +1 -1
- package/node_modules/@zuplo/openapi-tools/package.json +1 -1
- package/node_modules/@zuplo/otel/package.json +1 -1
- package/node_modules/@zuplo/runtime/out/esm/chunk-5SHD5VGF.js +412 -0
- package/node_modules/@zuplo/runtime/out/esm/chunk-5SHD5VGF.js.map +1 -0
- package/node_modules/@zuplo/runtime/out/esm/index.js +1 -1
- package/node_modules/@zuplo/runtime/out/esm/index.js.map +1 -1
- package/node_modules/@zuplo/runtime/out/esm/mcp-gateway/index.js +1 -1
- package/node_modules/@zuplo/runtime/out/esm/mocks/index.js +1 -1
- package/node_modules/@zuplo/runtime/out/esm/mocks/index.js.map +1 -1
- package/node_modules/@zuplo/runtime/out/types/index.d.ts +112 -0
- package/node_modules/@zuplo/runtime/out/types/internal/index.d.ts +38 -0
- package/node_modules/@zuplo/runtime/out/types/mcp/messages/index.d.ts +38 -0
- package/node_modules/@zuplo/runtime/out/types/mcp-gateway/index.d.ts +38 -0
- package/node_modules/@zuplo/runtime/out/types/mocks/index.d.ts +38 -0
- package/node_modules/@zuplo/runtime/out/types/sdks/aws/index.d.ts +38 -0
- package/node_modules/@zuplo/runtime/package.json +1 -1
- package/node_modules/fast-copy/README.md +8 -1
- package/node_modules/fast-copy/dist/cjs/index.cjs +23 -3
- package/node_modules/fast-copy/dist/cjs/index.cjs.map +1 -1
- package/node_modules/fast-copy/dist/es/index.mjs +23 -3
- package/node_modules/fast-copy/dist/es/index.mjs.map +1 -1
- package/node_modules/fast-copy/dist/umd/index.js +23 -3
- package/node_modules/fast-copy/dist/umd/index.js.map +1 -1
- package/node_modules/fast-copy/package.json +1 -1
- package/package.json +11 -11
- package/node_modules/@zuplo/runtime/out/esm/chunk-TPYCFLC7.js +0 -412
- package/node_modules/@zuplo/runtime/out/esm/chunk-TPYCFLC7.js.map +0 -1
- /package/node_modules/@zuplo/runtime/out/esm/{chunk-TPYCFLC7.js.LEGAL.txt → chunk-5SHD5VGF.js.LEGAL.txt} +0 -0
|
@@ -22,5 +22,5 @@
|
|
|
22
22
|
* DEALINGS IN THE SOFTWARE.
|
|
23
23
|
*--------------------------------------------------------------------------------------------*/
|
|
24
24
|
|
|
25
|
-
import{E as p,J as c,M as u}from"../chunk-
|
|
25
|
+
import{E as p,J as c,M as u}from"../chunk-5SHD5VGF.js";import"../chunk-NUVXDVLJ.js";import{a as d}from"../chunk-QGAJTUPE.js";import"../chunk-A3QGJZO7.js";import"../chunk-CDEAY3VY.js";import{aa as i}from"../chunk-LVSZ3WTO.js";import{a as o}from"../chunk-TYV53J3B.js";function w(l={request:new Request("https://api.example.com")}){let e=[];function t(s){e.push(Promise.resolve(s))}return o(t,"waitUntil"),{context:new a({event:{waitUntil:t},route:l.route,originalRequest:l.request}),invokeResponse:o(async()=>{await Promise.all(e)},"invokeResponse")}}o(w,"createMockContext");var g={path:"/",methods:["GET"],handler:{module:{},export:"default"},raw:o(()=>({}),"raw")},a=class extends EventTarget{static{o(this,"MockZuploContext")}#e;#t;contextId;requestId;log;route;custom;incomingRequestProperties;parentContext;analyticsContext;constructor({event:e,route:t=g,parentContext:n,originalRequest:r}){super(),this.requestId=crypto.randomUUID(),this.contextId=crypto.randomUUID(),this.log={info:i.console.info,log:i.console.log,debug:i.console.debug,warn:i.console.warn,error:i.console.error,setLogProperties:o(()=>{},"setLogProperties"),setRequestProperties:o(()=>{},"setRequestProperties")},this.custom={},this.route=t,this.incomingRequestProperties={ip:"203.0.113.7",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,clientCert:void 0,clientMtlsVerificationStatus:void 0,clientMtlsVerificationReason:void 0,clientCertFingerprintSha256:void 0,clientCertNotBefore:void 0,clientCertNotAfter:void 0,clientCertIssuerDn:void 0,clientCertSubjectDn:void 0},this.parentContext=n,this.#e=e,this.#t=r,this.analyticsContext=new c(this.requestId)}waitUntil(e){this.#e.waitUntil(e)}invokeInboundPolicy(e,t){throw new Error("Not implemented")}invokeOutboundPolicy(e,t,n){throw new Error("Not implemented")}invokeRoute(e,t){throw new Error("Not implemented")}addResponseSendingHook(e){throw new Error("Not implemented")}addResponseSendingFinalHook(e){throw new Error("Not implemented")}addPreRequestHandler(e,t){let n;try{n=u.getContextExtensions(this)}catch{n=u.initialize(this,new d(this.#t??new Request("https://api.example.com")))}n.preRequestPhase??="active",p(this,n,e,t)}get preRequestHandlers(){let e;try{e=u.getContextExtensions(this)}catch{return[]}return(e.preRequestState?.entries??[]).map(t=>({policyName:t.policyName,name:t.name}))}addEventListener(e,t,n){let r=o(s=>{try{typeof t=="function"?t(s):t.handleEvent(s)}catch(m){throw this.log.error(`Error invoking event ${e}. See following logs for details.`),m}},"wrapped");super.addEventListener(e,r,n)}};export{a as MockZuploContext,w as createMockContext};
|
|
26
26
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@zuplo/runtime/mocks/context.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;0QAkCO,SAASA,EACdC,EAA6D,CAC3D,QAAS,IAAI,QAAQ,yBAAyB,CAChD,EACA,CACA,IAAMC,EAAwC,CAAC,EAG/C,SAASC,EAAUC,EAA6B,CAC9CF,EAAkB,KAAK,QAAQ,QAAQE,CAAO,CAAC,CACjD,CAFS,OAAAC,EAAAF,EAAA,aAcF,CAAE,QAVO,IAAIG,EAAiB,CACnC,MAAO,CAAE,UAAAH,CAAU,EACnB,MAA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BACEY,EACAC,EACkC,CAClC,MAAM,IAAI,MAAM,iBAAiB,CACnC,CAEA,qBACED,EACAE,EACAD,EACmB,CACnB,MAAM,IAAI,MAAM,iBAAiB,CACnC,CAEA,YACEE,EACAC,EACmB,CACnB,MAAM,IAAI,MAAM,iBAAiB,CACnC,CAKA,uBAAuBC,EAAmC,CACxD,MAAM,IAAI,MAAM,iBAAiB,CACnC,CAKA,4BAA4BA,EAAwC,CAClE,MAAM,IAAI,MAAM,iBAAiB,CACnC,CAQA,qBACEC,EACArB,EACM,CAIN,IAAIsB,EACJ,GAAI,CACFA,EAAMC,EAAuB,qBAAqB,IAAI,CACxD,MAAQ,CACND,EAAMC,EAAuB,WAC3B,KACA,IAAIC,EACF,KAAKhB,IAAoB,IAAI,QAAQ,yBAAyB,CAChE,CACF,CACF,CAKAc,EAAI,kBAAoB,SACxBG,EAA0B,KAAMH,EAAKD,EAASrB,CAAO,CACvD,CAgBA,IAAI,oBAAyE,CAC3E,IAAIsB,EACJ,GAAI,CACFA,EAAMC,EAAuB,qBAAqB,IAAI,CACxD,MAAQ,CACN,MAAO,CAAC,CACV,CACA,OAAQD,EAAI,iBAAiB,SAAW,CAAC,GAAG,IAAKI,IAAW,CAC1D,WAAYA,EAAM,WAClB,KAAMA,EAAM,IACd,EAAE,CACJ,CAES,iBACPC,EACAN,EACArB,EACM,CACN,IAAM4B,EAA8CxB,EAACyB,GAAM,CACzD,GAAI,CACF,OAAOR,GAAY,WAAaA,EAAQQ,CAAC,EAAIR,EAAQ,YAAYQ,CAAC,CACpE,OAASC,EAAK,CACZ,WAAK,IAAI,MACP,wBAAwBH,CAAI,mCAC9B,EACMG,CACR,CACF,EAToD,WAUpD,MAAM,iBAAiBH,EAAMC,EAAS5B,CAAO,CAC/C,CACF","names":["createMockContext","options","waitUntilPromises","waitUntil","promise","__name","MockZuploContext","DEFAULT_ROUTE_CONFIG","#event","#originalRequest","event","route","parentContext","originalRequest","internals_default","ZuploGatewayAnalyticsContext","policyName","request","response","input","init","hook","handler","ext","ZuploContextExtensions","ZuploRequest","registerPreRequestHandler","entry","type","wrapped","e","err"]}
|
|
@@ -3297,6 +3297,8 @@ export declare interface BrownoutInboundPolicyOptions {
|
|
|
3297
3297
|
};
|
|
3298
3298
|
}
|
|
3299
3299
|
|
|
3300
|
+
/* Excluded from this release type: buildCacheOperationBase */
|
|
3301
|
+
|
|
3300
3302
|
/* Excluded from this release type: BuildEnvironment */
|
|
3301
3303
|
|
|
3302
3304
|
/**
|
|
@@ -3349,6 +3351,62 @@ declare interface BuildRouteConfiguration {
|
|
|
3349
3351
|
*/
|
|
3350
3352
|
declare type CacheNamespace = string;
|
|
3351
3353
|
|
|
3354
|
+
/**
|
|
3355
|
+
* The shared per-request dimensions every `cache_operation` event from a
|
|
3356
|
+
* policy carries; outcome-specific fields are added at each emission site.
|
|
3357
|
+
*/
|
|
3358
|
+
declare type CacheOperationBase = Pick<
|
|
3359
|
+
CacheOperationParams,
|
|
3360
|
+
| "cacheType"
|
|
3361
|
+
| "policyType"
|
|
3362
|
+
| "policyName"
|
|
3363
|
+
| "configId"
|
|
3364
|
+
| "consumerSub"
|
|
3365
|
+
| "routePath"
|
|
3366
|
+
| "method"
|
|
3367
|
+
>;
|
|
3368
|
+
|
|
3369
|
+
/** The kind of cache a `cache_operation` event describes. */
|
|
3370
|
+
declare type CacheOperationCacheType = "semantic" | "http";
|
|
3371
|
+
|
|
3372
|
+
/**
|
|
3373
|
+
* The outcome of a single cache lookup or write attempt:
|
|
3374
|
+
* - `hit` / `miss`: lookup outcomes.
|
|
3375
|
+
* - `store`: a write-back stored the response.
|
|
3376
|
+
* - `not_stored`: a write-back declined to store (see `reason`).
|
|
3377
|
+
* - `skip`: the lookup never ran (uncacheable shape, missing identity, ...).
|
|
3378
|
+
* - `error`: the lookup or store failed (see `reason`).
|
|
3379
|
+
*/
|
|
3380
|
+
declare type CacheOperationOutcome =
|
|
3381
|
+
| "hit"
|
|
3382
|
+
| "miss"
|
|
3383
|
+
| "store"
|
|
3384
|
+
| "skip"
|
|
3385
|
+
| "error"
|
|
3386
|
+
| "not_stored";
|
|
3387
|
+
|
|
3388
|
+
/**
|
|
3389
|
+
* Emitter-facing params for a `cache_operation` event. Everything the emitter
|
|
3390
|
+
* doesn't know may be omitted; {@link buildCacheOperationMetadata} normalizes
|
|
3391
|
+
* omissions to explicit `null`s so every event carries the full contract.
|
|
3392
|
+
*/
|
|
3393
|
+
declare interface CacheOperationParams {
|
|
3394
|
+
cacheType: CacheOperationCacheType;
|
|
3395
|
+
policyType: string;
|
|
3396
|
+
policyName: string;
|
|
3397
|
+
outcome: CacheOperationOutcome;
|
|
3398
|
+
reason?: string | null;
|
|
3399
|
+
latencyMs?: number | null;
|
|
3400
|
+
similarity?: number | null;
|
|
3401
|
+
configId?: string | null;
|
|
3402
|
+
consumerSub?: string | null;
|
|
3403
|
+
routePath?: string | null;
|
|
3404
|
+
method?: string | null;
|
|
3405
|
+
statusCode?: number | null;
|
|
3406
|
+
savedPromptTokens?: number | null;
|
|
3407
|
+
savedCompletionTokens?: number | null;
|
|
3408
|
+
}
|
|
3409
|
+
|
|
3352
3410
|
/**
|
|
3353
3411
|
* Internal
|
|
3354
3412
|
*/
|
|
@@ -5418,6 +5476,10 @@ declare type EmbeddingsOverride =
|
|
|
5418
5476
|
default: DefaultModel1;
|
|
5419
5477
|
};
|
|
5420
5478
|
|
|
5479
|
+
/* Excluded from this release type: emitCacheOperation */
|
|
5480
|
+
|
|
5481
|
+
/* Excluded from this release type: emitCacheOperationLate */
|
|
5482
|
+
|
|
5421
5483
|
/**
|
|
5422
5484
|
* Enable accumulation and validation of streaming responses.
|
|
5423
5485
|
* @public
|
|
@@ -8596,6 +8658,44 @@ export declare interface Logger extends SystemLogger {
|
|
|
8596
8658
|
setLogProperties?(
|
|
8597
8659
|
properties: Record<string, string | number | boolean>
|
|
8598
8660
|
): void;
|
|
8661
|
+
/**
|
|
8662
|
+
* Attach properties to this request's row in Zuplo's request log, the one
|
|
8663
|
+
* row per request that analytics and the request details view read.
|
|
8664
|
+
*
|
|
8665
|
+
* This differs from `setLogProperties`, which adds fields to every log
|
|
8666
|
+
* entry (each `context.log.info(...)` line) that log plugins ship. Use
|
|
8667
|
+
* `setRequestProperties` to label the request itself, for example with a
|
|
8668
|
+
* tenant ID, a feature flag or an experiment variant.
|
|
8669
|
+
*
|
|
8670
|
+
* Each call merges into the properties already set for this request, and a
|
|
8671
|
+
* later value for the same key overwrites an earlier one. Numbers and
|
|
8672
|
+
* booleans are stored as strings, and `null` or `undefined` values are
|
|
8673
|
+
* skipped. A request made with `context.invokeRoute` has a row of its own,
|
|
8674
|
+
* so properties set while it runs land on that row, not on the caller's.
|
|
8675
|
+
*
|
|
8676
|
+
* To keep rows small, a request holds at most 64 properties, a key can be
|
|
8677
|
+
* at most 128 characters, and a value at most 2048 characters. A longer
|
|
8678
|
+
* value is truncated, and a property over the other limits is dropped. The
|
|
8679
|
+
* method never throws.
|
|
8680
|
+
*
|
|
8681
|
+
* @param properties - Key-value pairs to attach to the request's log row.
|
|
8682
|
+
*
|
|
8683
|
+
* @example
|
|
8684
|
+
* ```ts
|
|
8685
|
+
* export default async function (request: ZuploRequest, context: ZuploContext) {
|
|
8686
|
+
* context.log.setRequestProperties({
|
|
8687
|
+
* tenantId: request.user?.data.tenantId,
|
|
8688
|
+
* pricingExperiment: "variant-b",
|
|
8689
|
+
* cached: false,
|
|
8690
|
+
* });
|
|
8691
|
+
*
|
|
8692
|
+
* return new Response("ok");
|
|
8693
|
+
* }
|
|
8694
|
+
* ```
|
|
8695
|
+
*/
|
|
8696
|
+
setRequestProperties(
|
|
8697
|
+
properties: Record<string, string | number | boolean | undefined | null>
|
|
8698
|
+
): void;
|
|
8599
8699
|
}
|
|
8600
8700
|
|
|
8601
8701
|
/* Excluded from this release type: LoggingContext */
|
|
@@ -10683,6 +10783,18 @@ declare interface MetricsData {
|
|
|
10683
10783
|
parentContextId?: string;
|
|
10684
10784
|
requestId: string;
|
|
10685
10785
|
parentRequestId?: string;
|
|
10786
|
+
/**
|
|
10787
|
+
* The full URL, query string included, of the request as the gateway
|
|
10788
|
+
* received it for this route invocation. For a request made with
|
|
10789
|
+
* `context.invokeRoute` this is the invoked URL, for example
|
|
10790
|
+
* `http://localhost/some/path`.
|
|
10791
|
+
*/
|
|
10792
|
+
url?: string;
|
|
10793
|
+
/**
|
|
10794
|
+
* Free-form properties attached with `context.log.setRequestProperties`.
|
|
10795
|
+
* Omitted when none were set.
|
|
10796
|
+
*/
|
|
10797
|
+
properties?: Record<string, string>;
|
|
10686
10798
|
routePath: string;
|
|
10687
10799
|
systemRouteName?: string;
|
|
10688
10800
|
method: HttpMethod;
|
|
@@ -1058,6 +1058,44 @@ declare interface Logger extends BaseLogger {
|
|
|
1058
1058
|
setLogProperties?(
|
|
1059
1059
|
properties: Record<string, string | number | boolean>
|
|
1060
1060
|
): void;
|
|
1061
|
+
/**
|
|
1062
|
+
* Attach properties to this request's row in Zuplo's request log, the one
|
|
1063
|
+
* row per request that analytics and the request details view read.
|
|
1064
|
+
*
|
|
1065
|
+
* This differs from `setLogProperties`, which adds fields to every log
|
|
1066
|
+
* entry (each `context.log.info(...)` line) that log plugins ship. Use
|
|
1067
|
+
* `setRequestProperties` to label the request itself, for example with a
|
|
1068
|
+
* tenant ID, a feature flag or an experiment variant.
|
|
1069
|
+
*
|
|
1070
|
+
* Each call merges into the properties already set for this request, and a
|
|
1071
|
+
* later value for the same key overwrites an earlier one. Numbers and
|
|
1072
|
+
* booleans are stored as strings, and `null` or `undefined` values are
|
|
1073
|
+
* skipped. A request made with `context.invokeRoute` has a row of its own,
|
|
1074
|
+
* so properties set while it runs land on that row, not on the caller's.
|
|
1075
|
+
*
|
|
1076
|
+
* To keep rows small, a request holds at most 64 properties, a key can be
|
|
1077
|
+
* at most 128 characters, and a value at most 2048 characters. A longer
|
|
1078
|
+
* value is truncated, and a property over the other limits is dropped. The
|
|
1079
|
+
* method never throws.
|
|
1080
|
+
*
|
|
1081
|
+
* @param properties - Key-value pairs to attach to the request's log row.
|
|
1082
|
+
*
|
|
1083
|
+
* @example
|
|
1084
|
+
* ```ts
|
|
1085
|
+
* export default async function (request: ZuploRequest, context: ZuploContext) {
|
|
1086
|
+
* context.log.setRequestProperties({
|
|
1087
|
+
* tenantId: request.user?.data.tenantId,
|
|
1088
|
+
* pricingExperiment: "variant-b",
|
|
1089
|
+
* cached: false,
|
|
1090
|
+
* });
|
|
1091
|
+
*
|
|
1092
|
+
* return new Response("ok");
|
|
1093
|
+
* }
|
|
1094
|
+
* ```
|
|
1095
|
+
*/
|
|
1096
|
+
setRequestProperties(
|
|
1097
|
+
properties: Record<string, string | number | boolean | undefined | null>
|
|
1098
|
+
): void;
|
|
1061
1099
|
}
|
|
1062
1100
|
|
|
1063
1101
|
declare type Modify<T, R> = Omit<T, keyof R> & R;
|
|
@@ -986,6 +986,44 @@ declare interface Logger extends BaseLogger {
|
|
|
986
986
|
setLogProperties?(
|
|
987
987
|
properties: Record<string, string | number | boolean>
|
|
988
988
|
): void;
|
|
989
|
+
/**
|
|
990
|
+
* Attach properties to this request's row in Zuplo's request log, the one
|
|
991
|
+
* row per request that analytics and the request details view read.
|
|
992
|
+
*
|
|
993
|
+
* This differs from `setLogProperties`, which adds fields to every log
|
|
994
|
+
* entry (each `context.log.info(...)` line) that log plugins ship. Use
|
|
995
|
+
* `setRequestProperties` to label the request itself, for example with a
|
|
996
|
+
* tenant ID, a feature flag or an experiment variant.
|
|
997
|
+
*
|
|
998
|
+
* Each call merges into the properties already set for this request, and a
|
|
999
|
+
* later value for the same key overwrites an earlier one. Numbers and
|
|
1000
|
+
* booleans are stored as strings, and `null` or `undefined` values are
|
|
1001
|
+
* skipped. A request made with `context.invokeRoute` has a row of its own,
|
|
1002
|
+
* so properties set while it runs land on that row, not on the caller's.
|
|
1003
|
+
*
|
|
1004
|
+
* To keep rows small, a request holds at most 64 properties, a key can be
|
|
1005
|
+
* at most 128 characters, and a value at most 2048 characters. A longer
|
|
1006
|
+
* value is truncated, and a property over the other limits is dropped. The
|
|
1007
|
+
* method never throws.
|
|
1008
|
+
*
|
|
1009
|
+
* @param properties - Key-value pairs to attach to the request's log row.
|
|
1010
|
+
*
|
|
1011
|
+
* @example
|
|
1012
|
+
* ```ts
|
|
1013
|
+
* export default async function (request: ZuploRequest, context: ZuploContext) {
|
|
1014
|
+
* context.log.setRequestProperties({
|
|
1015
|
+
* tenantId: request.user?.data.tenantId,
|
|
1016
|
+
* pricingExperiment: "variant-b",
|
|
1017
|
+
* cached: false,
|
|
1018
|
+
* });
|
|
1019
|
+
*
|
|
1020
|
+
* return new Response("ok");
|
|
1021
|
+
* }
|
|
1022
|
+
* ```
|
|
1023
|
+
*/
|
|
1024
|
+
setRequestProperties(
|
|
1025
|
+
properties: Record<string, string | number | boolean | undefined | null>
|
|
1026
|
+
): void;
|
|
989
1027
|
}
|
|
990
1028
|
|
|
991
1029
|
/**
|
|
@@ -1114,6 +1114,44 @@ declare interface Logger extends BaseLogger {
|
|
|
1114
1114
|
setLogProperties?(
|
|
1115
1115
|
properties: Record<string, string | number | boolean>
|
|
1116
1116
|
): void;
|
|
1117
|
+
/**
|
|
1118
|
+
* Attach properties to this request's row in Zuplo's request log, the one
|
|
1119
|
+
* row per request that analytics and the request details view read.
|
|
1120
|
+
*
|
|
1121
|
+
* This differs from `setLogProperties`, which adds fields to every log
|
|
1122
|
+
* entry (each `context.log.info(...)` line) that log plugins ship. Use
|
|
1123
|
+
* `setRequestProperties` to label the request itself, for example with a
|
|
1124
|
+
* tenant ID, a feature flag or an experiment variant.
|
|
1125
|
+
*
|
|
1126
|
+
* Each call merges into the properties already set for this request, and a
|
|
1127
|
+
* later value for the same key overwrites an earlier one. Numbers and
|
|
1128
|
+
* booleans are stored as strings, and `null` or `undefined` values are
|
|
1129
|
+
* skipped. A request made with `context.invokeRoute` has a row of its own,
|
|
1130
|
+
* so properties set while it runs land on that row, not on the caller's.
|
|
1131
|
+
*
|
|
1132
|
+
* To keep rows small, a request holds at most 64 properties, a key can be
|
|
1133
|
+
* at most 128 characters, and a value at most 2048 characters. A longer
|
|
1134
|
+
* value is truncated, and a property over the other limits is dropped. The
|
|
1135
|
+
* method never throws.
|
|
1136
|
+
*
|
|
1137
|
+
* @param properties - Key-value pairs to attach to the request's log row.
|
|
1138
|
+
*
|
|
1139
|
+
* @example
|
|
1140
|
+
* ```ts
|
|
1141
|
+
* export default async function (request: ZuploRequest, context: ZuploContext) {
|
|
1142
|
+
* context.log.setRequestProperties({
|
|
1143
|
+
* tenantId: request.user?.data.tenantId,
|
|
1144
|
+
* pricingExperiment: "variant-b",
|
|
1145
|
+
* cached: false,
|
|
1146
|
+
* });
|
|
1147
|
+
*
|
|
1148
|
+
* return new Response("ok");
|
|
1149
|
+
* }
|
|
1150
|
+
* ```
|
|
1151
|
+
*/
|
|
1152
|
+
setRequestProperties(
|
|
1153
|
+
properties: Record<string, string | number | boolean | undefined | null>
|
|
1154
|
+
): void;
|
|
1117
1155
|
}
|
|
1118
1156
|
|
|
1119
1157
|
/* Excluded from this release type: LookupResult */
|
|
@@ -893,6 +893,44 @@ declare interface Logger extends BaseLogger {
|
|
|
893
893
|
setLogProperties?(
|
|
894
894
|
properties: Record<string, string | number | boolean>
|
|
895
895
|
): void;
|
|
896
|
+
/**
|
|
897
|
+
* Attach properties to this request's row in Zuplo's request log, the one
|
|
898
|
+
* row per request that analytics and the request details view read.
|
|
899
|
+
*
|
|
900
|
+
* This differs from `setLogProperties`, which adds fields to every log
|
|
901
|
+
* entry (each `context.log.info(...)` line) that log plugins ship. Use
|
|
902
|
+
* `setRequestProperties` to label the request itself, for example with a
|
|
903
|
+
* tenant ID, a feature flag or an experiment variant.
|
|
904
|
+
*
|
|
905
|
+
* Each call merges into the properties already set for this request, and a
|
|
906
|
+
* later value for the same key overwrites an earlier one. Numbers and
|
|
907
|
+
* booleans are stored as strings, and `null` or `undefined` values are
|
|
908
|
+
* skipped. A request made with `context.invokeRoute` has a row of its own,
|
|
909
|
+
* so properties set while it runs land on that row, not on the caller's.
|
|
910
|
+
*
|
|
911
|
+
* To keep rows small, a request holds at most 64 properties, a key can be
|
|
912
|
+
* at most 128 characters, and a value at most 2048 characters. A longer
|
|
913
|
+
* value is truncated, and a property over the other limits is dropped. The
|
|
914
|
+
* method never throws.
|
|
915
|
+
*
|
|
916
|
+
* @param properties - Key-value pairs to attach to the request's log row.
|
|
917
|
+
*
|
|
918
|
+
* @example
|
|
919
|
+
* ```ts
|
|
920
|
+
* export default async function (request: ZuploRequest, context: ZuploContext) {
|
|
921
|
+
* context.log.setRequestProperties({
|
|
922
|
+
* tenantId: request.user?.data.tenantId,
|
|
923
|
+
* pricingExperiment: "variant-b",
|
|
924
|
+
* cached: false,
|
|
925
|
+
* });
|
|
926
|
+
*
|
|
927
|
+
* return new Response("ok");
|
|
928
|
+
* }
|
|
929
|
+
* ```
|
|
930
|
+
*/
|
|
931
|
+
setRequestProperties(
|
|
932
|
+
properties: Record<string, string | number | boolean | undefined | null>
|
|
933
|
+
): void;
|
|
896
934
|
}
|
|
897
935
|
|
|
898
936
|
/**
|
|
@@ -1270,6 +1270,44 @@ declare interface Logger extends BaseLogger {
|
|
|
1270
1270
|
setLogProperties?(
|
|
1271
1271
|
properties: Record<string, string | number | boolean>
|
|
1272
1272
|
): void;
|
|
1273
|
+
/**
|
|
1274
|
+
* Attach properties to this request's row in Zuplo's request log, the one
|
|
1275
|
+
* row per request that analytics and the request details view read.
|
|
1276
|
+
*
|
|
1277
|
+
* This differs from `setLogProperties`, which adds fields to every log
|
|
1278
|
+
* entry (each `context.log.info(...)` line) that log plugins ship. Use
|
|
1279
|
+
* `setRequestProperties` to label the request itself, for example with a
|
|
1280
|
+
* tenant ID, a feature flag or an experiment variant.
|
|
1281
|
+
*
|
|
1282
|
+
* Each call merges into the properties already set for this request, and a
|
|
1283
|
+
* later value for the same key overwrites an earlier one. Numbers and
|
|
1284
|
+
* booleans are stored as strings, and `null` or `undefined` values are
|
|
1285
|
+
* skipped. A request made with `context.invokeRoute` has a row of its own,
|
|
1286
|
+
* so properties set while it runs land on that row, not on the caller's.
|
|
1287
|
+
*
|
|
1288
|
+
* To keep rows small, a request holds at most 64 properties, a key can be
|
|
1289
|
+
* at most 128 characters, and a value at most 2048 characters. A longer
|
|
1290
|
+
* value is truncated, and a property over the other limits is dropped. The
|
|
1291
|
+
* method never throws.
|
|
1292
|
+
*
|
|
1293
|
+
* @param properties - Key-value pairs to attach to the request's log row.
|
|
1294
|
+
*
|
|
1295
|
+
* @example
|
|
1296
|
+
* ```ts
|
|
1297
|
+
* export default async function (request: ZuploRequest, context: ZuploContext) {
|
|
1298
|
+
* context.log.setRequestProperties({
|
|
1299
|
+
* tenantId: request.user?.data.tenantId,
|
|
1300
|
+
* pricingExperiment: "variant-b",
|
|
1301
|
+
* cached: false,
|
|
1302
|
+
* });
|
|
1303
|
+
*
|
|
1304
|
+
* return new Response("ok");
|
|
1305
|
+
* }
|
|
1306
|
+
* ```
|
|
1307
|
+
*/
|
|
1308
|
+
setRequestProperties(
|
|
1309
|
+
properties: Record<string, string | number | boolean | undefined | null>
|
|
1310
|
+
): void;
|
|
1273
1311
|
}
|
|
1274
1312
|
|
|
1275
1313
|
declare type Modify<T, R> = Omit<T, keyof R> & R;
|
|
@@ -27,6 +27,7 @@ A [blazing fast](#benchmarks) deep object copier
|
|
|
27
27
|
- [Aspects of default copiers](#aspects-of-default-copiers)
|
|
28
28
|
- [Error references are copied directly, instead of creating a new `*Error` object](#error-references-are-copied-directly-instead-of-creating-a-new-error-object)
|
|
29
29
|
- [The constructor of the original object is used, instead of using known globals](#the-constructor-of-the-original-object-is-used-instead-of-using-known-globals)
|
|
30
|
+
- [Sparse arrays are copied densely, unless using `copyStrict`](#sparse-arrays-are-copied-densely-unless-using-copystrict)
|
|
30
31
|
- [Benchmarks](#benchmarks)
|
|
31
32
|
- [Simple objects](#simple-objects)
|
|
32
33
|
- [Complex objects](#complex-objects)
|
|
@@ -72,7 +73,8 @@ Deeply copy the object passed, but with additional strictness when replicating t
|
|
|
72
73
|
|
|
73
74
|
- Properties retain their original property descriptor
|
|
74
75
|
- Non-enumerable keys are copied
|
|
75
|
-
- Non-standard properties (e.g., keys on arrays / maps / sets) are copied
|
|
76
|
+
- Non-standard properties (e.g., keys on arrays / dates / maps / sets) are copied
|
|
77
|
+
- Holes in sparse arrays are preserved
|
|
76
78
|
|
|
77
79
|
```js
|
|
78
80
|
import { copyStrict } from 'fast-copy';
|
|
@@ -353,6 +355,11 @@ constructor of the original object. However, the expectation is that these subcl
|
|
|
353
355
|
signature as their native base class. This is a common community practice, but there is the possibility of inaccuracy if
|
|
354
356
|
the contract differs.
|
|
355
357
|
|
|
358
|
+
### Sparse arrays are copied densely, unless using `copyStrict`
|
|
359
|
+
|
|
360
|
+
For performance, [`copy`](#copy) copies every index up to `length`, so holes in sparse arrays become explicit
|
|
361
|
+
`undefined` values (e.g., `copy([, 1])` has the key `0`). [`copyStrict`](#copystrict) preserves holes.
|
|
362
|
+
|
|
356
363
|
## Benchmarks
|
|
357
364
|
|
|
358
365
|
#### Simple objects
|
|
@@ -29,7 +29,8 @@ function getCleanClone(prototype) {
|
|
|
29
29
|
if (Constructor === Object) {
|
|
30
30
|
return prototype === Object.prototype ? {} : Object.create(prototype);
|
|
31
31
|
}
|
|
32
|
-
|
|
32
|
+
// 2026-10-10: Prototype constructor properties may contain ordinary data.
|
|
33
|
+
if (typeof Constructor === 'function' && ~toStringFunction.call(Constructor).indexOf('[native code]')) {
|
|
33
34
|
try {
|
|
34
35
|
return new Constructor();
|
|
35
36
|
}
|
|
@@ -144,6 +145,15 @@ function copyDataView(dataView, state) {
|
|
|
144
145
|
function copyDate(date, state) {
|
|
145
146
|
return new state.Constructor(date.getTime());
|
|
146
147
|
}
|
|
148
|
+
/**
|
|
149
|
+
* Copy the time of the original Date, as well as any custom properties.
|
|
150
|
+
*/
|
|
151
|
+
function copyDateStrict(date, state) {
|
|
152
|
+
const clone = copyDate(date, state);
|
|
153
|
+
// set in the cache immediately to be able to reuse the object recursively
|
|
154
|
+
state.cache.set(date, clone);
|
|
155
|
+
return copyOwnPropertiesStrict(date, clone, state);
|
|
156
|
+
}
|
|
147
157
|
/**
|
|
148
158
|
* Deeply copy the keys and values of the original.
|
|
149
159
|
*/
|
|
@@ -170,7 +180,17 @@ function copyObjectLoose(object, state) {
|
|
|
170
180
|
// set in the cache immediately to be able to reuse the object recursively
|
|
171
181
|
state.cache.set(object, clone);
|
|
172
182
|
for (const key of Object.keys(object)) {
|
|
173
|
-
|
|
183
|
+
if (key === '__proto__') {
|
|
184
|
+
Object.defineProperty(clone, key, {
|
|
185
|
+
configurable: true,
|
|
186
|
+
enumerable: true,
|
|
187
|
+
value: state.copier(object[key], state),
|
|
188
|
+
writable: true,
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
else {
|
|
192
|
+
clone[key] = state.copier(object[key], state);
|
|
193
|
+
}
|
|
174
194
|
}
|
|
175
195
|
for (const symbol of Object.getOwnPropertySymbols(object)) {
|
|
176
196
|
if (propertyIsEnumerable.call(object, symbol)) {
|
|
@@ -250,7 +270,7 @@ function getOptions({ createCache: createCacheOverride, maxDepth, methods: metho
|
|
|
250
270
|
asyncGenerator: copySelf,
|
|
251
271
|
blob: copyBlob,
|
|
252
272
|
dataView: copyDataView,
|
|
253
|
-
date: copyDate,
|
|
273
|
+
date: strict ? copyDateStrict : copyDate,
|
|
254
274
|
error: copySelf,
|
|
255
275
|
generator: copySelf,
|
|
256
276
|
map: strict ? copyMapStrict : copyMapLoose,
|