@prisma/cli-dev 0.8.2 → 0.9.0
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/dist/accelerate-6KR7K7Y5.js +494 -0
- package/dist/chunk-6CY7FTXB.js +12 -0
- package/dist/chunk-7LVVKN3Q.js +2 -0
- package/dist/chunk-C743SY2X.js +2 -0
- package/dist/chunk-IUA2KLPR.js +34 -0
- package/dist/chunk-J2EYU3K5.js +2 -0
- package/dist/chunk-MKAOBCJL.js +2 -0
- package/dist/chunk-PKHPXFYF.js +4 -0
- package/dist/chunk-VMZVNK7U.js +2 -0
- package/dist/chunk-VN3SER5K.js +2 -0
- package/dist/chunk-WAQNVDRS.js +15 -0
- package/dist/chunk-ZZ7TGN5J.js +2 -0
- package/dist/client-ROT4AZYN.js +2 -0
- package/dist/dist-44BN73S3.js +24 -0
- package/dist/dist-FF6JPL3Y.js +2 -0
- package/dist/dist-OWTPHSRP.js +2 -0
- package/dist/http-exception-IXDDLQOJ.js +2 -0
- package/dist/index.js +100 -18
- package/dist/list-AF7WT6HT.js +5 -0
- package/dist/logger-5NORX5VG.js +2 -0
- package/dist/nodefs-MQZB2OFY.js +2 -0
- package/dist/opfs-ahp-W7WVBYAH.js +4 -0
- package/dist/pg_dump-F2HW5KLY.js +3 -0
- package/dist/prompt-AVJG6SAC.js +46 -0
- package/dist/proxy-signals-TJILVQAL.js +2 -0
- package/dist/remove-BWVQMMM4.js +9 -0
- package/dist/stop-XM5K7ZMT.js +5 -0
- package/dist/tiny-4VNDEAK3.js +2 -0
- package/dist/utility-5QZDATLM.js +2 -0
- package/package.json +8 -10
- package/dist/chunk-D5MRRGDK.js +0 -12
- package/dist/chunk-XOIFSEIB.js +0 -2
- package/dist/chunk-ZKMEOIRF.js +0 -2
- package/dist/list-K5DAVLAS.js +0 -3
- package/dist/remove-6QJTZ5SK.js +0 -9
- package/dist/stop-CRL2UWAK.js +0 -5
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import"./chunk-J2EYU3K5.js";import{createServer as g}from"net";var a=6e4,l=class d extends EventTarget{constructor(t){super(),this.socket=null,this.active=!1,this.db=t.db,this.closeOnDetach=t.closeOnDetach??!1,this.inspect=t.inspect??!1,this.debug=t.debug??!1,this.id=d.nextHandlerId++,this.log("constructor: created new handler")}get handlerId(){return this.id}log(t,...n){this.debug&&console.log(`[PGLiteSocketHandler#${this.id}] ${t}`,...n)}async attach(t){if(this.log(`attach: attaching socket from ${t.remoteAddress}:${t.remotePort}`),this.socket)throw new Error("Socket already attached");return this.socket=t,this.active=!0,this.log("attach: waiting for PGlite to be ready"),await this.db.waitReady,this.log("attach: acquiring exclusive lock on PGlite instance"),await new Promise(n=>{this.db.runExclusive(()=>(n(),new Promise((i,r)=>{this.resolveLock=i,this.rejectLock=r})))}),this.log("attach: setting up socket event handlers"),t.on("data",n=>this.handleData(n)),t.on("error",n=>this.handleError(n)),t.on("close",()=>this.handleClose()),this}detach(t){return this.log(`detach: detaching socket, close=${t??this.closeOnDetach}`),this.socket?(this.socket.removeAllListeners("data"),this.socket.removeAllListeners("error"),this.socket.removeAllListeners("close"),(t??this.closeOnDetach)&&this.socket.writable&&(this.log("detach: closing socket"),this.socket.end()),this.log("detach: releasing exclusive lock on PGlite instance"),this.resolveLock?.(),this.socket=null,this.active=!1,this):(this.log("detach: no socket attached, nothing to do"),this)}get isAttached(){return this.socket!==null}async handleData(t){if(!this.socket||!this.active){this.log("handleData: no active socket, ignoring data");return}this.log(`handleData: received ${t.length} bytes`),this.inspectData("incoming",t);try{this.log("handleData: sending data to PGlite for processing");let n=await this.db.execProtocolRaw(new Uint8Array(t));this.log(`handleData: received ${n.length} bytes from PGlite`),this.inspectData("outgoing",n),this.socket&&this.socket.writable&&this.active?(this.log("handleData: writing response to socket"),this.socket.write(Buffer.from(n)),this.dispatchEvent(new CustomEvent("data",{detail:{incoming:t.length,outgoing:n.length}}))):this.log("handleData: socket no longer writable or active, discarding response")}catch(n){this.log("handleData: error processing data:",n),this.handleError(n)}}handleError(t){this.log("handleError:",t),this.dispatchEvent(new CustomEvent("error",{detail:t})),this.log("handleError: rejecting exclusive lock on PGlite instance"),this.rejectLock?.(t),this.resolveLock=void 0,this.rejectLock=void 0,this.detach(!0)}handleClose(){this.log("handleClose: socket closed"),this.dispatchEvent(new CustomEvent("close")),this.detach(!1)}inspectData(t,n){if(this.inspect){console.log("-".repeat(75)),console.log(t==="incoming"?"-> incoming":"<- outgoing",n.length,"bytes");for(let i=0;i<n.length;i+=16){let r=Math.min(16,n.length-i),c="";for(let s=0;s<16;s++)if(s<r){let o=n[i+s];c+=o.toString(16).padStart(2,"0")+" "}else c+=" ";let h="";for(let s=0;s<r;s++){let o=n[i+s];h+=o>=32&&o<=126?String.fromCharCode(o):"."}console.log(`${i.toString(16).padStart(8,"0")} ${c} ${h}`)}}}};l.nextHandlerId=1;var u=l,v=class extends EventTarget{constructor(e){super(),this.server=null,this.active=!1,this.activeHandler=null,this.connectionQueue=[],this.handlerCount=0,this.db=e.db,e.path?this.path=e.path:(this.port=e.port||5432,this.host=e.host||"127.0.0.1"),this.inspect=e.inspect??!1,this.debug=e.debug??!1,this.connectionQueueTimeout=e.connectionQueueTimeout??a,this.log(`constructor: created server on ${this.host}:${this.port}`),this.log(`constructor: connection queue timeout: ${this.connectionQueueTimeout}ms`)}log(e,...t){this.debug&&console.log(`[PGLiteSocketServer] ${e}`,...t)}async start(){if(this.log(`start: starting server on ${this.getServerConn()}`),this.server)throw new Error("Socket server already started");return this.active=!0,this.server=g(e=>this.handleConnection(e)),new Promise((e,t)=>{if(!this.server)return t(new Error("Server not initialized"));this.server.on("error",n=>{this.log("start: server error:",n),this.dispatchEvent(new CustomEvent("error",{detail:n})),t(n)}),this.path?this.server.listen(this.path,()=>{this.log(`start: server listening on ${this.getServerConn()}`),this.dispatchEvent(new CustomEvent("listening",{detail:{path:this.path}})),e()}):this.server.listen(this.port,this.host,()=>{this.log(`start: server listening on ${this.getServerConn()}`),this.dispatchEvent(new CustomEvent("listening",{detail:{port:this.port,host:this.host}})),e()})})}getServerConn(){return this.path?this.path:`${this.host}:${this.port}`}async stop(){return this.log("stop: stopping server"),this.active=!1,this.log(`stop: clearing connection queue (${this.connectionQueue.length} connections)`),this.connectionQueue.forEach(e=>{clearTimeout(e.timeoutId),e.socket.writable&&(this.log(`stop: closing queued connection from ${e.clientInfo.clientAddress}:${e.clientInfo.clientPort}`),e.socket.end())}),this.connectionQueue=[],this.activeHandler&&(this.log(`stop: detaching active handler #${this.activeHandlerId}`),this.activeHandler.detach(!0),this.activeHandler=null),this.server?new Promise(e=>{if(!this.server)return e();this.server.close(()=>{this.log("stop: server closed"),this.server=null,this.dispatchEvent(new CustomEvent("close")),e()})}):(this.log("stop: server not running, nothing to do"),Promise.resolve())}get activeHandlerId(){return this.activeHandler?.handlerId??null}async handleConnection(e){let t={clientAddress:e.remoteAddress||"unknown",clientPort:e.remotePort||0};if(this.log(`handleConnection: new connection from ${t.clientAddress}:${t.clientPort}`),!this.active){this.log("handleConnection: server not active, closing connection"),e.end();return}if(!this.activeHandler||!this.activeHandler.isAttached){this.log("handleConnection: no active handler, attaching socket directly"),this.dispatchEvent(new CustomEvent("connection",{detail:t})),await this.attachSocketToNewHandler(e,t);return}this.log(`handleConnection: active handler #${this.activeHandlerId} exists, queueing connection`),this.enqueueConnection(e,t)}enqueueConnection(e,t){this.log(`enqueueConnection: queueing connection from ${t.clientAddress}:${t.clientPort}, timeout: ${this.connectionQueueTimeout}ms`);let n=setTimeout(()=>{this.log(`enqueueConnection: timeout for connection from ${t.clientAddress}:${t.clientPort}`),this.connectionQueue=this.connectionQueue.filter(i=>i.socket!==e),e.writable&&(this.log("enqueueConnection: closing timed out connection"),e.end()),this.dispatchEvent(new CustomEvent("queueTimeout",{detail:{...t,queueSize:this.connectionQueue.length}}))},this.connectionQueueTimeout);this.connectionQueue.push({socket:e,clientInfo:t,timeoutId:n}),this.log(`enqueueConnection: connection queued, queue size: ${this.connectionQueue.length}`),this.dispatchEvent(new CustomEvent("queuedConnection",{detail:{...t,queueSize:this.connectionQueue.length}}))}processNextInQueue(){if(this.log(`processNextInQueue: processing next connection, queue size: ${this.connectionQueue.length}`),this.connectionQueue.length===0||!this.active){this.log("processNextInQueue: no connections in queue or server not active, nothing to do");return}let e=this.connectionQueue.shift();if(e){if(this.log(`processNextInQueue: processing connection from ${e.clientInfo.clientAddress}:${e.clientInfo.clientPort}`),clearTimeout(e.timeoutId),!e.socket.writable){this.log("processNextInQueue: socket no longer writable, skipping to next connection"),this.processNextInQueue();return}this.attachSocketToNewHandler(e.socket,e.clientInfo).catch(t=>{this.log("processNextInQueue: error attaching socket:",t),this.dispatchEvent(new CustomEvent("error",{detail:t})),this.processNextInQueue()})}}async attachSocketToNewHandler(e,t){this.handlerCount++,this.log(`attachSocketToNewHandler: creating new handler for ${t.clientAddress}:${t.clientPort} (handler #${this.handlerCount})`);let n=new u({db:this.db,closeOnDetach:!0,inspect:this.inspect,debug:this.debug});n.addEventListener("error",i=>{this.log(`handler #${n.handlerId}: error from handler:`,i.detail),this.dispatchEvent(new CustomEvent("error",{detail:i.detail}))}),n.addEventListener("close",()=>{this.log(`handler #${n.handlerId}: closed`),this.activeHandler===n&&(this.log(`handler #${n.handlerId}: was active handler, processing next connection in queue`),this.activeHandler=null,this.processNextInQueue())});try{this.activeHandler=n,this.log(`handler #${n.handlerId}: attaching socket`),await n.attach(e),this.dispatchEvent(new CustomEvent("connection",{detail:t}))}catch(i){throw this.log(`handler #${n.handlerId}: error attaching socket:`,i),this.activeHandler=null,e.writable&&e.end(),i}}};export{a as CONNECTION_QUEUE_TIMEOUT,u as PGLiteSocketHandler,v as PGLiteSocketServer};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import"./chunk-J2EYU3K5.js";import{createServer as A}from"http";import{Http2ServerRequest as w}from"http2";import{Readable as P}from"stream";import F from"crypto";var l=class extends Error{static name="RequestError";constructor(e,r){super(e,r)}},U=e=>e instanceof l?e:new l(e.message,{cause:e}),B=global.Request,y=class extends B{constructor(e,r){typeof e=="object"&&u in e&&(e=e[u]()),typeof r?.body?.getReader<"u"&&(r.duplex??="half"),super(e,r)}},L=(e,r,s,t)=>{let a=[],n=s.rawHeaders;for(let c=0;c<n.length;c+=2){let{[c]:h,[c+1]:p}=n;h.charCodeAt(0)!==58&&a.push([h,p])}let o={method:e,headers:a,signal:t.signal};if(e==="TRACE"){o.method="GET";let c=new y(r,o);return Object.defineProperty(c,"method",{get(){return"TRACE"}}),c}return e==="GET"||e==="HEAD"||("rawBody"in s&&s.rawBody instanceof Buffer?o.body=new ReadableStream({start(c){c.enqueue(s.rawBody),c.close()}}):o.body=P.toWeb(s)),new y(r,o)},u=Symbol("getRequestCache"),x=Symbol("requestCache"),m=Symbol("incomingKey"),v=Symbol("urlKey"),d=Symbol("abortControllerKey"),g=Symbol("getAbortController"),R={get method(){return this[m].method||"GET"},get url(){return this[v]},[g](){return this[u](),this[d]},[u](){return this[d]||=new AbortController,this[x]||=L(this.method,this[v],this[m],this[d])}};["body","bodyUsed","cache","credentials","destination","headers","integrity","mode","redirect","referrer","referrerPolicy","signal","keepalive"].forEach(e=>{Object.defineProperty(R,e,{get(){return this[u]()[e]}})});["arrayBuffer","blob","clone","formData","json","text"].forEach(e=>{Object.defineProperty(R,e,{value:function(){return this[u]()[e]()}})});Object.setPrototypeOf(R,y.prototype);var k=(e,r)=>{let s=Object.create(R);s[m]=e;let t=e.url||"";if(t[0]!=="/"&&(t.startsWith("http://")||t.startsWith("https://"))){if(e instanceof w)throw new l("Absolute URL for :path is not allowed in HTTP/2");try{let c=new URL(t);s[v]=c.href}catch(c){throw new l("Invalid absolute URL",{cause:c})}return s}let a=(e instanceof w?e.authority:e.headers.host)||r;if(!a)throw new l("Missing host header");let n;if(e instanceof w){if(n=e.scheme,!(n==="http"||n==="https"))throw new l("Unsupported scheme")}else n=e.socket&&e.socket.encrypted?"https":"http";let o=new URL(`${n}://${a}${t}`);if(o.hostname.length!==a.length&&o.hostname!==a.replace(/:\d+$/,""))throw new l("Invalid host header");return s[v]=o.href,s},q=Symbol("responseCache"),i=Symbol("getResponseCache"),f=Symbol("cache"),C=global.Response,b=class H{#r;#e;[i](){return delete this[f],this[q]||=new C(this.#r,this.#e)}constructor(r,s){let t;if(this.#r=r,s instanceof H){let a=s[q];if(a){this.#e=a,this[i]();return}else this.#e=s.#e,t=new Headers(s.#e.headers)}else this.#e=s;(typeof r=="string"||typeof r?.getReader<"u"||r instanceof Blob||r instanceof Uint8Array)&&(t||=s?.headers||{"content-type":"text/plain; charset=UTF-8"},this[f]=[s?.status||200,r,t])}get headers(){let r=this[f];return r?(r[2]instanceof Headers||(r[2]=new Headers(r[2])),r[2]):this[i]().headers}get status(){return this[f]?.[0]??this[i]().status}get ok(){let r=this.status;return r>=200&&r<300}};["body","bodyUsed","redirected","statusText","trailers","type","url"].forEach(e=>{Object.defineProperty(b.prototype,e,{get(){return this[i]()[e]}})});["arrayBuffer","blob","clone","formData","json","text"].forEach(e=>{Object.defineProperty(b.prototype,e,{value:function(){return this[i]()[e]()}})});Object.setPrototypeOf(b,C);Object.setPrototypeOf(b.prototype,C.prototype);function S(e,r){if(e.locked)throw new TypeError("ReadableStream is locked.");if(r.destroyed){e.cancel();return}let s=e.getReader();return r.on("close",t),r.on("error",t),s.read().then(n,t),s.closed.finally(()=>{r.off("close",t),r.off("error",t)});function t(o){s.cancel(o).catch(()=>{}),o&&r.destroy(o)}function a(){s.read().then(n,t)}function n({done:o,value:c}){try{if(o)r.end();else if(!r.write(c))r.once("drain",a);else return s.read().then(n,t)}catch(h){t(h)}}}var T=e=>{let r={};e instanceof Headers||(e=new Headers(e??void 0));let s=[];for(let[t,a]of e)t==="set-cookie"?s.push(a):r[t]=a;return s.length>0&&(r["set-cookie"]=s),r["content-type"]??="text/plain; charset=UTF-8",r},G="x-hono-already-sent",K=global.fetch;typeof global.crypto>"u"&&(global.crypto=F);global.fetch=(e,r)=>(r={compress:!1,...r},K(e,r));var $=/^no$/i,D=/^(application\/json\b|text\/(?!event-stream\b))/i,_=()=>new Response(null,{status:400}),O=e=>new Response(null,{status:e instanceof Error&&(e.name==="TimeoutError"||e.constructor.name==="TimeoutError")?504:500}),E=(e,r)=>{let s=e instanceof Error?e:new Error("unknown error",{cause:e});s.code==="ERR_STREAM_PREMATURE_CLOSE"?console.info("The user aborted a request."):(console.error(e),r.headersSent||r.writeHead(500,{"Content-Type":"text/plain"}),r.end(`Error: ${s.message}`),r.destroy(s))},j=async(e,r)=>{let[s,t,a]=e[f];if(a instanceof Headers&&(a=T(a)),typeof t=="string"?a["Content-Length"]=Buffer.byteLength(t):t instanceof Uint8Array?a["Content-Length"]=t.byteLength:t instanceof Blob&&(a["Content-Length"]=t.size),r.writeHead(s,a),typeof t=="string"||t instanceof Uint8Array)r.end(t);else if(t instanceof Blob)r.end(new Uint8Array(await t.arrayBuffer()));else return S(t,r)?.catch(n=>E(n,r))},I=async(e,r,s={})=>{if(e instanceof Promise)if(s.errorHandler)try{e=await e}catch(a){let n=await s.errorHandler(a);if(!n)return;e=n}else e=await e.catch(O);if(f in e)return j(e,r);let t=T(e.headers);if(e.body){let{"transfer-encoding":a,"content-encoding":n,"content-length":o,"x-accel-buffering":c,"content-type":h}=t;if(a||n||o||c&&$.test(c)||!D.test(h))r.writeHead(e.status,t),await S(e.body,r);else{let p=await e.arrayBuffer();t["content-length"]=p.byteLength,r.writeHead(e.status,t),r.end(new Uint8Array(p))}}else t[G]||(r.writeHead(e.status,t),r.end())},M=(e,r={})=>(r.overrideGlobalObjects!==!1&&global.Request!==y&&(Object.defineProperty(global,"Request",{value:y}),Object.defineProperty(global,"Response",{value:b})),async(s,t)=>{let a,n;try{if(n=k(s,r.hostname),t.on("close",()=>{n[d]&&(s.errored?n[d].abort(s.errored.toString()):t.writableFinished||n[d].abort("Client connection prematurely closed."))}),a=e(n,{incoming:s,outgoing:t}),f in a)return j(a,t)}catch(o){if(a)return E(o,t);if(r.errorHandler){if(a=await r.errorHandler(n?o:U(o)),!a)return}else n?a=O(o):a=_()}try{return await I(a,t,r)}catch(o){return E(o,t)}}),W=e=>{let r=e.fetch,s=M(r,{hostname:e.hostname,overrideGlobalObjects:e.overrideGlobalObjects});return(e.createServer||A)(e.serverOptions||{},s)},Y=(e,r)=>{let s=W(e);return s.listen(e?.port??3e3,e.hostname,()=>{let t=s.address();r&&r(t)}),s};export{l as RequestError,W as createAdaptorServer,M as getRequestListener,Y as serve};
|