@zuplo/runtime 7.11.4 → 7.11.6

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,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-3RVZUQKN.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")},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};
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,QAA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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"]}
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,MAAOF,EAAQ,MACf,gBAAiBA,EAAQ,OAC3B,CAAC,EAMiB,eAJKI,EAAA,SAAY,CACjC,MAAM,QAAQ,IAAIH,CAAiB,CACrC,EAFuB,iBAIU,CACnC,CAvBgBG,EAAAL,EAAA,qBAyBhB,IAAMO,EAA2C,CAC/C,KAAM,IACN,QAAS,CAAC,KAAK,EACf,QAAS,CACP,OAAQ,CAAC,EACT,OAAQ,SACV,EACA,IAAKF,EAAA,KAAU,CAAC,GAAX,MACP,EAMaC,EAAN,cAA+B,WAAoC,CAzE1E,MAyE0E,CAAAD,EAAA,yBAC/DG,GACAC,GACA,UACA,UACA,IACA,MAEA,OACA,0BACA,cACA,iBAET,YAAY,CACV,MAAAC,EACA,MAAAC,EAAQJ,EACR,cAAAK,EACA,gBAAAC,CACF,EAUG,CACD,MAAM,EACN,KAAK,UAAY,OAAO,WAAW,EACnC,KAAK,UAAY,OAAO,WAAW,EAEnC,KAAK,IAAM,CACT,KAAMC,EAAU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E,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"]}
@@ -8658,6 +8658,44 @@ export declare interface Logger extends SystemLogger {
8658
8658
  setLogProperties?(
8659
8659
  properties: Record<string, string | number | boolean>
8660
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;
8661
8699
  }
8662
8700
 
8663
8701
  /* Excluded from this release type: LoggingContext */
@@ -10745,6 +10783,18 @@ declare interface MetricsData {
10745
10783
  parentContextId?: string;
10746
10784
  requestId: string;
10747
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>;
10748
10798
  routePath: string;
10749
10799
  systemRouteName?: string;
10750
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;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@zuplo/runtime",
3
3
  "type": "module",
4
- "version": "7.11.4",
4
+ "version": "7.11.6",
5
5
  "repository": "https://github.com/zuplo/zuplo",
6
6
  "author": "Zuplo, Inc.",
7
7
  "exports": {