@prisma/extension-optimize 0.5.3 → 0.5.4

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/README.md CHANGED
@@ -1,15 +1,15 @@
1
1
  # Optimize Prisma Client extension
2
2
 
3
- This is the package for the [Prisma Client extension](https://www.prisma.io/docs/concepts/components/prisma-client/client-extensions?utm_source=github&utm_medium=accelerate-readme) that enables usage of Prisma Optimize.
3
+ This is the package for the [Prisma Client extension](https://www.prisma.io/docs/concepts/components/prisma-client/client-extensions?utm_source=github&utm_medium=optimize-readme) that enables usage of Prisma Optimize.
4
4
 
5
- Optimize enables developers to profile and get performance-related recommendations while developing applications with prisma.
5
+ Optimize enables developers to profile and get performance-related recommendations while developing applications with Prisma.
6
6
 
7
- It is part of the [Prisma](https://www.prisma.io?utm_source=github&utm_medium=accelerate-readme) ecosystem, alongside other tools such as:
7
+ It is part of the [Prisma](https://www.prisma.io?utm_source=github&utm_medium=optimize-readme) ecosystem, alongside other tools such as:
8
8
 
9
- - [Prisma Accelerate](https://www.prisma.io/data-platform/accelerate?utm_source=github&utm_medium=pulse-readme): Global database cache with scalable connection pooling.
10
- - [Prisma Pulse](https://www.prisma.io/data-platform/pulse?utm_source=github&utm_medium=accelerate-readme): Real-time database events with type-safe subscriptions.
9
+ - [Prisma Accelerate](https://www.prisma.io/data-platform/accelerate?utm_source=github&utm_medium=optimize-readme): Global database cache with scalable connection pooling.
10
+ - [Prisma Pulse](https://www.prisma.io/data-platform/pulse?utm_source=github&utm_medium=optimize-readme): Real-time database events with type-safe subscriptions.
11
11
 
12
- Prisma is leading Data DX, a philosophy that promotes simplicity in data-driven application development. Learn more on the [Data DX manifesto](https://www.datadx.io/?utm_source=github&utm_medium=accelerate-readme).
12
+ Prisma is leading Data DX, a philosophy that promotes simplicity in data-driven application development. Learn more on the [Data DX manifesto](https://www.datadx.io/?utm_source=github&utm_medium=optimize-readme).
13
13
 
14
14
  ## Getting started with Optimize
15
15
 
@@ -21,20 +21,35 @@ Enabling Optimize in your local development workflow is really simple.
21
21
  npm install @prisma/extension-optimize --save-dev
22
22
  ```
23
23
 
24
- > Starting a prisma project from scratch? Follow https://www.prisma.io/docs/getting-started
24
+ > Starting a Prisma project from scratch? Follow https://www.prisma.io/docs/getting-started
25
25
 
26
- ### 2. Extend your prisma client with Optimize support
26
+ ### 2. Enable the `tracing` preview feature in your schema
27
27
 
28
+ ```diff
29
+ generator client {
30
+ provider = "prisma-client-js"
31
+ + previewFeatures = ["tracing"]
32
+ }
28
33
  ```
34
+
35
+ After enabling the `tracing` preview feature, you need to re-generate your Prisma Client:
36
+
37
+ ```
38
+ npx prisma generate
39
+ ```
40
+
41
+ ### 3. Extend your Prisma Client with Optimize support
42
+
43
+ ```typescript
29
44
  import { PrismaClient } from "@prisma/client";
30
45
  import { withOptimize } from "@prisma/extension-optimize";
31
46
 
32
47
  const prisma = new PrismaClient().$extends(withOptimize());
33
48
  ```
34
49
 
35
- The extension will orchestrate the user experience around optimize. You will:
50
+ The extension will orchestrate the user experience around Optimize. You will:
36
51
 
37
- - Be required to log into the prisma data platform through your GitHub account
52
+ - Be required to log into the Prisma Data Platform through your GitHub account
38
53
  - And be instructed to visit the URL of your Optimize dashboard:
39
54
 
40
55
  ```
package/dist/index.d.ts CHANGED
@@ -17,10 +17,8 @@ type OptimizeOptions = {
17
17
  */
18
18
  dashboardUrl?: string;
19
19
  /**
20
- * Whether to use tracing or not. Requires the `tracing` preview feature to be enabled,
21
- * hence disabled by default to maximize compatibility. Basic functionality is available
22
- * without tracing but capturing the SQL statements and detecting cold starts is only
23
- * available with tracing.
20
+ * Whether to use tracing or not. Basic functionality is available without tracing
21
+ * but capturing the SQL statements and detecting cold starts is only available with tracing.
24
22
  */
25
23
  useTracing?: boolean;
26
24
  /**
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var de=Object.create;var f=Object.defineProperty;var pe=Object.getOwnPropertyDescriptor;var ce=Object.getOwnPropertyNames;var le=Object.getPrototypeOf,me=Object.prototype.hasOwnProperty;var ue=(t,e)=>{for(var n in e)f(t,n,{get:e[n],enumerable:!0})},L=(t,e,n,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of ce(e))!me.call(t,r)&&r!==n&&f(t,r,{get:()=>e[r],enumerable:!(o=pe(e,r))||o.enumerable});return t};var a=(t,e,n)=>(n=t!=null?de(le(t)):{},L(e||!t||!t.__esModule?f(n,"default",{value:t,enumerable:!0}):n,t)),fe=t=>L(f({},"__esModule",{value:!0}),t);var qe={};ue(qe,{PROD_DASHBOARD_URL:()=>ae,PROD_INGESTION_URL:()=>ie,withOptimize:()=>xe});module.exports=fe(qe);var oe=require("@opentelemetry/api"),re=require("@prisma/client/extension"),se=a(require("@prisma/debug")),b=require("kleur");var q;async function h(t,e,n){let o=new URL("/ingest",t),r=new Headers({"Content-Type":"application/json",Authorization:`Bearer ${e}`});q&&r.set("prisma-optimize-jwt",q);let s=await fetch(o,{method:"POST",headers:r,body:JSON.stringify(n)});if(!s.ok){console.error(`[optimize] HTTP ${s.status} ${s.statusText}: ${await s.text()}`);return}let i=s.headers.get("prisma-optimize-jwt");i&&(q=i)}var M=a(require("fs")),U=a(require("path")),F=a(require("@prisma/debug")),_=a(require("xdg-app-paths")),he=(0,F.default)("prisma:extension:optimize"),ge=new _.default("prisma-platform-cli").config(),Se=U.default.join(ge,"auth.json");function ye(t){if(typeof t!="object"||t===null)throw new Error("Invalid credentials");if(typeof t.token!="string")throw new Error("Invalid credentials");return t}function D(){try{let t=M.default.readFileSync(Se,"utf-8");return ye(JSON.parse(t)).token}catch(t){return he(t),null}}var c=a(require("fs")),$=a(require("path")),N=require("stream"),j=require("stream/promises"),g=require("kleur"),J=require("node-notifier"),B=a(require("xdg-app-paths")),we="https://avatars.githubusercontent.com/u/17219288?s=96";async function Re(t){let e=new B.default("prisma-optimize").config();c.default.mkdirSync(e,{recursive:!0});let n=$.default.resolve(e,"avatar.png");if(!c.default.existsSync(n)){let p=await fetch(we);if(p.ok&&p.body!=null){let I=c.default.createWriteStream(n,{flags:"wx"});await(0,j.finished)(N.Readable.fromWeb(p.body).pipe(I))}}let o="See your Optimize dashboard at:",r=o.length,s=`${(0,g.underline)((0,g.bold)(t))}`,i=t.length,d=Math.max(r,i)+2;console.log("\u250C"+"\u2500".repeat(d)+"\u2510"),console.log("\u2502 "+o+" ".repeat(d-r-2)+" \u2502"),console.log("\u2502 "+s+" ".repeat(d-i-2)+" \u2502"),console.log("\u2514"+"\u2500".repeat(d)+"\u2518"),(0,J.notify)({timeout:10,open:t,subtitle:"Your dashboard is ready! \u{1F680} ",message:"Click to open",title:"Prisma Optimize",icon:c.default.existsSync(n)?n:void 0,contentImage:c.default.existsSync(n)?n:void 0})}var H={dashboardReady:Re};var V=require("@opentelemetry/api"),G=require("@opentelemetry/context-async-hooks"),W=require("@opentelemetry/instrumentation"),X=require("@opentelemetry/resources"),Y=require("@opentelemetry/sdk-trace-base"),R=require("@opentelemetry/semantic-conventions"),Z=require("@prisma/instrumentation");var Q=a(require("@prisma/debug"));function S(t,...e){setTimeout(()=>{t(...e)},0)}function v(t){return t[0]*1e3+t[1]/1e6}var y=(0,Q.default)("prisma:extension:optimize"),P="0000000000000000",T=class{spanId;timestamp;model;operation;args;duration;connect;sql;error;completionFlags={clientSpanClosed:!1,engineSpanClosed:!1};constructor(e){this.spanId=e.spanId,this.timestamp=e.timestamp,this.model=e.model,this.operation=e.operation,this.args=e.args}#e(){return this.completionFlags.clientSpanClosed&&this.completionFlags.engineSpanClosed}completedRequest(){if(this.#e()&&this.error!==void 0){if(this.duration===void 0)throw new Error("Invariant violation: duration cannot still be undefined after the client span is closed because it is retrieved from the client span. This is a bug.");return{ts:this.timestamp,model:this.model??null,operation:this.operation,args:this.args,latency:this.duration,connect:this.connect??!1,sql:this.sql??null,error:this.error}}}},w=class{#e=new Map;#r=Promise.resolve();#t=new Map;#n=new Map;#i;#a;#d;#o=[];#s=!1;#p=0;constructor(e,n,o){this.#i=e,this.#a=n,this.#d=o}createRequest(e){let n=new T(e);this.#e.set(e.spanId,n)}setRequestError(e,n){let o=this.#e.get(e);if(!o)throw new Error(`Unknown request ${e}`);o.error=n}#u(e){for(let n=e;n!==P;n=this.#t.get(n)){if(n===void 0)return{type:"UndeliveredSpanInTree"};let o=this.#e.get(n);if(o)return{type:"Ok",request:o}}return{type:"NotInRequestTree"}}onStart(e,n){let o=e.spanContext().spanId;if(!e.parentSpanId){this.#t.set(o,P);return}if(this.#t.set(o,e.parentSpanId),e.parentSpanId===P)return;let r=this.#n.get(e.parentSpanId);r?r.add(o):this.#n.set(e.parentSpanId,new Set([o]))}onEnd(e){this.#c(e)}async forceFlush(){await this.#r,await this.#m()}async shutdown(){await this.forceFlush()}#c(e){let n=e.spanContext().spanId,o,r=this.#u(n);switch(r.type){case"Ok":o=r.request;break;case"UndeliveredSpanInTree":this.#f(e);break;case"NotInRequestTree":this.#l(n);break}if(!o)return;switch(e.name){case"prisma:client:connect":{o.connect=v(e.duration);break}case"prisma:engine:db_query":{let i=e.attributes["db.statement"];typeof i=="string"?o.sql=i:y("db.statement in span %s must be a string, got %o",n,i),o.completionFlags.engineSpanClosed=!0;break}case"prisma:client:operation":{let i=v(e.duration);y("latency otel: %d",i),o.duration=i,o.completionFlags.clientSpanClosed=!0;break}}let s=o.completedRequest();s&&(this.#e.delete(o.spanId),this.#h(s))}#f(e){this.#r=Promise.all([this.#r,new Promise(n=>{S(()=>{this.#c(e),n()})})]).then(()=>{})}#l(e){this.#t.delete(e);let n=this.#n.get(e);if(this.#n.delete(e),n)for(let o of n)this.#l(o)}#h(e){this.#o.push(e),this.#g()}#g(){if(this.#s)return;this.#s=!0;let e=Date.now()-this.#p;y("time since last send: %d",e),setTimeout(()=>{this.#s=!1,this.#m()},Math.max(0,this.#d-e))}async#m(){if(this.#o.length===0)return;let e=this.#o;this.#o=[],y("sending batch of %d requests",e.length),this.#p=Date.now(),await h(this.#i,this.#a,e)}};function K(t,e,n){let o=new G.AsyncHooksContextManager().enable();V.context.setGlobalContextManager(o);let r=new Y.BasicTracerProvider({resource:new X.Resource({[R.SEMRESATTRS_SERVICE_NAME]:"extension-optimize",[R.SEMRESATTRS_SERVICE_VERSION]:"0.0.0"})}),s=new w(t,e,n);return r.addSpanProcessor(s),(0,W.registerInstrumentations)({tracerProvider:r,instrumentations:[new Z.PrismaInstrumentation]}),r.register(),s}function ee(t){if(t instanceof Error)return t.stack??t.message;switch(typeof t){case"undefined":return"undefined";case"object":{let e;return t!==null&&typeof t.toString=="function"&&(e=t.toString()),typeof e=="string"&&e!=="[object Object]"?e:JSON.stringify(t)}default:return String(t)}}var te=require("@prisma/client/extension"),ne=te.Prisma.defineExtension(t=>t.$extends({}));var be=(0,se.default)("prisma:extension:optimize"),ie="https://optimize-ingestion.datacdn.workers.dev/",ae="https://optimize-3k7.pages.dev/",Ie=`Please login to Prisma Data Platform using the CLI to use Prisma Optimize:
1
+ "use strict";var ue=Object.create;var f=Object.defineProperty;var fe=Object.getOwnPropertyDescriptor;var he=Object.getOwnPropertyNames;var ge=Object.getPrototypeOf,Se=Object.prototype.hasOwnProperty;var we=(t,e)=>{for(var n in e)f(t,n,{get:e[n],enumerable:!0})},F=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of he(e))!Se.call(t,o)&&o!==n&&f(t,o,{get:()=>e[o],enumerable:!(r=fe(e,o))||r.enumerable});return t};var p=(t,e,n)=>(n=t!=null?ue(ge(t)):{},F(e||!t||!t.__esModule?f(n,"default",{value:t,enumerable:!0}):n,t)),ye=t=>F(f({},"__esModule",{value:!0}),t);var Te={};we(Te,{PROD_DASHBOARD_URL:()=>ce,PROD_INGESTION_URL:()=>me,withOptimize:()=>Ce});module.exports=ye(Te);var ae=require("@opentelemetry/api"),pe=require("@prisma/client/extension"),de=p(require("@prisma/debug")),b=require("kleur"),le=p(require("readline-sync"));var P;async function h(t,e,n){let r=new URL("/ingest",t),o=new Headers({"Content-Type":"application/json",Authorization:`Bearer ${e}`});P&&o.set("prisma-optimize-jwt",P);let s=await fetch(r,{method:"POST",headers:o,body:JSON.stringify(n)});if(!s.ok){console.error(`[optimize] HTTP ${s.status} ${s.statusText}: ${await s.text()}`);return}let i=s.headers.get("prisma-optimize-jwt");i&&(P=i)}var M=p(require("fs")),U=p(require("path")),_=p(require("@prisma/debug")),D=p(require("xdg-app-paths")),Re=(0,_.default)("prisma:extension:optimize"),be=new D.default("prisma-platform-cli").config(),Ie=U.default.join(be,"auth.json");function xe(t){if(typeof t!="object"||t===null)throw new Error("Invalid credentials");if(typeof t.token!="string")throw new Error("Invalid credentials");return t}function q(){try{let t=M.default.readFileSync(Ie,"utf-8");return xe(JSON.parse(t)).token}catch(t){return Re(t),null}}var N=require("child_process");function $(){let t=(0,N.spawnSync)("npx",["prisma","platform","auth","login","--early-access"],{stdio:"inherit",shell:!0});if(t.error)throw t.error}var l=p(require("fs")),j=p(require("path")),J=require("stream"),B=require("stream/promises"),g=require("kleur"),H=require("node-notifier"),Q=p(require("xdg-app-paths")),Pe="https://avatars.githubusercontent.com/u/17219288?s=96";async function qe(t){let e=new Q.default("prisma-optimize").config();l.default.mkdirSync(e,{recursive:!0});let n=j.default.resolve(e,"avatar.png");if(!l.default.existsSync(n)){let d=await fetch(Pe);if(d.ok&&d.body!=null){let I=l.default.createWriteStream(n,{flags:"wx"});await(0,B.finished)(J.Readable.fromWeb(d.body).pipe(I))}}let r="See your Optimize dashboard at:",o=r.length,s=`${(0,g.underline)((0,g.bold)(t))}`,i=t.length,a=Math.max(o,i)+2;console.log("\u250C"+"\u2500".repeat(a)+"\u2510"),console.log("\u2502 "+r+" ".repeat(a-o-2)+" \u2502"),console.log("\u2502 "+s+" ".repeat(a-i-2)+" \u2502"),console.log("\u2514"+"\u2500".repeat(a)+"\u2518"),(0,H.notify)({timeout:10,open:t,subtitle:"Your dashboard is ready! \u{1F680} ",message:"Click to open",title:"Prisma Optimize",icon:l.default.existsSync(n)?n:void 0,contentImage:l.default.existsSync(n)?n:void 0})}var V={dashboardReady:qe};var Y=require("@opentelemetry/api"),G=require("@opentelemetry/context-async-hooks"),X=require("@opentelemetry/instrumentation"),Z=require("@opentelemetry/resources"),K=require("@opentelemetry/sdk-trace-base"),R=require("@opentelemetry/semantic-conventions"),ee=require("@prisma/instrumentation");var W=p(require("@prisma/debug"));function S(t,...e){setTimeout(()=>{t(...e)},0)}function v(t){return t[0]*1e3+t[1]/1e6}var w=(0,W.default)("prisma:extension:optimize"),C="0000000000000000",T=class{spanId;timestamp;model;operation;args;duration;connect;sql;error;completionFlags={clientSpanClosed:!1,engineSpanClosed:!1};constructor(e){this.spanId=e.spanId,this.timestamp=e.timestamp,this.model=e.model,this.operation=e.operation,this.args=e.args}#e(){return this.completionFlags.clientSpanClosed&&this.completionFlags.engineSpanClosed}completedRequest(){if(this.#e()&&this.error!==void 0){if(this.duration===void 0)throw new Error("Invariant violation: duration cannot still be undefined after the client span is closed because it is retrieved from the client span. This is a bug.");return{ts:this.timestamp,model:this.model??null,operation:this.operation,args:this.args,latency:this.duration,connect:this.connect??!1,sql:this.sql??null,error:this.error}}}},y=class{#e=new Map;#o=Promise.resolve();#t=new Map;#n=new Map;#s;#a;#p;#r=[];#i=!1;#d=0;constructor(e,n,r){this.#s=e,this.#a=n,this.#p=r}createRequest(e){let n=new T(e);this.#e.set(e.spanId,n)}setRequestError(e,n){let r=this.#e.get(e);if(!r)throw new Error(`Unknown request ${e}`);r.error=n}#u(e){for(let n=e;n!==C;n=this.#t.get(n)){if(n===void 0)return{type:"UndeliveredSpanInTree"};let r=this.#e.get(n);if(r)return{type:"Ok",request:r}}return{type:"NotInRequestTree"}}onStart(e,n){let r=e.spanContext().spanId;if(!e.parentSpanId){this.#t.set(r,C);return}if(this.#t.set(r,e.parentSpanId),e.parentSpanId===C)return;let o=this.#n.get(e.parentSpanId);o?o.add(r):this.#n.set(e.parentSpanId,new Set([r]))}onEnd(e){this.#l(e)}async forceFlush(){await this.#o,await this.#c()}async shutdown(){await this.forceFlush()}#l(e){let n=e.spanContext().spanId,r,o=this.#u(n);switch(o.type){case"Ok":r=o.request;break;case"UndeliveredSpanInTree":this.#f(e);break;case"NotInRequestTree":this.#m(n);break}if(!r)return;switch(e.name){case"prisma:client:connect":{r.connect=v(e.duration);break}case"prisma:engine:db_query":{let i=e.attributes["db.statement"];typeof i=="string"?r.sql=i:w("db.statement in span %s must be a string, got %o",n,i),r.completionFlags.engineSpanClosed=!0;break}case"prisma:client:operation":{let i=v(e.duration);w("latency otel: %d",i),r.duration=i,r.completionFlags.clientSpanClosed=!0;break}}let s=r.completedRequest();s&&(this.#e.delete(r.spanId),this.#h(s))}#f(e){this.#o=Promise.all([this.#o,new Promise(n=>{S(()=>{this.#l(e),n()})})]).then(()=>{})}#m(e){this.#t.delete(e);let n=this.#n.get(e);if(this.#n.delete(e),n)for(let r of n)this.#m(r)}#h(e){this.#r.push(e),this.#g()}#g(){if(this.#i)return;this.#i=!0;let e=Date.now()-this.#d;w("time since last send: %d",e),setTimeout(()=>{this.#i=!1,this.#c()},Math.max(0,this.#p-e))}async#c(){if(this.#r.length===0)return;let e=this.#r;this.#r=[],w("sending batch of %d requests",e.length),this.#d=Date.now(),await h(this.#s,this.#a,e)}};function te(t,e,n){let r=new G.AsyncHooksContextManager().enable();Y.context.setGlobalContextManager(r);let o=new K.BasicTracerProvider({resource:new Z.Resource({[R.SEMRESATTRS_SERVICE_NAME]:"extension-optimize",[R.SEMRESATTRS_SERVICE_VERSION]:"0.0.0"})}),s=new y(t,e,n);return o.addSpanProcessor(s),(0,X.registerInstrumentations)({tracerProvider:o,instrumentations:[new ee.PrismaInstrumentation]}),o.register(),s}function ne(t){return t._previewFeatures?.includes("tracing")}function re(t){if(t instanceof Error)return t.stack??t.message;switch(typeof t){case"undefined":return"undefined";case"object":{let e;return t!==null&&typeof t.toString=="function"&&(e=t.toString()),typeof e=="string"&&e!=="[object Object]"?e:JSON.stringify(t)}default:return String(t)}}var oe=require("@prisma/client/extension"),ie=oe.Prisma.defineExtension(t=>t.$extends({}));var ve=(0,de.default)("prisma:extension:optimize"),me="https://optimize-ingestion.datacdn.workers.dev/",ce="https://optimize-3k7.pages.dev/",se=`You need to login to Prisma Data Platform using the CLI to use Prisma Optimize:
2
2
 
3
3
  ${(0,b.dim)("$")} ${(0,b.bold)("prisma platform auth login --early-access")}
4
- `;function xe({enable:t=!0,ingestionUrl:e=ie,dashboardUrl:n=ae,useTracing:o=!1,minSendInterval:r=10}={}){if(!t)return ne;let s=new URL(e),i=D();if(!i)throw new Error(Ie);return H.dashboardReady(n).then().catch(d=>{console.error("Failed to show toast",d)}),re.Prisma.defineExtension(d=>{let p=o?K(s,i,r):void 0;return d.$extends({query:{async $allOperations({query:I,model:k,operation:E,args:x}){let C=oe.trace.getActiveSpan();if(o&&!C)throw new Error("prisma:client:operation span is expected to be entered in the client extension when tracing is enabled");let m=C?.spanContext().spanId,u=null,A=performance.now(),O=Date.now();m&&p?.createRequest({spanId:m,timestamp:O,model:k,operation:E,args:x});try{return await I(x)}catch(l){throw u=ee(l),await p?.forceFlush(),l}finally{let l=performance.now();if(be("latency raw: %d",l-A),m&&p?.setRequestError(m,u),!o){let z=async()=>{await h(s,i,[{model:k??null,operation:E,args:x,error:u,latency:l-A,ts:O,connect:!1,sql:null}])};u!==null?await z():S(z)}}}}})})}0&&(module.exports={PROD_DASHBOARD_URL,PROD_INGESTION_URL,withOptimize});
4
+ `;function Ce({enable:t=!0,ingestionUrl:e=me,dashboardUrl:n=ce,useTracing:r=!0,minSendInterval:o=50}={}){if(!t)return ie;let s=new URL(e),i=q();if(!i)if(process.stdin.isTTY){if(console.error(se),le.default.keyInYN("Run this command now?")&&($(),i=q()),!i)throw new Error("Please login to Prisma Data Platform in the CLI to use Prisma Optimize.")}else throw new Error(se);return V.dashboardReady(n).then().catch(a=>{console.error("Failed to show toast",a)}),pe.Prisma.defineExtension(a=>{let d=r?te(s,i,o):void 0;if(r&&!ne(a))throw new Error('Please enable the "tracing" preview feature and regenerate the client.');return a.$extends({query:{async $allOperations({query:I,model:E,operation:k,args:x}){let A=ae.trace.getActiveSpan();if(r&&!A)throw new Error("prisma:client:operation span is expected to be entered in the client extension when tracing is enabled");let c=A?.spanContext().spanId,u=null,O=performance.now(),L=Date.now();c&&d?.createRequest({spanId:c,timestamp:L,model:E,operation:k,args:x});try{return await I(x)}catch(m){throw u=re(m),await d?.forceFlush(),m}finally{let m=performance.now();if(ve("latency raw: %d",m-O),c&&d?.setRequestError(c,u),!r){let z=async()=>{await h(s,i,[{model:E??null,operation:k,args:x,error:u,latency:m-O,ts:L,connect:!1,sql:null}])};u!==null?await z():S(z)}}}}})})}0&&(module.exports={PROD_DASHBOARD_URL,PROD_INGESTION_URL,withOptimize});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prisma/extension-optimize",
3
- "version": "0.5.3",
3
+ "version": "0.5.4",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -20,15 +20,17 @@
20
20
  "@opentelemetry/sdk-trace-base": "1.22.0",
21
21
  "@opentelemetry/semantic-conventions": "1.22.0",
22
22
  "@prisma/debug": "5.12.1",
23
- "@prisma/instrumentation": "5.11.0",
24
- "node-notifier": "10.0.1",
23
+ "@prisma/instrumentation": "5.13.0",
25
24
  "kleur": "4.1.5",
25
+ "node-notifier": "10.0.1",
26
+ "readline-sync": "1.4.10",
26
27
  "xdg-app-paths": "8.3.0"
27
28
  },
28
29
  "devDependencies": {
30
+ "@types/node-notifier": "8.0.5",
31
+ "@types/readline-sync": "1.4.8",
29
32
  "common": "workspace:*",
30
33
  "tsup": "8.0.2",
31
- "@types/node-notifier": "8.0.5",
32
34
  "vitest": "1.4.0"
33
35
  },
34
36
  "peerDependencies": {