d1s 0.2.5 → 0.2.8
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 +3 -1
- package/dist/.next/.next/BUILD_ID +1 -1
- package/dist/.next/.next/app-build-manifest.json +31 -24
- package/dist/.next/.next/app-path-routes-manifest.json +1 -1
- package/dist/.next/.next/build-manifest.json +2 -2
- package/dist/.next/.next/cache/.rscinfo +1 -1
- package/dist/.next/.next/cache/.tsbuildinfo +1 -1
- package/dist/.next/.next/cache/webpack/client-development/0.pack.gz +0 -0
- package/dist/.next/.next/cache/webpack/client-development/1.pack.gz +0 -0
- package/dist/.next/.next/cache/webpack/client-development/2.pack.gz +0 -0
- package/dist/.next/.next/cache/webpack/client-development/3.pack.gz +0 -0
- package/dist/.next/.next/cache/webpack/client-development/4.pack.gz +0 -0
- package/dist/.next/.next/cache/webpack/client-development/index.pack.gz +0 -0
- package/dist/.next/.next/cache/webpack/client-development/index.pack.gz.old +0 -0
- package/dist/.next/.next/cache/webpack/client-production/0.pack +0 -0
- package/dist/.next/.next/cache/webpack/client-production/1.pack +0 -0
- package/dist/.next/.next/cache/webpack/client-production/10.pack +0 -0
- package/dist/.next/.next/cache/webpack/client-production/11.pack +0 -0
- package/dist/.next/.next/cache/webpack/client-production/12.pack +0 -0
- package/dist/.next/.next/cache/webpack/client-production/13.pack +0 -0
- package/dist/.next/.next/cache/webpack/client-production/14.pack +0 -0
- package/dist/.next/.next/cache/webpack/client-production/2.pack +0 -0
- package/dist/.next/.next/cache/webpack/client-production/3.pack +0 -0
- package/dist/.next/.next/cache/webpack/client-production/4.pack +0 -0
- package/dist/.next/.next/cache/webpack/client-production/5.pack +0 -0
- package/dist/.next/.next/cache/webpack/client-production/6.pack +0 -0
- package/dist/.next/.next/cache/webpack/client-production/7.pack +0 -0
- package/dist/.next/.next/cache/webpack/client-production/8.pack +0 -0
- package/dist/.next/.next/cache/webpack/client-production/9.pack +0 -0
- package/dist/.next/.next/cache/webpack/client-production/index.pack +0 -0
- package/dist/.next/.next/cache/webpack/client-production/index.pack.old +0 -0
- package/dist/.next/.next/cache/webpack/edge-server-production/index.pack +0 -0
- package/dist/.next/.next/cache/webpack/server-development/0.pack.gz +0 -0
- package/dist/.next/.next/cache/webpack/server-development/1.pack.gz +0 -0
- package/dist/.next/.next/cache/webpack/server-development/2.pack.gz +0 -0
- package/dist/.next/.next/cache/webpack/server-development/3.pack.gz +0 -0
- package/dist/.next/.next/cache/webpack/server-development/4.pack.gz +0 -0
- package/dist/.next/.next/cache/webpack/server-development/index.pack.gz +0 -0
- package/dist/.next/.next/cache/webpack/server-development/index.pack.gz.old +0 -0
- package/dist/.next/.next/cache/webpack/server-production/0.pack +0 -0
- package/dist/.next/.next/cache/webpack/server-production/1.pack +0 -0
- package/dist/.next/.next/cache/webpack/server-production/10.pack +0 -0
- package/dist/.next/.next/cache/webpack/server-production/11.pack +0 -0
- package/dist/.next/.next/cache/webpack/server-production/12.pack +0 -0
- package/dist/.next/.next/cache/webpack/server-production/13.pack +0 -0
- package/dist/.next/.next/cache/webpack/server-production/2.pack +0 -0
- package/dist/.next/.next/cache/webpack/server-production/3.pack +0 -0
- package/dist/.next/.next/cache/webpack/server-production/4.pack +0 -0
- package/dist/.next/.next/cache/webpack/server-production/5.pack +0 -0
- package/dist/.next/.next/cache/webpack/server-production/6.pack +0 -0
- package/dist/.next/.next/cache/webpack/server-production/7.pack +0 -0
- package/dist/.next/.next/cache/webpack/server-production/8.pack +0 -0
- package/dist/.next/.next/cache/webpack/server-production/9.pack +0 -0
- package/dist/.next/.next/cache/webpack/server-production/index.pack +0 -0
- package/dist/.next/.next/cache/webpack/server-production/index.pack.old +0 -0
- package/dist/.next/.next/next-minimal-server.js.nft.json +1 -1
- package/dist/.next/.next/next-server.js.nft.json +1 -1
- package/dist/.next/.next/prerender-manifest.json +1 -1
- package/dist/.next/.next/server/app/_not-found/page.js +1 -1
- package/dist/.next/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/dist/.next/.next/server/app/_not-found.html +1 -1
- package/dist/.next/.next/server/app/_not-found.rsc +2 -2
- package/dist/.next/.next/server/app/api/cloudflare/route.js +1 -1
- package/dist/.next/.next/server/app/api/cloudflare/route.js.nft.json +1 -1
- package/dist/.next/.next/server/app/api/cloudflare/route_client-reference-manifest.js +1 -1
- package/dist/.next/.next/server/app/api/databases/route.js +1 -1
- package/dist/.next/.next/server/app/api/databases/route.js.nft.json +1 -1
- package/dist/.next/.next/server/app/api/databases/route_client-reference-manifest.js +1 -1
- package/dist/.next/.next/server/app/api/migrations/sync/route.js +3 -3
- package/dist/.next/.next/server/app/api/migrations/sync/route.js.nft.json +1 -1
- package/dist/.next/.next/server/app/api/migrations/sync/route_client-reference-manifest.js +1 -1
- package/dist/.next/.next/server/app/api/migrations/sync-files/route.js +1 -1
- package/dist/.next/.next/server/app/api/migrations/sync-files/route.js.nft.json +1 -1
- package/dist/.next/.next/server/app/api/migrations/sync-files/route_client-reference-manifest.js +1 -1
- package/dist/.next/.next/server/app/api/pull-remote/confirm/route.js +1 -1
- package/dist/.next/.next/server/app/api/pull-remote/confirm/route.js.nft.json +1 -1
- package/dist/.next/.next/server/app/api/pull-remote/confirm/route_client-reference-manifest.js +1 -1
- package/dist/.next/.next/server/app/api/pull-remote/preview/route.js +1 -1
- package/dist/.next/.next/server/app/api/pull-remote/preview/route.js.nft.json +1 -1
- package/dist/.next/.next/server/app/api/pull-remote/preview/route_client-reference-manifest.js +1 -1
- package/dist/.next/.next/server/app/api/push-remote/confirm/route.js +2 -2
- package/dist/.next/.next/server/app/api/push-remote/confirm/route.js.nft.json +1 -1
- package/dist/.next/.next/server/app/api/push-remote/confirm/route_client-reference-manifest.js +1 -1
- package/dist/.next/.next/server/app/api/push-remote/preview/route.js +2 -2
- package/dist/.next/.next/server/app/api/push-remote/preview/route.js.nft.json +1 -1
- package/dist/.next/.next/server/app/api/push-remote/preview/route_client-reference-manifest.js +1 -1
- package/dist/.next/.next/server/app/api/query/route.js +2 -2
- package/dist/.next/.next/server/app/api/query/route.js.nft.json +1 -1
- package/dist/.next/.next/server/app/api/query/route_client-reference-manifest.js +1 -1
- package/dist/.next/.next/server/app/api/tables/[name]/route.js +4 -4
- package/dist/.next/.next/server/app/api/tables/[name]/route.js.nft.json +1 -1
- package/dist/.next/.next/server/app/api/tables/[name]/route_client-reference-manifest.js +1 -1
- package/dist/.next/.next/server/app/api/tables/route.js +2 -2
- package/dist/.next/.next/server/app/api/tables/route.js.nft.json +1 -1
- package/dist/.next/.next/server/app/api/tables/route_client-reference-manifest.js +1 -1
- package/dist/.next/.next/server/app/api/update/route.js +5 -0
- package/dist/.next/.next/server/app/api/update/route.js.nft.json +1 -0
- package/dist/.next/.next/server/app/api/update/route_client-reference-manifest.js +1 -0
- package/dist/.next/.next/server/app/index.html +3 -3
- package/dist/.next/.next/server/app/index.rsc +3 -3
- package/dist/.next/.next/server/app/page.js +14 -12
- package/dist/.next/.next/server/app/page_client-reference-manifest.js +1 -1
- package/dist/.next/.next/server/app-paths-manifest.json +2 -1
- package/dist/.next/.next/server/chunks/336.js +1 -1
- package/dist/.next/.next/server/chunks/391.js +23 -0
- package/dist/.next/.next/server/chunks/452.js +1 -0
- package/dist/.next/.next/server/chunks/627.js +3 -3
- package/dist/.next/.next/server/chunks/638.js +3 -3
- package/dist/.next/.next/server/chunks/686.js +1 -1
- package/dist/.next/.next/server/chunks/801.js +55 -0
- package/dist/.next/.next/server/chunks/992.js +3 -3
- package/dist/.next/.next/server/pages/404.html +1 -1
- package/dist/.next/.next/server/pages/500.html +1 -1
- package/dist/.next/.next/server/pages/_app.js +1 -1
- package/dist/.next/.next/server/pages/_document.js +1 -1
- package/dist/.next/.next/server/pages/_error.js +1 -1
- package/dist/.next/.next/server/pages-manifest.json +1 -1
- package/dist/.next/.next/server/server-reference-manifest.json +1 -1
- package/dist/.next/.next/static/JrwgdSDcipr0Zh7k19Cj_/_buildManifest.js +1 -0
- package/dist/.next/.next/static/chunks/958-98887928efebfdf7.js +1 -0
- package/dist/.next/.next/static/chunks/app/api/cloudflare/route-5133155a604f2719.js +1 -0
- package/dist/.next/.next/static/chunks/app/api/databases/route-63a31080b565794e.js +1 -0
- package/dist/.next/.next/static/chunks/app/api/migrations/sync/route-d97667565b4a59b6.js +1 -0
- package/dist/.next/.next/static/chunks/app/api/migrations/sync-files/route-7089bcbfeb6b5260.js +1 -0
- package/dist/.next/.next/static/chunks/app/api/pull-remote/confirm/route-9143e6e4c3f05162.js +1 -0
- package/dist/.next/.next/static/chunks/app/api/pull-remote/preview/route-c963d143a51aed66.js +1 -0
- package/dist/.next/.next/static/chunks/app/api/push-remote/confirm/route-072132c0a6cb3df3.js +1 -0
- package/dist/.next/.next/static/chunks/app/api/push-remote/preview/route-ca6bf35aa72661ee.js +1 -0
- package/dist/.next/.next/static/chunks/app/api/query/route-1466f6b7ffd8b6c0.js +1 -0
- package/dist/.next/.next/static/chunks/app/api/tables/[name]/route-898d3f85fc8544c4.js +1 -0
- package/dist/.next/.next/static/chunks/app/api/tables/route-91650359fc3735cb.js +1 -0
- package/dist/.next/.next/static/chunks/app/api/update/route-504d663df9124f97.js +1 -0
- package/dist/.next/.next/static/chunks/app/page-2c28a255a4ecd8d4.js +1 -0
- package/dist/.next/.next/static/chunks/app/page-3db7feef57019055.js +1 -0
- package/dist/.next/.next/static/css/4957328384ed5c42.css +3 -0
- package/dist/.next/.next/static/gc8l1G6KXOeLLOM7VJip6/_buildManifest.js +1 -0
- package/dist/.next/.next/static/gc8l1G6KXOeLLOM7VJip6/_ssgManifest.js +1 -0
- package/dist/.next/.next/static/kYsJoni86CJWDuTkc1xU6/_buildManifest.js +1 -0
- package/dist/.next/.next/static/kYsJoni86CJWDuTkc1xU6/_ssgManifest.js +1 -0
- package/dist/.next/.next/static/scC5qwQC9H7rR1groM0Q-/_ssgManifest.js +1 -0
- package/dist/.next/.next/static/tEHOI_-t-iqfJClNzuo9m/_buildManifest.js +1 -0
- package/dist/.next/.next/static/tEHOI_-t-iqfJClNzuo9m/_ssgManifest.js +1 -0
- package/dist/.next/.next/static/vin2VQs5pM_dH2e2_I7AN/_buildManifest.js +1 -0
- package/dist/.next/.next/static/vin2VQs5pM_dH2e2_I7AN/_ssgManifest.js +1 -0
- package/dist/.next/.next/static/wHKwQhaxin5_i06GFVDHb/_buildManifest.js +1 -0
- package/dist/.next/.next/static/wHKwQhaxin5_i06GFVDHb/_ssgManifest.js +1 -0
- package/dist/.next/.next/static/xW4MspD8XibrhXDi_q2IO/_buildManifest.js +1 -0
- package/dist/.next/.next/static/xW4MspD8XibrhXDi_q2IO/_ssgManifest.js +1 -0
- package/dist/.next/.next/trace +3 -3
- package/dist/.next/.next/types/app/api/update/route.ts +347 -0
- package/dist/.next/BUILD_ID +1 -1
- package/dist/.next/app-build-manifest.json +17 -17
- package/dist/.next/app-path-routes-manifest.json +1 -1
- package/dist/.next/build-manifest.json +2 -2
- package/dist/.next/cache/.rscinfo +1 -1
- package/dist/.next/cache/.tsbuildinfo +1 -1
- package/dist/.next/cache/webpack/client-production/0.pack +0 -0
- package/dist/.next/cache/webpack/client-production/index.pack +0 -0
- package/dist/.next/cache/webpack/edge-server-production/index.pack +0 -0
- package/dist/.next/cache/webpack/server-production/0.pack +0 -0
- package/dist/.next/cache/webpack/server-production/index.pack +0 -0
- package/dist/.next/next-minimal-server.js.nft.json +1 -1
- package/dist/.next/next-server.js.nft.json +1 -1
- package/dist/.next/prerender-manifest.json +1 -1
- package/dist/.next/server/app/_not-found.html +1 -1
- package/dist/.next/server/app/_not-found.rsc +1 -1
- package/dist/.next/server/app/api/cloudflare/route.js +1 -1
- package/dist/.next/server/app/api/databases/route.js +1 -1
- package/dist/.next/server/app/api/migrations/sync/route.js +3 -3
- package/dist/.next/server/app/api/migrations/sync/route.js.nft.json +1 -1
- package/dist/.next/server/app/api/migrations/sync-files/route.js +1 -1
- package/dist/.next/server/app/api/migrations/sync-files/route.js.nft.json +1 -1
- package/dist/.next/server/app/api/pull-remote/confirm/route.js +1 -1
- package/dist/.next/server/app/api/pull-remote/confirm/route.js.nft.json +1 -1
- package/dist/.next/server/app/api/pull-remote/preview/route.js +1 -1
- package/dist/.next/server/app/api/pull-remote/preview/route.js.nft.json +1 -1
- package/dist/.next/server/app/api/push-remote/confirm/route.js +2 -2
- package/dist/.next/server/app/api/push-remote/confirm/route.js.nft.json +1 -1
- package/dist/.next/server/app/api/push-remote/preview/route.js +2 -2
- package/dist/.next/server/app/api/push-remote/preview/route.js.nft.json +1 -1
- package/dist/.next/server/app/api/query/route.js +2 -2
- package/dist/.next/server/app/api/query/route.js.nft.json +1 -1
- package/dist/.next/server/app/api/tables/[name]/route.js +4 -4
- package/dist/.next/server/app/api/tables/route.js +2 -2
- package/dist/.next/server/app/index.html +1 -1
- package/dist/.next/server/app/index.rsc +1 -1
- package/dist/.next/server/app-paths-manifest.json +6 -6
- package/dist/.next/server/chunks/801.js +55 -0
- package/dist/.next/server/pages/404.html +1 -1
- package/dist/.next/server/pages/500.html +1 -1
- package/dist/.next/server/server-reference-manifest.json +1 -1
- package/dist/.next/static/ZwNOdZJ0LOtE0AJMNWwzY/_buildManifest.js +1 -0
- package/dist/.next/static/ZwNOdZJ0LOtE0AJMNWwzY/_ssgManifest.js +1 -0
- package/dist/.next/trace +14 -14
- package/dist/app/api/cloudflare/route.js +5 -1
- package/dist/app/api/databases/route.js +3 -4
- package/dist/app/api/migrations/sync/route.js +5 -3
- package/dist/app/api/pull-remote/confirm/route.js +24 -23
- package/dist/app/api/pull-remote/preview/route.js +4 -3
- package/dist/app/api/push-remote/preview/route.js +3 -2
- package/dist/app/api/query/route.js +11 -3
- package/dist/app/api/tables/[name]/route.js +3 -2
- package/dist/app/api/tables/route.js +6 -2
- package/dist/app/app/api/cloudflare/route.js +5 -1
- package/dist/app/app/api/databases/route.js +3 -4
- package/dist/app/app/api/migrations/sync/route.js +5 -3
- package/dist/app/app/api/pull-remote/confirm/route.js +24 -23
- package/dist/app/app/api/pull-remote/preview/route.js +4 -3
- package/dist/app/app/api/push-remote/preview/route.js +3 -2
- package/dist/app/app/api/query/route.js +11 -3
- package/dist/app/app/api/tables/[name]/route.js +3 -2
- package/dist/app/app/api/tables/route.js +6 -2
- package/dist/app/app/api/update/route.js +11 -0
- package/dist/app/app/page.jsx +7 -1
- package/dist/d1-studio.js +94 -58
- package/dist/lib/database-queue.js +34 -30
- package/dist/lib/find-wrangler-config.js +14 -8
- package/dist/lib/logger.js +11 -2
- package/dist/lib/migrations.js +4 -4
- package/dist/lib/schema-operations.js +4 -1
- package/dist/lib/sql-operations.js +8 -1
- package/package.json +5 -2
- package/scripts/studio.js +94 -58
- package/scripts/test.js +280 -82
- package/src/app/api/cloudflare/route.js +5 -1
- package/src/app/api/databases/route.js +3 -4
- package/src/app/api/migrations/sync/route.js +5 -3
- package/src/app/api/pull-remote/confirm/route.js +24 -23
- package/src/app/api/pull-remote/preview/route.js +4 -3
- package/src/app/api/push-remote/preview/route.js +3 -2
- package/src/app/api/query/route.js +11 -3
- package/src/app/api/tables/[name]/route.js +3 -2
- package/src/app/api/tables/route.js +6 -2
- package/src/app/api/update/route.js +11 -0
- package/src/app/page.jsx +7 -1
- package/src/components/update-banner.jsx +64 -0
- package/src/lib/database-queue.js +34 -30
- package/src/lib/find-wrangler-config.js +14 -8
- package/src/lib/logger.js +11 -2
- package/src/lib/migrations.js +4 -4
- package/src/lib/schema-operations.js +4 -1
- package/src/lib/sql-operations.js +8 -1
- package/dist/.next/.next/server/chunks/603.js +0 -55
- package/dist/.next/server/chunks/603.js +0 -55
- /package/dist/.next/.next/static/{q6WmQmyONe88bMN0_jrC2 → IWRJZhjf8U8mjzz4h0VNE}/_buildManifest.js +0 -0
- /package/dist/.next/.next/static/{q6WmQmyONe88bMN0_jrC2 → IWRJZhjf8U8mjzz4h0VNE}/_ssgManifest.js +0 -0
- /package/dist/.next/{static/Tk1fnz_CXLavm23ZEeChG → .next/static/JrwgdSDcipr0Zh7k19Cj_}/_ssgManifest.js +0 -0
- /package/dist/.next/{static/Tk1fnz_CXLavm23ZEeChG → .next/static/scC5qwQC9H7rR1groM0Q-}/_buildManifest.js +0 -0
|
@@ -20,4 +20,4 @@ ${t}`,c.pop(),`[${e}]`}let i=Object.keys(h),g=i.length;if(0===g)return"{}";if(b<
|
|
|
20
20
|
${d}`,y="",v="",_=Math.min(g,w);l(h)&&(y+=u(h,m,w),i=i.slice(h.length),_-=h.length,v=m),n&&(i=o(i,a)),c.push(h);for(let e=0;e<_;e++){let t=i[e],r=x(t,h[t],c,f,d);void 0!==r&&(y+=`${v}${s(t)}: ${r}`,v=m)}if(g>w){let e=g-w;y+=`${v}"...": "${p(e)} not stringified"`,v=m}return""!==v&&(y=`
|
|
21
21
|
${d}${y}
|
|
22
22
|
${t}`),c.pop(),`{${y}}`}case"number":return isFinite(h)?String(h):t?t(h):"null";case"boolean":return!0===h?"true":"false";case"undefined":return;case"bigint":if(i)return String(h);default:return t?t(h):void 0}}function _(e,h,c){switch(typeof h){case"string":return s(h);case"object":{if(null===h)return"null";if("function"==typeof h.toJSON){if("object"!=typeof(h=h.toJSON(e)))return _(e,h,c);if(null===h)return"null"}if(-1!==c.indexOf(h))return r;let t="",i=void 0!==h.length;if(i&&Array.isArray(h)){if(0===h.length)return"[]";if(b<c.length+1)return'"[Array]"';c.push(h);let e=Math.min(h.length,w),r=0;for(;r<e-1;r++){let e=_(String(r),h[r],c);t+=void 0!==e?e:"null",t+=","}let i=_(String(r),h[r],c);if(t+=void 0!==i?i:"null",h.length-1>w){let e=h.length-w-1;t+=`,"... ${p(e)} not stringified"`}return c.pop(),`[${t}]`}let f=Object.keys(h),d=f.length;if(0===d)return"{}";if(b<c.length+1)return'"[Object]"';let g="",m=Math.min(d,w);i&&l(h)&&(t+=u(h,",",w),f=f.slice(h.length),m-=h.length,g=","),n&&(f=o(f,a)),c.push(h);for(let e=0;e<m;e++){let r=f[e],i=_(r,h[r],c);void 0!==i&&(t+=`${g}${s(r)}:${i}`,g=",")}if(d>w){let e=d-w;t+=`${g}"...":"${p(e)} not stringified"`}return c.pop(),`{${t}}`}case"number":return isFinite(h)?String(h):t?t(h):"null";case"boolean":return!0===h?"true":"false";case"undefined":return;case"bigint":if(i)return String(h);default:return t?t(h):void 0}}return function(e,t,r){if(arguments.length>1){let i="";if("number"==typeof r?i=" ".repeat(Math.min(r,10)):"string"==typeof r&&(i=r.slice(0,10)),null!=t){if("function"==typeof t)return y("",{"":e},[],t,i,"");if(Array.isArray(t))return v("",e,[],g(t),i,"")}if(0!==i.length)return x("",e,[],i,"")}return _("",e,[])}}},9312:(e,t)=>{function r(e){for(var t in e)this[t]=e[t]}t.get=function(e){var r=Error.stackTraceLimit;Error.stackTraceLimit=1/0;var i={},n=Error.prepareStackTrace;Error.prepareStackTrace=function(e,t){return t},Error.captureStackTrace(i,e||t.get);var s=i.stack;return Error.prepareStackTrace=n,Error.stackTraceLimit=r,s},t.parse=function(e){if(!e.stack)return[];var t=this;return e.stack.split("\n").slice(1).map(function(e){if(e.match(/^\s*[-]{4,}$/))return t._createParsedCallSite({fileName:e,lineNumber:null,functionName:null,typeName:null,methodName:null,columnNumber:null,native:null});var r=e.match(/at (?:(.+)\s+\()?(?:(.+?):(\d+)(?::(\d+))?|([^)]+))\)?/);if(r){var i=null,n=null,s=null,o=null,a=null,l="native"===r[5];if(r[1]){var u=(s=r[1]).lastIndexOf(".");if("."==s[u-1]&&u--,u>0){i=s.substr(0,u),n=s.substr(u+1);var h=i.indexOf(".Module");h>0&&(s=s.substr(h+1),i=i.substr(0,h))}o=null}n&&(o=i,a=n),"<anonymous>"===n&&(a=null,s=null);var c={fileName:r[2]||null,lineNumber:parseInt(r[3],10)||null,functionName:s,typeName:o,methodName:a,columnNumber:parseInt(r[4],10)||null,native:l};return t._createParsedCallSite(c)}}).filter(function(e){return!!e})};var i=["topLevel","eval","native","constructor"];["this","typeName","functionName","methodName","fileName","lineNumber","columnNumber","function","evalOrigin"].forEach(function(e){r.prototype[e]=null,r.prototype["get"+e[0].toUpperCase()+e.substr(1)]=function(){return this[e]}}),i.forEach(function(e){r.prototype[e]=!1,r.prototype["is"+e[0].toUpperCase()+e.substr(1)]=function(){return this[e]}}),t._createParsedCallSite=function(e){return new r(e)}},8333:(e,t,r)=>{"use strict";var i=r(5957).Buffer,n=i.isEncoding||function(e){switch((e=""+e)&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function s(e){var t;if(!e)return"utf8";for(;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}function o(e){var t=s(e);if("string"!=typeof t&&(i.isEncoding===n||!n(e)))throw Error("Unknown encoding: "+e);return t||e}function a(e){var t;switch(this.encoding=o(e),this.encoding){case"utf16le":this.text=p,this.end=g,t=4;break;case"utf8":this.fillLast=c,t=4;break;case"base64":this.text=m,this.end=b,t=3;break;default:this.write=w,this.end=y;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=i.allocUnsafe(t)}function l(e){return e<=127?0:e>>5==6?2:e>>4==14?3:e>>3==30?4:e>>6==2?-1:-2}function u(e,t,r){var i=t.length-1;if(i<r)return 0;var n=l(t[i]);return n>=0?(n>0&&(e.lastNeed=n-1),n):--i<r||-2===n?0:(n=l(t[i]))>=0?(n>0&&(e.lastNeed=n-2),n):--i<r||-2===n?0:(n=l(t[i]))>=0?(n>0&&(2===n?n=0:e.lastNeed=n-3),n):0}function h(e,t,r){if((192&t[0])!=128)return e.lastNeed=0,"�";if(e.lastNeed>1&&t.length>1){if((192&t[1])!=128)return e.lastNeed=1,"�";if(e.lastNeed>2&&t.length>2&&(192&t[2])!=128)return e.lastNeed=2,"�"}}function c(e){var t=this.lastTotal-this.lastNeed,r=h(this,e,t);return void 0!==r?r:this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):void(e.copy(this.lastChar,t,0,e.length),this.lastNeed-=e.length)}function f(e,t){var r=u(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=r;var i=e.length-(r-this.lastNeed);return e.copy(this.lastChar,0,i),e.toString("utf8",t,i)}function d(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+"�":t}function p(e,t){if((e.length-t)%2==0){var r=e.toString("utf16le",t);if(r){var i=r.charCodeAt(r.length-1);if(i>=55296&&i<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function g(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,r)}return t}function m(e,t){var r=(e.length-t)%3;return 0===r?e.toString("base64",t):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-r))}function b(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function w(e){return e.toString(this.encoding)}function y(e){return e&&e.length?this.write(e):""}t.I=a,a.prototype.write=function(e){var t,r;if(0===e.length)return"";if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r<e.length?t?t+this.text(e,r):this.text(e,r):t||""},a.prototype.end=d,a.prototype.text=f,a.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length}},1292:(e,t)=>{"use strict";t.levels={error:0,warn:1,help:2,data:3,info:4,debug:5,prompt:6,verbose:7,input:8,silly:9},t.colors={error:"red",warn:"yellow",help:"cyan",data:"grey",info:"green",debug:"blue",prompt:"grey",verbose:"cyan",input:"grey",silly:"magenta"}},7062:(e,t,r)=>{"use strict";Object.defineProperty(t,"cli",{value:r(1292)}),Object.defineProperty(t,"npm",{value:r(2e3)}),Object.defineProperty(t,"syslog",{value:r(7349)})},2e3:(e,t)=>{"use strict";t.levels={error:0,warn:1,info:2,http:3,verbose:4,debug:5,silly:6},t.colors={error:"red",warn:"yellow",info:"green",http:"green",verbose:"cyan",debug:"blue",silly:"magenta"}},7349:(e,t)=>{"use strict";t.levels={emerg:0,alert:1,crit:2,error:3,warning:4,notice:5,info:6,debug:7},t.colors={emerg:"red",alert:"yellow",crit:"red",error:"red",warning:"red",notice:"yellow",info:"green",debug:"blue"}},2239:(e,t,r)=>{"use strict";Object.defineProperty(t,"LEVEL",{value:Symbol.for("level")}),Object.defineProperty(t,"MESSAGE",{value:Symbol.for("message")}),Object.defineProperty(t,"SPLAT",{value:Symbol.for("splat")}),Object.defineProperty(t,"configs",{value:r(7062)})},1387:(e,t,r)=>{e.exports=r(8354).deprecate},9747:(e,t,r)=>{"use strict";e.exports=r(3744),e.exports.LegacyTransportStream=r(1352)},1352:(e,t,r)=>{"use strict";let i=r(8354),{LEVEL:n}=r(2239),s=r(3744),o=e.exports=function(e={}){if(s.call(this,e),!e.transport||"function"!=typeof e.transport.log)throw Error("Invalid transport, must be an object with a log method.");function t(e){this.emit("error",e,this.transport)}this.transport=e.transport,this.level=this.level||e.transport.level,this.handleExceptions=this.handleExceptions||e.transport.handleExceptions,this._deprecated(),this.transport.__winstonError||(this.transport.__winstonError=t.bind(this),this.transport.on("error",this.transport.__winstonError))};i.inherits(o,s),o.prototype._write=function(e,t,r){if(this.silent||!0===e.exception&&!this.handleExceptions)return r(null);(!this.level||this.levels[this.level]>=this.levels[e[n]])&&this.transport.log(e[n],e.message,e,this._nop),r(null)},o.prototype._writev=function(e,t){for(let t=0;t<e.length;t++)this._accept(e[t])&&(this.transport.log(e[t].chunk[n],e[t].chunk.message,e[t].chunk,this._nop),e[t].callback());return t(null)},o.prototype._deprecated=function(){console.error(`${this.transport.name} is a legacy winston transport. Consider upgrading:
|
|
23
|
-
- Upgrade docs: https://github.com/winstonjs/winston/blob/master/UPGRADE-3.0.md`)},o.prototype.close=function(){this.transport.close&&this.transport.close(),this.transport.__winstonError&&(this.transport.removeListener("error",this.transport.__winstonError),this.transport.__winstonError=null)}},3744:(e,t,r)=>{"use strict";let i=r(8354),n=r(6324),{LEVEL:s}=r(2239),o=e.exports=function(e={}){n.call(this,{objectMode:!0,highWaterMark:e.highWaterMark}),this.format=e.format,this.level=e.level,this.handleExceptions=e.handleExceptions,this.handleRejections=e.handleRejections,this.silent=e.silent,e.log&&(this.log=e.log),e.logv&&(this.logv=e.logv),e.close&&(this.close=e.close),this.once("pipe",e=>{this.levels=e.levels,this.parent=e}),this.once("unpipe",e=>{e===this.parent&&(this.parent=null,this.close&&this.close())})};i.inherits(o,n),o.prototype._write=function(e,t,r){if(this.silent||!0===e.exception&&!this.handleExceptions)return r(null);let i=this.level||this.parent&&this.parent.level;if(!i||this.levels[i]>=this.levels[e[s]]){let t,i;if(e&&!this.format)return this.log(e,r);try{i=this.format.transform(Object.assign({},e),this.format.options)}catch(e){t=e}if(t||!i){if(r(),t)throw t;return}return this.log(i,r)}return this._writableState.sync=!1,r(null)},o.prototype._writev=function(e,t){if(this.logv){let r=e.filter(this._accept,this);return r.length?this.logv(r,t):t(null)}for(let r=0;r<e.length;r++){let i,n;if(this._accept(e[r])){if(e[r].chunk&&!this.format){this.log(e[r].chunk,e[r].callback);continue}try{n=this.format.transform(Object.assign({},e[r].chunk),this.format.options)}catch(e){i=e}if(i||!n){if(e[r].callback(),i)throw t(null),i}else this.log(n,e[r].callback)}}return t(null)},o.prototype._accept=function(e){let t=e.chunk;if(this.silent)return!1;let r=this.level||this.parent&&this.parent.level;return(!0===t.exception||!r||this.levels[r]>=this.levels[t[s]])&&(!!this.handleExceptions||!0!==t.exception)},o.prototype._nop=function(){}},6399:(e,t,r)=>{"use strict";let i=r(51),{warn:n}=r(3563);t.version=r(5040).version,t.transports=r(4279),t.config=r(5211),t.addColors=i.levels,t.format=i.format,t.createLogger=r(6747),t.Logger=r(1190),t.ExceptionHandler=r(608),t.RejectionHandler=r(3930),t.Container=r(6735),t.Transport=r(9747),t.loggers=new t.Container;let s=t.createLogger();Object.keys(t.config.npm.levels).concat(["log","query","stream","add","remove","clear","profile","startTimer","handleExceptions","unhandleExceptions","handleRejections","unhandleRejections","configure","child"]).forEach(e=>t[e]=(...t)=>s[e](...t)),Object.defineProperty(t,"level",{get:()=>s.level,set(e){s.level=e}}),Object.defineProperty(t,"exceptions",{get:()=>s.exceptions}),Object.defineProperty(t,"rejections",{get:()=>s.rejections}),["exitOnError"].forEach(e=>{Object.defineProperty(t,e,{get:()=>s[e],set(t){s[e]=t}})}),Object.defineProperty(t,"default",{get:()=>({exceptionHandlers:s.exceptionHandlers,rejectionHandlers:s.rejectionHandlers,transports:s.transports})}),n.deprecated(t,"setLevels"),n.forFunctions(t,"useFormat",["cli"]),n.forProperties(t,"useFormat",["padLevels","stripColors"]),n.forFunctions(t,"deprecated",["addRewriter","addFilter","clone","extend"]),n.forProperties(t,"deprecated",["emitErrs","levelLength"])},3563:(e,t,r)=>{"use strict";let{format:i}=r(8354);t.warn={deprecated:e=>()=>{throw Error(i("{ %s } was removed in winston@3.0.0.",e))},useFormat:e=>()=>{throw Error([i("{ %s } was removed in winston@3.0.0.",e),"Use a custom winston.format = winston.format(function) instead."].join("\n"))},forFunctions(e,r,i){i.forEach(i=>{e[i]=t.warn[r](i)})},forProperties(e,r,i){i.forEach(i=>{let n=t.warn[r](i);Object.defineProperty(e,i,{get:n,set:n})})}}},5211:(e,t,r)=>{"use strict";let i=r(51),{configs:n}=r(2239);t.cli=i.levels(n.cli),t.npm=i.levels(n.npm),t.syslog=i.levels(n.syslog),t.addColors=i.levels},6735:(e,t,r)=>{"use strict";let i=r(6747);e.exports=class{constructor(e={}){this.loggers=new Map,this.options=e}add(e,t){if(!this.loggers.has(e)){let r=(t=Object.assign({},t||this.options)).transports||this.options.transports;r?t.transports=Array.isArray(r)?r.slice():[r]:t.transports=[];let n=i(t);n.on("close",()=>this._delete(e)),this.loggers.set(e,n)}return this.loggers.get(e)}get(e,t){return this.add(e,t)}has(e){return!!this.loggers.has(e)}close(e){if(e)return this._removeLogger(e);this.loggers.forEach((e,t)=>this._removeLogger(t))}_removeLogger(e){this.loggers.has(e)&&(this.loggers.get(e).close(),this._delete(e))}_delete(e){this.loggers.delete(e)}}},6747:(e,t,r)=>{"use strict";let{LEVEL:i}=r(2239),n=r(5211),s=r(1190),o=r(1298)("winston:create-logger");function a(e){return"is"+e.charAt(0).toUpperCase()+e.slice(1)+"Enabled"}e.exports=function(e={}){e.levels=e.levels||n.npm.levels;class t extends s{constructor(e){super(e)}}let r=new t(e);return Object.keys(e.levels).forEach(function(e){if(o('Define prototype method for "%s"',e),"log"===e){console.warn('Level "log" not defined: conflicts with the method "log". Use a different level name.');return}t.prototype[e]=function(...t){let n=this||r;if(1===t.length){let[s]=t,o=s&&s.message&&s||{message:s};return o.level=o[i]=e,n._addDefaultMeta(o),n.write(o),this||r}return 0===t.length?(n.log(e,""),n):n.log(e,...t)},t.prototype[a(e)]=function(){return(this||r).isLevelEnabled(e)}}),r}},608:(e,t,r)=>{"use strict";let i=r(1820),n=r(3529),s=r(1298)("winston:exception"),o=r(3927),a=r(9312),l=r(5002);e.exports=class{constructor(e){if(!e)throw Error("Logger is required to handle exceptions");this.logger=e,this.handlers=new Map}handle(...e){e.forEach(e=>{if(Array.isArray(e))return e.forEach(e=>this._addHandler(e));this._addHandler(e)}),this.catcher||(this.catcher=this._uncaughtException.bind(this),process.on("uncaughtException",this.catcher))}unhandle(){this.catcher&&(process.removeListener("uncaughtException",this.catcher),this.catcher=!1,Array.from(this.handlers.values()).forEach(e=>this.logger.unpipe(e)))}getAllInfo(e){let t=null;return e&&(t="string"==typeof e?e:e.message),{error:e,level:"error",message:[`uncaughtException: ${t||"(no error message)"}`,e&&e.stack||" No stack trace"].join("\n"),stack:e&&e.stack,exception:!0,date:new Date().toString(),process:this.getProcessInfo(),os:this.getOsInfo(),trace:this.getTrace(e)}}getProcessInfo(){return{pid:process.pid,uid:process.getuid?process.getuid():null,gid:process.getgid?process.getgid():null,cwd:process.cwd(),execPath:process.execPath,version:process.version,argv:process.argv,memoryUsage:process.memoryUsage()}}getOsInfo(){return{loadavg:i.loadavg(),uptime:i.uptime()}}getTrace(e){return(e?a.parse(e):a.get()).map(e=>({column:e.getColumnNumber(),file:e.getFileName(),function:e.getFunctionName(),line:e.getLineNumber(),method:e.getMethodName(),native:e.isNative()}))}_addHandler(e){if(!this.handlers.has(e)){e.handleExceptions=!0;let t=new l(e);this.handlers.set(e,t),this.logger.pipe(t)}}_uncaughtException(e){let t;let r=this.getAllInfo(e),i=this._getExceptionHandlers(),a="function"==typeof this.logger.exitOnError?this.logger.exitOnError(e):this.logger.exitOnError;function l(){s("doExit",a),s("process._exiting",process._exiting),a&&!process._exiting&&(t&&clearTimeout(t),process.exit(1))}if(!i.length&&a&&(console.warn("winston: exitOnError cannot be true with no exception handlers."),console.warn("winston: not exiting process."),a=!1),!i||0===i.length)return process.nextTick(l);n(i,(e,t)=>{let r=o(t),i=e.transport||e;function n(e){return()=>{s(e),r()}}i._ending=!0,i.once("finish",n("finished")),i.once("error",n("error"))},()=>a&&l()),this.logger.log(r),a&&(t=setTimeout(l,3e3))}_getExceptionHandlers(){return this.logger.transports.filter(e=>(e.transport||e).handleExceptions)}}},5002:(e,t,r)=>{"use strict";let{Writable:i}=r(2826);e.exports=class extends i{constructor(e){if(super({objectMode:!0}),!e)throw Error("ExceptionStream requires a TransportStream instance.");this.handleExceptions=!0,this.transport=e}_write(e,t,r){return e.exception?this.transport.log(e,r):(r(),!0)}}},1190:(e,t,r)=>{"use strict";let{Stream:i,Transform:n}=r(2826),s=r(3529),{LEVEL:o,SPLAT:a}=r(2239),l=r(6696),u=r(608),h=r(3930),c=r(1352),f=r(3659),{warn:d}=r(3563),p=r(5211),g=/%[scdjifoO%]/g;class m extends n{constructor(e){super({objectMode:!0}),this.configure(e)}child(e){let t=this;return Object.create(t,{write:{value:function(r){let i=Object.assign({},e,r);r instanceof Error&&(i.stack=r.stack,i.message=r.message),t.write(i)}}})}configure({silent:e,format:t,defaultMeta:i,levels:n,level:s="info",exitOnError:o=!0,transports:a,colors:l,emitErrs:c,formatters:f,padLevels:d,rewriters:g,stripColors:m,exceptionHandlers:b,rejectionHandlers:w}={}){if(this.transports.length&&this.clear(),this.silent=e,this.format=t||this.format||r(9161)(),this.defaultMeta=i||null,this.levels=n||this.levels||p.npm.levels,this.level=s,this.exceptions&&this.exceptions.unhandle(),this.rejections&&this.rejections.unhandle(),this.exceptions=new u(this),this.rejections=new h(this),this.profilers={},this.exitOnError=o,a&&(a=Array.isArray(a)?a:[a]).forEach(e=>this.add(e)),l||c||f||d||g||m)throw Error("{ colors, emitErrs, formatters, padLevels, rewriters, stripColors } were removed in winston@3.0.0.\nUse a custom winston.format(function) instead.\nSee: https://github.com/winstonjs/winston/tree/master/UPGRADE-3.0.md");b&&this.exceptions.handle(b),w&&this.rejections.handle(w)}isLevelEnabled(e){let t=b(this.levels,e);if(null===t)return!1;let r=b(this.levels,this.level);return null!==r&&(this.transports&&0!==this.transports.length?-1!==this.transports.findIndex(e=>{let i=b(this.levels,e.level);return null===i&&(i=r),i>=t}):r>=t)}log(e,t,...r){if(1==arguments.length)return e[o]=e.level,this._addDefaultMeta(e),this.write(e),this;if(2==arguments.length)return t&&"object"==typeof t?t[o]=t.level=e:t={[o]:e,level:e,message:t},this._addDefaultMeta(t),this.write(t),this;let[i]=r;if("object"==typeof i&&null!==i&&!(t&&t.match&&t.match(g))){let n=Object.assign({},this.defaultMeta,i,{[o]:e,[a]:r,level:e,message:t});return i.message&&(n.message=`${n.message} ${i.message}`),i.stack&&(n.stack=i.stack),i.cause&&(n.cause=i.cause),this.write(n),this}return this.write(Object.assign({},this.defaultMeta,{[o]:e,[a]:r,level:e,message:t})),this}_transform(e,t,r){if(this.silent)return r();e[o]||(e[o]=e.level),this.levels[e[o]]||0===this.levels[e[o]]||console.error("[winston] Unknown logger level: %s",e[o]),this._readableState.pipes||console.error("[winston] Attempt to write logs with no transports, which can increase memory usage: %j",e);try{this.push(this.format.transform(e,this.format.options))}finally{this._writableState.sync=!1,r()}}_final(e){s(this.transports.slice(),(e,t)=>{if(!e||e.finished)return setImmediate(t);e.once("finish",t),e.end()},e)}add(e){let t=!l(e)||e.log.length>2?new c({transport:e}):e;if(!t._writableState||!t._writableState.objectMode)throw Error("Transports must WritableStreams in objectMode. Set { objectMode: true }.");return this._onEvent("error",t),this._onEvent("warn",t),this.pipe(t),e.handleExceptions&&this.exceptions.handle(),e.handleRejections&&this.rejections.handle(),this}remove(e){if(!e)return this;let t=e;return(!l(e)||e.log.length>2)&&(t=this.transports.filter(t=>t.transport===e)[0]),t&&this.unpipe(t),this}clear(){return this.unpipe(),this}close(){return this.exceptions.unhandle(),this.rejections.unhandle(),this.clear(),this.emit("close"),this}setLevels(){d.deprecated("setLevels")}query(e,t){"function"==typeof e&&(t=e,e={});let r={},i=Object.assign({},(e=e||{}).query||{});function n(t,r){e.query&&"function"==typeof t.formatQuery&&(e.query=t.formatQuery(i)),t.query(e,(i,n)=>{if(i)return r(i);"function"==typeof t.formatResults&&(n=t.formatResults(n,e.format)),r(null,n)})}function o(e,t){n(e,(i,n)=>{t&&((n=i||n)&&(r[e.name]=n),t()),t=null})}s(this.transports.filter(e=>!!e.query),o,()=>t(null,r))}stream(e={}){let t=new i,r=[];return t._streams=r,t.destroy=()=>{let e=r.length;for(;e--;)r[e].destroy()},this.transports.filter(e=>!!e.stream).forEach(i=>{let n=i.stream(e);n&&(r.push(n),n.on("log",e=>{e.transport=e.transport||[],e.transport.push(i.name),t.emit("log",e)}),n.on("error",e=>{e.transport=e.transport||[],e.transport.push(i.name),t.emit("error",e)}))}),t}startTimer(){return new f(this)}profile(e,...t){let r=Date.now();if(this.profilers[e]){let i=this.profilers[e];delete this.profilers[e],"function"==typeof t[t.length-2]&&(console.warn("Callback function no longer supported as of winston@3.0.0"),t.pop());let n="object"==typeof t[t.length-1]?t.pop():{};return n.level=n.level||"info",n.durationMs=r-i,n.message=n.message||e,this.write(n)}return this.profilers[e]=r,this}handleExceptions(...e){console.warn("Deprecated: .handleExceptions() will be removed in winston@4. Use .exceptions.handle()"),this.exceptions.handle(...e)}unhandleExceptions(...e){console.warn("Deprecated: .unhandleExceptions() will be removed in winston@4. Use .exceptions.unhandle()"),this.exceptions.unhandle(...e)}cli(){throw Error("Logger.cli() was removed in winston@3.0.0\nUse a custom winston.formats.cli() instead.\nSee: https://github.com/winstonjs/winston/tree/master/UPGRADE-3.0.md")}_onEvent(e,t){function r(r){"error"!==e||this.transports.includes(t)||this.add(t),this.emit(e,r,t)}t["__winston"+e]||(t["__winston"+e]=r.bind(this),t.on(e,t["__winston"+e]))}_addDefaultMeta(e){this.defaultMeta&&Object.assign(e,this.defaultMeta)}}function b(e,t){let r=e[t];return r||0===r?r:null}Object.defineProperty(m.prototype,"transports",{configurable:!1,enumerable:!0,get(){let{pipes:e}=this._readableState;return Array.isArray(e)?e:[e].filter(Boolean)}}),e.exports=m},3659:(e,t,r)=>{"use strict";class i{constructor(e){let t=r(1190);if("object"!=typeof e||Array.isArray(e)||!(e instanceof t))throw Error("Logger is required for profiling");this.logger=e,this.start=Date.now()}done(...e){"function"==typeof e[e.length-1]&&(console.warn("Callback function no longer supported as of winston@3.0.0"),e.pop());let t="object"==typeof e[e.length-1]?e.pop():{};return t.level=t.level||"info",t.durationMs=Date.now()-this.start,this.logger.write(t)}}e.exports=i},3930:(e,t,r)=>{"use strict";let i=r(1820),n=r(3529),s=r(1298)("winston:rejection"),o=r(3927),a=r(9312),l=r(3448);e.exports=class{constructor(e){if(!e)throw Error("Logger is required to handle rejections");this.logger=e,this.handlers=new Map}handle(...e){e.forEach(e=>{if(Array.isArray(e))return e.forEach(e=>this._addHandler(e));this._addHandler(e)}),this.catcher||(this.catcher=this._unhandledRejection.bind(this),process.on("unhandledRejection",this.catcher))}unhandle(){this.catcher&&(process.removeListener("unhandledRejection",this.catcher),this.catcher=!1,Array.from(this.handlers.values()).forEach(e=>this.logger.unpipe(e)))}getAllInfo(e){let t=null;return e&&(t="string"==typeof e?e:e.message),{error:e,level:"error",message:[`unhandledRejection: ${t||"(no error message)"}`,e&&e.stack||" No stack trace"].join("\n"),stack:e&&e.stack,rejection:!0,date:new Date().toString(),process:this.getProcessInfo(),os:this.getOsInfo(),trace:this.getTrace(e)}}getProcessInfo(){return{pid:process.pid,uid:process.getuid?process.getuid():null,gid:process.getgid?process.getgid():null,cwd:process.cwd(),execPath:process.execPath,version:process.version,argv:process.argv,memoryUsage:process.memoryUsage()}}getOsInfo(){return{loadavg:i.loadavg(),uptime:i.uptime()}}getTrace(e){return(e?a.parse(e):a.get()).map(e=>({column:e.getColumnNumber(),file:e.getFileName(),function:e.getFunctionName(),line:e.getLineNumber(),method:e.getMethodName(),native:e.isNative()}))}_addHandler(e){if(!this.handlers.has(e)){e.handleRejections=!0;let t=new l(e);this.handlers.set(e,t),this.logger.pipe(t)}}_unhandledRejection(e){let t;let r=this.getAllInfo(e),i=this._getRejectionHandlers(),a="function"==typeof this.logger.exitOnError?this.logger.exitOnError(e):this.logger.exitOnError;function l(){s("doExit",a),s("process._exiting",process._exiting),a&&!process._exiting&&(t&&clearTimeout(t),process.exit(1))}if(!i.length&&a&&(console.warn("winston: exitOnError cannot be true with no rejection handlers."),console.warn("winston: not exiting process."),a=!1),!i||0===i.length)return process.nextTick(l);n(i,(e,t)=>{let r=o(t),i=e.transport||e;function n(e){return()=>{s(e),r()}}i._ending=!0,i.once("finish",n("finished")),i.once("error",n("error"))},()=>a&&l()),this.logger.log(r),a&&(t=setTimeout(l,3e3))}_getRejectionHandlers(){return this.logger.transports.filter(e=>(e.transport||e).handleRejections)}}},3448:(e,t,r)=>{"use strict";let{Writable:i}=r(2826);e.exports=class extends i{constructor(e){if(super({objectMode:!0}),!e)throw Error("RejectionStream requires a TransportStream instance.");this.handleRejections=!0,this.transport=e}_write(e,t,r){return e.rejection?this.transport.log(e,r):(r(),!0)}}},7539:(e,t,r)=>{"use strict";let i=r(9021),{StringDecoder:n}=r(1204),{Stream:s}=r(2826);function o(){}e.exports=(e,t)=>{let r=Buffer.alloc(65536),a=new n("utf8"),l=new s,u="",h=0,c=0;return(-1===e.start&&delete e.start,l.readable=!0,l.destroy=()=>{l.destroyed=!0,l.emit("end"),l.emit("close")},i.open(e.file,"a+","0644",(n,s)=>{if(n){t?t(n):l.emit("error",n),l.destroy();return}!function n(){if(l.destroyed){i.close(s,o);return}return i.read(s,r,0,r.length,h,(i,s)=>{if(i){t?t(i):l.emit("error",i),l.destroy();return}if(!s)return u&&((null==e.start||c>e.start)&&(t?t(null,u):l.emit("line",u)),c++,u=""),setTimeout(n,1e3);let o=a.write(r.slice(0,s));t||l.emit("data",o);let f=(o=(u+o).split(/\n+/)).length-1,d=0;for(;d<f;d++)(null==e.start||c>e.start)&&(t?t(null,o[d]):l.emit("line",o[d])),c++;return u=o[f],h+=s,n()})}()}),t)?l.destroy:l}},6718:(e,t,r)=>{"use strict";let i=r(1820),{LEVEL:n,MESSAGE:s}=r(2239),o=r(9747);e.exports=class extends o{constructor(e={}){super(e),this.name=e.name||"console",this.stderrLevels=this._stringArrayToSet(e.stderrLevels),this.consoleWarnLevels=this._stringArrayToSet(e.consoleWarnLevels),this.eol="string"==typeof e.eol?e.eol:i.EOL,this.forceConsole=e.forceConsole||!1,this._consoleLog=console.log.bind(console),this._consoleWarn=console.warn.bind(console),this._consoleError=console.error.bind(console),this.setMaxListeners(30)}log(e,t){if(setImmediate(()=>this.emit("logged",e)),this.stderrLevels[e[n]]){console._stderr&&!this.forceConsole?console._stderr.write(`${e[s]}${this.eol}`):this._consoleError(e[s]),t&&t();return}if(this.consoleWarnLevels[e[n]]){console._stderr&&!this.forceConsole?console._stderr.write(`${e[s]}${this.eol}`):this._consoleWarn(e[s]),t&&t();return}console._stdout&&!this.forceConsole?console._stdout.write(`${e[s]}${this.eol}`):this._consoleLog(e[s]),t&&t()}_stringArrayToSet(e,t){if(!e)return{};if(t=t||"Cannot make set from type other than Array of string elements",!Array.isArray(e))throw Error(t);return e.reduce((e,r)=>{if("string"!=typeof r)throw Error(t);return e[r]=!0,e},{})}}},2089:(e,t,r)=>{"use strict";let i=r(9021),n=r(3873),s=r(3258),o=r(4075),{MESSAGE:a}=r(2239),{Stream:l,PassThrough:u}=r(2826),h=r(9747),c=r(1298)("winston:file"),f=r(1820),d=r(7539);e.exports=class extends h{constructor(e={}){function t(r,...i){i.slice(1).forEach(t=>{if(e[t])throw Error(`Cannot set ${t} and ${r} together`)})}if(super(e),this.name=e.name||"file",this._stream=new u,this._stream.setMaxListeners(30),this._onError=this._onError.bind(this),e.filename||e.dirname)t("filename or dirname","stream"),this._basename=this.filename=e.filename?n.basename(e.filename):"winston.log",this.dirname=e.dirname||n.dirname(e.filename),this.options=e.options||{flags:"a"};else if(e.stream)console.warn("options.stream will be removed in winston@4. Use winston.transports.Stream"),t("stream","filename","maxsize"),this._dest=this._stream.pipe(this._setupStream(e.stream)),this.dirname=n.dirname(this._dest.path);else throw Error("Cannot log to file without filename or stream.");this.maxsize=e.maxsize||null,this.rotationFormat=e.rotationFormat||!1,this.zippedArchive=e.zippedArchive||!1,this.maxFiles=e.maxFiles||null,this.eol="string"==typeof e.eol?e.eol:f.EOL,this.tailable=e.tailable||!1,this.lazy=e.lazy||!1,this._size=0,this._pendingSize=0,this._created=0,this._drain=!1,this._opening=!1,this._ending=!1,this._fileExist=!1,this.dirname&&this._createLogDirIfNotExist(this.dirname),this.lazy||this.open()}finishIfEnding(){this._ending&&(this._opening?this.once("open",()=>{this._stream.once("finish",()=>this.emit("finish")),setImmediate(()=>this._stream.end())}):(this._stream.once("finish",()=>this.emit("finish")),setImmediate(()=>this._stream.end())))}log(e,t=()=>{}){if(this.silent)return t(),!0;if(this._drain){this._stream.once("drain",()=>{this._drain=!1,this.log(e,t)});return}if(this._rotate){this._stream.once("rotate",()=>{this._rotate=!1,this.log(e,t)});return}if(this.lazy){if(!this._fileExist){this._opening||this.open(),this.once("open",()=>{this._fileExist=!0,this.log(e,t)});return}if(this._needsNewFile(this._pendingSize)){this._dest.once("close",()=>{this._opening||this.open(),this.once("open",()=>{this.log(e,t)})});return}}let r=`${e[a]}${this.eol}`,i=Buffer.byteLength(r);function n(){if(this._size+=i,this._pendingSize-=i,c("logged %s %s",this._size,r),this.emit("logged",e),!this._rotate&&!this._opening&&this._needsNewFile()){if(this.lazy){this._endStream(()=>{this.emit("fileclosed")});return}this._rotate=!0,this._endStream(()=>this._rotateFile())}}this._pendingSize+=i,this._opening&&!this.rotatedWhileOpening&&this._needsNewFile(this._size+this._pendingSize)&&(this.rotatedWhileOpening=!0);let s=this._stream.write(r,n.bind(this));return s?t():(this._drain=!0,this._stream.once("drain",()=>{this._drain=!1,t()})),c("written",s,this._drain),this.finishIfEnding(),s}query(e,t){"function"==typeof e&&(t=e,e={}),e=f(e);let r=n.join(this.dirname,this.filename),s="",o=[],a=0,l=i.createReadStream(r,{encoding:"utf8"});function u(e,t){try{let t=JSON.parse(e);c(t)&&h(t)}catch(e){t||l.emit("error",e)}}function h(t){if(e.rows&&o.length>=e.rows&&"desc"!==e.order){l.readable&&l.destroy();return}e.fields&&(t=e.fields.reduce((e,r)=>(e[r]=t[r],e),{})),"desc"===e.order&&o.length>=e.rows&&o.shift(),o.push(t)}function c(t){if(!t||"object"!=typeof t)return;let r=new Date(t.timestamp);if((!e.from||!(r<e.from))&&(!e.until||!(r>e.until))&&(!e.level||e.level===t.level))return!0}function f(e){return(e=e||{}).rows=e.rows||e.limit||10,e.start=e.start||0,e.until=e.until||new Date,"object"!=typeof e.until&&(e.until=new Date(e.until)),e.from=e.from||e.until-864e5,"object"!=typeof e.from&&(e.from=new Date(e.from)),e.order=e.order||"desc",e}l.on("error",e=>{if(l.readable&&l.destroy(),t)return"ENOENT"!==e.code?t(e):t(null,o)}),l.on("data",t=>{let r=(t=(s+t).split(/\n+/)).length-1,i=0;for(;i<r;i++)(!e.start||a>=e.start)&&u(t[i]),a++;s=t[r]}),l.on("close",()=>{s&&u(s,!0),"desc"===e.order&&(o=o.reverse()),t&&t(null,o)})}stream(e={}){let t=n.join(this.dirname,this.filename),r=new l,i={file:t,start:e.start};return r.destroy=d(i,(e,t)=>{if(e)return r.emit("error",e);try{r.emit("data",t),t=JSON.parse(t),r.emit("log",t)}catch(e){r.emit("error",e)}}),r}open(){this.filename&&(this._opening||(this._opening=!0,this.stat((e,t)=>{if(e)return this.emit("error",e);c("stat done: %s { size: %s }",this.filename,t),this._size=t,this._dest=this._createStream(this._stream),this._opening=!1,this.once("open",()=>{this._stream.emit("rotate")||(this._rotate=!1)})})))}stat(e){let t=this._getFile(),r=n.join(this.dirname,t);i.stat(r,(i,n)=>i&&"ENOENT"===i.code?(c("ENOENT\xa0ok",r),this.filename=t,e(null,0)):i?(c(`err ${i.code} ${r}`),e(i)):!n||this._needsNewFile(n.size)?this._incFile(()=>this.stat(e)):void(this.filename=t,e(null,n.size)))}close(e){this._stream&&this._stream.end(()=>{e&&e(),this.emit("flush"),this.emit("closed")})}_needsNewFile(e){return e=e||this._size,this.maxsize&&e>=this.maxsize}_onError(e){this.emit("error",e)}_setupStream(e){return e.on("error",this._onError),e}_cleanupStream(e){return e.removeListener("error",this._onError),e.destroy(),e}_rotateFile(){this._incFile(()=>this.open())}_endStream(e=()=>{}){this._dest?(this._stream.unpipe(this._dest),this._dest.end(()=>{this._cleanupStream(this._dest),e()})):e()}_createStream(e){let t=n.join(this.dirname,this.filename);c("create stream start",t,this.options);let r=i.createWriteStream(t,this.options).on("error",e=>c(e)).on("close",()=>c("close",r.path,r.bytesWritten)).on("open",()=>{c("file open ok",t),this.emit("open",t),e.pipe(r),this.rotatedWhileOpening&&(this._stream=new u,this._stream.setMaxListeners(30),this._rotateFile(),this.rotatedWhileOpening=!1,this._cleanupStream(r),e.end())});return c("create stream ok",t),r}_incFile(e){c("_incFile",this.filename);let t=n.extname(this._basename),r=n.basename(this._basename,t),i=[];this.zippedArchive&&i.push((function(e){let i=this._created>0&&!this.tailable?this._created:"";this._compressFile(n.join(this.dirname,`${r}${i}${t}`),n.join(this.dirname,`${r}${i}${t}.gz`),e)}).bind(this)),i.push((function(e){this.tailable?this._checkMaxFilesTailable(t,r,e):(this._created+=1,this._checkMaxFilesIncrementing(t,r,e))}).bind(this)),s(i,e)}_getFile(){let e=n.extname(this._basename),t=n.basename(this._basename,e),r=this.rotationFormat?this.rotationFormat():this._created;return!this.tailable&&this._created?`${t}${r}${e}`:`${t}${e}`}_checkMaxFilesIncrementing(e,t,r){if(!this.maxFiles||this._created<this.maxFiles)return setImmediate(r);let s=this._created-this.maxFiles,o=0!==s?s:"",a=this.zippedArchive?".gz":"",l=`${t}${o}${e}${a}`,u=n.join(this.dirname,l);i.unlink(u,r)}_checkMaxFilesTailable(e,t,r){let o=[];if(!this.maxFiles)return;let a=this.zippedArchive?".gz":"";for(let r=this.maxFiles-1;r>1;r--)o.push((function(r,s){let o=`${t}${r-1}${e}${a}`,l=n.join(this.dirname,o);i.exists(l,u=>{if(!u)return s(null);o=`${t}${r}${e}${a}`,i.rename(l,n.join(this.dirname,o),s)})}).bind(this,r));s(o,()=>{i.rename(n.join(this.dirname,`${t}${e}${a}`),n.join(this.dirname,`${t}1${e}${a}`),r)})}_compressFile(e,t,r){i.access(e,i.F_OK,n=>{if(n)return r();var s=o.createGzip(),a=i.createReadStream(e),l=i.createWriteStream(t);l.on("finish",()=>{i.unlink(e,r)}),a.pipe(s).pipe(l)})}_createLogDirIfNotExist(e){i.existsSync(e)||i.mkdirSync(e,{recursive:!0})}}},5307:(e,t,r)=>{"use strict";let i=r(1630),n=r(5591),{Stream:s}=r(2826),o=r(9747),{configure:a}=r(900);e.exports=class extends o{constructor(e={}){super(e),this.options=e,this.name=e.name||"http",this.ssl=!!e.ssl,this.host=e.host||"localhost",this.port=e.port,this.auth=e.auth,this.path=e.path||"",this.maximumDepth=e.maximumDepth,this.agent=e.agent,this.headers=e.headers||{},this.headers["content-type"]="application/json",this.batch=e.batch||!1,this.batchInterval=e.batchInterval||5e3,this.batchCount=e.batchCount||10,this.batchOptions=[],this.batchTimeoutID=-1,this.batchCallback={},this.port||(this.port=this.ssl?443:80)}log(e,t){this._request(e,null,null,(t,r)=>{r&&200!==r.statusCode&&(t=Error(`Invalid HTTP Status Code: ${r.statusCode}`)),t?this.emit("warn",t):this.emit("logged",e)}),t&&setImmediate(t)}query(e,t){"function"==typeof e&&(t=e,e={});let r=(e={method:"query",params:this.normalizeQuery(e)}).params.auth||null;delete e.params.auth;let i=e.params.path||null;delete e.params.path,this._request(e,r,i,(e,r,i)=>{if(r&&200!==r.statusCode&&(e=Error(`Invalid HTTP Status Code: ${r.statusCode}`)),e)return t(e);if("string"==typeof i)try{i=JSON.parse(i)}catch(e){return t(e)}t(null,i)})}stream(e={}){let t=new s,r=(e={method:"stream",params:e}).params.path||null;delete e.params.path;let i=e.params.auth||null;delete e.params.auth;let n="",o=this._request(e,i,r);return t.destroy=()=>o.destroy(),o.on("data",e=>{let r=(e=(n+e).split(/\n+/)).length-1,i=0;for(;i<r;i++)try{t.emit("log",JSON.parse(e[i]))}catch(e){t.emit("error",e)}n=e[r]}),o.on("error",e=>t.emit("error",e)),t}_request(e,t,r,i){e=e||{},t=t||this.auth,r=r||this.path||"",this.batch?this._doBatch(e,i,t,r):this._doRequest(e,i,t,r)}_doBatch(e,t,r,i){if(this.batchOptions.push(e),1===this.batchOptions.length){let e=this;this.batchCallback=t,this.batchTimeoutID=setTimeout(function(){e.batchTimeoutID=-1,e._doBatchRequest(e.batchCallback,r,i)},this.batchInterval)}this.batchOptions.length===this.batchCount&&this._doBatchRequest(this.batchCallback,r,i)}_doBatchRequest(e,t,r){this.batchTimeoutID>0&&(clearTimeout(this.batchTimeoutID),this.batchTimeoutID=-1);let i=this.batchOptions.slice();this.batchOptions=[],this._doRequest(i,e,t,r)}_doRequest(e,t,r,s){let o=Object.assign({},this.headers);r&&r.bearer&&(o.Authorization=`Bearer ${r.bearer}`);let l=(this.ssl?n:i).request({...this.options,method:"POST",host:this.host,port:this.port,path:`/${s.replace(/^\//,"")}`,headers:o,auth:r&&r.username&&r.password?`${r.username}:${r.password}`:"",agent:this.agent});l.on("error",t),l.on("response",e=>e.on("end",()=>t(null,e)).resume());let u=a({...this.maximumDepth&&{maximumDepth:this.maximumDepth}});l.end(Buffer.from(u(e,this.options.replacer),"utf8"))}}},4279:(e,t,r)=>{"use strict";Object.defineProperty(t,"Console",{configurable:!0,enumerable:!0,get:()=>r(6718)}),Object.defineProperty(t,"File",{configurable:!0,enumerable:!0,get:()=>r(2089)}),Object.defineProperty(t,"Http",{configurable:!0,enumerable:!0,get:()=>r(5307)}),Object.defineProperty(t,"Stream",{configurable:!0,enumerable:!0,get:()=>r(1171)})},1171:(e,t,r)=>{"use strict";let i=r(6696),{MESSAGE:n}=r(2239),s=r(1820),o=r(9747);e.exports=class extends o{constructor(e={}){if(super(e),!e.stream||!i(e.stream))throw Error("options.stream is required.");this._stream=e.stream,this._stream.setMaxListeners(1/0),this.isObjectMode=e.stream._writableState.objectMode,this.eol="string"==typeof e.eol?e.eol:s.EOL}log(e,t){if(setImmediate(()=>this.emit("logged",e)),this.isObjectMode){this._stream.write(e),t&&t();return}this._stream.write(`${e[n]}${this.eol}`),t&&t()}}},3149:(e,t,r)=>{"use strict";r.d(t,{dJ:()=>_});var i=r(4379),n=r(1708),s=r(643),o=r(3136);class a{value;next;constructor(e){this.value=e}}class l{#e;#t;#r;constructor(){this.clear()}enqueue(e){let t=new a(e);this.#e?this.#t.next=t:this.#e=t,this.#t=t,this.#r++}dequeue(){let e=this.#e;if(e)return this.#e=this.#e.next,this.#r--,e.value}peek(){if(this.#e)return this.#e.value}clear(){this.#e=void 0,this.#t=void 0,this.#r=0}get size(){return this.#r}*[Symbol.iterator](){let e=this.#e;for(;e;)yield e.value,e=e.next}}function u(e){if(!((Number.isInteger(e)||e===Number.POSITIVE_INFINITY)&&e>0))throw TypeError("Expected `concurrency` to be a number from 1 and up");let t=new l,r=0,i=()=>{r--,t.size>0&&t.dequeue()()},n=async(e,t,n)=>{r++;let s=(async()=>e(...n))();t(s);try{await s}catch{}i()},s=(i,s,o)=>{t.enqueue(n.bind(void 0,i,s,o)),(async()=>{await Promise.resolve(),r<e&&t.size>0&&t.dequeue()()})()},o=(e,...t)=>new Promise(r=>{s(e,r,t)});return Object.defineProperties(o,{activeCount:{get:()=>r},pendingCount:{get:()=>t.size},clearQueue:{value:()=>{t.clear()}}}),o}class h extends Error{constructor(e){super(),this.value=e}}let c=async(e,t)=>t(await e),f=async e=>{let t=await Promise.all(e);if(!0===t[1])throw new h(t[0]);return!1};async function d(e,t,{concurrency:r=Number.POSITIVE_INFINITY,preserveOrder:i=!0}={}){let n=u(r),s=[...e].map(e=>[e,n(c,e,t)]),o=u(i?1:Number.POSITIVE_INFINITY);try{await Promise.all(s.map(e=>o(f,e)))}catch(e){if(e instanceof h)return e.value;throw e}}let p={directory:"isDirectory",file:"isFile"};function g(e){if(!Object.hasOwnProperty.call(p,e))throw Error(`Invalid type specified: ${e}`)}let m=(e,t)=>t[p[e]](),b=e=>e instanceof URL?(0,o.fileURLToPath)(e):e;async function w(e,{cwd:t=n.cwd(),type:r="file",allowSymlinks:o=!0,concurrency:a,preserveOrder:l}={}){g(r),t=b(t);let u=o?s.promises.stat:s.promises.lstat;return d(e,async e=>{try{let n=await u(i.resolve(t,e));return m(r,n)}catch{return!1}},{concurrency:a,preserveOrder:l})}function y(e){return e instanceof URL?(0,o.fileURLToPath)(e):e}let v=Symbol("findUpStop");async function x(e,t={}){let r=i.resolve(y(t.cwd)??""),{root:n}=i.parse(r),s=i.resolve(r,y(t.stopAt??n)),o=t.limit??Number.POSITIVE_INFINITY,a=[e].flat(),l=async t=>{if("function"!=typeof e)return w(a,t);let r=await e(t.cwd);return"string"==typeof r?w([r],t):r},u=[];for(;;){let e=await l({...t,cwd:r});if(e===v||(e&&u.push(i.resolve(r,e)),r===s||u.length>=o))break;r=i.dirname(r)}return u}async function _(e,t={}){return(await x(e,{...t,limit:1}))[0]}},6789:(e,t,r)=>{"use strict";r.d(t,{A:()=>l});let i=Symbol("singleComment"),n=Symbol("multiComment"),s=()=>"",o=(e,t,r)=>e.slice(t,r).replace(/\S/g," "),a=(e,t)=>{let r=t-1,i=0;for(;"\\"===e[r];)r-=1,i+=1;return!!(i%2)};function l(e,{whitespace:t=!0,trailingCommas:r=!1}={}){if("string"!=typeof e)throw TypeError(`Expected argument \`jsonString\` to be a \`string\`, got \`${typeof e}\``);let u=t?o:s,h=!1,c=!1,f=0,d="",p="",g=-1;for(let t=0;t<e.length;t++){let s=e[t],o=e[t+1];if(c||'"'!==s||a(e,t)||(h=!h),!h){if(c||s+o!=="//"){if(c===i&&s+o==="\r\n"){c=!1,d+=u(e,f,++t),f=t;continue}if(c===i&&"\n"===s)c=!1,d+=u(e,f,t),f=t;else if(c||s+o!=="/*"){if(c===n&&s+o==="*/"){c=!1,d+=u(e,f,++t+1),f=t+1;continue}r&&!c&&(-1!==g?"}"===s||"]"===s?(d+=e.slice(f,t),p+=u(d,0,1)+d.slice(1),d="",f=t,g=-1):" "!==s&&" "!==s&&"\r"!==s&&"\n"!==s&&(d+=e.slice(f,t),f=t,g=-1):","===s&&(p+=d+e.slice(f,t),d="",f=t,g=t))}else{d+=e.slice(f,t),f=t,c=n,t++;continue}}else d+=e.slice(f,t),f=t,c=i,t++}}return p+d+(c?u(e.slice(f)):e.slice(f))}},5040:e=>{"use strict";e.exports={version:"3.17.0"}}};
|
|
23
|
+
- Upgrade docs: https://github.com/winstonjs/winston/blob/master/UPGRADE-3.0.md`)},o.prototype.close=function(){this.transport.close&&this.transport.close(),this.transport.__winstonError&&(this.transport.removeListener("error",this.transport.__winstonError),this.transport.__winstonError=null)}},3744:(e,t,r)=>{"use strict";let i=r(8354),n=r(6324),{LEVEL:s}=r(2239),o=e.exports=function(e={}){n.call(this,{objectMode:!0,highWaterMark:e.highWaterMark}),this.format=e.format,this.level=e.level,this.handleExceptions=e.handleExceptions,this.handleRejections=e.handleRejections,this.silent=e.silent,e.log&&(this.log=e.log),e.logv&&(this.logv=e.logv),e.close&&(this.close=e.close),this.once("pipe",e=>{this.levels=e.levels,this.parent=e}),this.once("unpipe",e=>{e===this.parent&&(this.parent=null,this.close&&this.close())})};i.inherits(o,n),o.prototype._write=function(e,t,r){if(this.silent||!0===e.exception&&!this.handleExceptions)return r(null);let i=this.level||this.parent&&this.parent.level;if(!i||this.levels[i]>=this.levels[e[s]]){let t,i;if(e&&!this.format)return this.log(e,r);try{i=this.format.transform(Object.assign({},e),this.format.options)}catch(e){t=e}if(t||!i){if(r(),t)throw t;return}return this.log(i,r)}return this._writableState.sync=!1,r(null)},o.prototype._writev=function(e,t){if(this.logv){let r=e.filter(this._accept,this);return r.length?this.logv(r,t):t(null)}for(let r=0;r<e.length;r++){let i,n;if(this._accept(e[r])){if(e[r].chunk&&!this.format){this.log(e[r].chunk,e[r].callback);continue}try{n=this.format.transform(Object.assign({},e[r].chunk),this.format.options)}catch(e){i=e}if(i||!n){if(e[r].callback(),i)throw t(null),i}else this.log(n,e[r].callback)}}return t(null)},o.prototype._accept=function(e){let t=e.chunk;if(this.silent)return!1;let r=this.level||this.parent&&this.parent.level;return(!0===t.exception||!r||this.levels[r]>=this.levels[t[s]])&&(!!this.handleExceptions||!0!==t.exception)},o.prototype._nop=function(){}},6399:(e,t,r)=>{"use strict";let i=r(51),{warn:n}=r(3563);t.version=r(5040).version,t.transports=r(4279),t.config=r(5211),t.addColors=i.levels,t.format=i.format,t.createLogger=r(6747),t.Logger=r(1190),t.ExceptionHandler=r(608),t.RejectionHandler=r(3930),t.Container=r(6735),t.Transport=r(9747),t.loggers=new t.Container;let s=t.createLogger();Object.keys(t.config.npm.levels).concat(["log","query","stream","add","remove","clear","profile","startTimer","handleExceptions","unhandleExceptions","handleRejections","unhandleRejections","configure","child"]).forEach(e=>t[e]=(...t)=>s[e](...t)),Object.defineProperty(t,"level",{get:()=>s.level,set(e){s.level=e}}),Object.defineProperty(t,"exceptions",{get:()=>s.exceptions}),Object.defineProperty(t,"rejections",{get:()=>s.rejections}),["exitOnError"].forEach(e=>{Object.defineProperty(t,e,{get:()=>s[e],set(t){s[e]=t}})}),Object.defineProperty(t,"default",{get:()=>({exceptionHandlers:s.exceptionHandlers,rejectionHandlers:s.rejectionHandlers,transports:s.transports})}),n.deprecated(t,"setLevels"),n.forFunctions(t,"useFormat",["cli"]),n.forProperties(t,"useFormat",["padLevels","stripColors"]),n.forFunctions(t,"deprecated",["addRewriter","addFilter","clone","extend"]),n.forProperties(t,"deprecated",["emitErrs","levelLength"])},3563:(e,t,r)=>{"use strict";let{format:i}=r(8354);t.warn={deprecated:e=>()=>{throw Error(i("{ %s } was removed in winston@3.0.0.",e))},useFormat:e=>()=>{throw Error([i("{ %s } was removed in winston@3.0.0.",e),"Use a custom winston.format = winston.format(function) instead."].join("\n"))},forFunctions(e,r,i){i.forEach(i=>{e[i]=t.warn[r](i)})},forProperties(e,r,i){i.forEach(i=>{let n=t.warn[r](i);Object.defineProperty(e,i,{get:n,set:n})})}}},5211:(e,t,r)=>{"use strict";let i=r(51),{configs:n}=r(2239);t.cli=i.levels(n.cli),t.npm=i.levels(n.npm),t.syslog=i.levels(n.syslog),t.addColors=i.levels},6735:(e,t,r)=>{"use strict";let i=r(6747);e.exports=class{constructor(e={}){this.loggers=new Map,this.options=e}add(e,t){if(!this.loggers.has(e)){let r=(t=Object.assign({},t||this.options)).transports||this.options.transports;r?t.transports=Array.isArray(r)?r.slice():[r]:t.transports=[];let n=i(t);n.on("close",()=>this._delete(e)),this.loggers.set(e,n)}return this.loggers.get(e)}get(e,t){return this.add(e,t)}has(e){return!!this.loggers.has(e)}close(e){if(e)return this._removeLogger(e);this.loggers.forEach((e,t)=>this._removeLogger(t))}_removeLogger(e){this.loggers.has(e)&&(this.loggers.get(e).close(),this._delete(e))}_delete(e){this.loggers.delete(e)}}},6747:(e,t,r)=>{"use strict";let{LEVEL:i}=r(2239),n=r(5211),s=r(1190),o=r(1298)("winston:create-logger");function a(e){return"is"+e.charAt(0).toUpperCase()+e.slice(1)+"Enabled"}e.exports=function(e={}){e.levels=e.levels||n.npm.levels;class t extends s{constructor(e){super(e)}}let r=new t(e);return Object.keys(e.levels).forEach(function(e){if(o('Define prototype method for "%s"',e),"log"===e){console.warn('Level "log" not defined: conflicts with the method "log". Use a different level name.');return}t.prototype[e]=function(...t){let n=this||r;if(1===t.length){let[s]=t,o=s&&s.message&&s||{message:s};return o.level=o[i]=e,n._addDefaultMeta(o),n.write(o),this||r}return 0===t.length?(n.log(e,""),n):n.log(e,...t)},t.prototype[a(e)]=function(){return(this||r).isLevelEnabled(e)}}),r}},608:(e,t,r)=>{"use strict";let i=r(1820),n=r(3529),s=r(1298)("winston:exception"),o=r(3927),a=r(9312),l=r(5002);e.exports=class{constructor(e){if(!e)throw Error("Logger is required to handle exceptions");this.logger=e,this.handlers=new Map}handle(...e){e.forEach(e=>{if(Array.isArray(e))return e.forEach(e=>this._addHandler(e));this._addHandler(e)}),this.catcher||(this.catcher=this._uncaughtException.bind(this),process.on("uncaughtException",this.catcher))}unhandle(){this.catcher&&(process.removeListener("uncaughtException",this.catcher),this.catcher=!1,Array.from(this.handlers.values()).forEach(e=>this.logger.unpipe(e)))}getAllInfo(e){let t=null;return e&&(t="string"==typeof e?e:e.message),{error:e,level:"error",message:[`uncaughtException: ${t||"(no error message)"}`,e&&e.stack||" No stack trace"].join("\n"),stack:e&&e.stack,exception:!0,date:new Date().toString(),process:this.getProcessInfo(),os:this.getOsInfo(),trace:this.getTrace(e)}}getProcessInfo(){return{pid:process.pid,uid:process.getuid?process.getuid():null,gid:process.getgid?process.getgid():null,cwd:process.cwd(),execPath:process.execPath,version:process.version,argv:process.argv,memoryUsage:process.memoryUsage()}}getOsInfo(){return{loadavg:i.loadavg(),uptime:i.uptime()}}getTrace(e){return(e?a.parse(e):a.get()).map(e=>({column:e.getColumnNumber(),file:e.getFileName(),function:e.getFunctionName(),line:e.getLineNumber(),method:e.getMethodName(),native:e.isNative()}))}_addHandler(e){if(!this.handlers.has(e)){e.handleExceptions=!0;let t=new l(e);this.handlers.set(e,t),this.logger.pipe(t)}}_uncaughtException(e){let t;let r=this.getAllInfo(e),i=this._getExceptionHandlers(),a="function"==typeof this.logger.exitOnError?this.logger.exitOnError(e):this.logger.exitOnError;function l(){s("doExit",a),s("process._exiting",process._exiting),a&&!process._exiting&&(t&&clearTimeout(t),process.exit(1))}if(!i.length&&a&&(console.warn("winston: exitOnError cannot be true with no exception handlers."),console.warn("winston: not exiting process."),a=!1),!i||0===i.length)return process.nextTick(l);n(i,(e,t)=>{let r=o(t),i=e.transport||e;function n(e){return()=>{s(e),r()}}i._ending=!0,i.once("finish",n("finished")),i.once("error",n("error"))},()=>a&&l()),this.logger.log(r),a&&(t=setTimeout(l,3e3))}_getExceptionHandlers(){return this.logger.transports.filter(e=>(e.transport||e).handleExceptions)}}},5002:(e,t,r)=>{"use strict";let{Writable:i}=r(2826);e.exports=class extends i{constructor(e){if(super({objectMode:!0}),!e)throw Error("ExceptionStream requires a TransportStream instance.");this.handleExceptions=!0,this.transport=e}_write(e,t,r){return e.exception?this.transport.log(e,r):(r(),!0)}}},1190:(e,t,r)=>{"use strict";let{Stream:i,Transform:n}=r(2826),s=r(3529),{LEVEL:o,SPLAT:a}=r(2239),l=r(6696),u=r(608),h=r(3930),c=r(1352),f=r(3659),{warn:d}=r(3563),p=r(5211),g=/%[scdjifoO%]/g;class m extends n{constructor(e){super({objectMode:!0}),this.configure(e)}child(e){let t=this;return Object.create(t,{write:{value:function(r){let i=Object.assign({},e,r);r instanceof Error&&(i.stack=r.stack,i.message=r.message),t.write(i)}}})}configure({silent:e,format:t,defaultMeta:i,levels:n,level:s="info",exitOnError:o=!0,transports:a,colors:l,emitErrs:c,formatters:f,padLevels:d,rewriters:g,stripColors:m,exceptionHandlers:b,rejectionHandlers:w}={}){if(this.transports.length&&this.clear(),this.silent=e,this.format=t||this.format||r(9161)(),this.defaultMeta=i||null,this.levels=n||this.levels||p.npm.levels,this.level=s,this.exceptions&&this.exceptions.unhandle(),this.rejections&&this.rejections.unhandle(),this.exceptions=new u(this),this.rejections=new h(this),this.profilers={},this.exitOnError=o,a&&(a=Array.isArray(a)?a:[a]).forEach(e=>this.add(e)),l||c||f||d||g||m)throw Error("{ colors, emitErrs, formatters, padLevels, rewriters, stripColors } were removed in winston@3.0.0.\nUse a custom winston.format(function) instead.\nSee: https://github.com/winstonjs/winston/tree/master/UPGRADE-3.0.md");b&&this.exceptions.handle(b),w&&this.rejections.handle(w)}isLevelEnabled(e){let t=b(this.levels,e);if(null===t)return!1;let r=b(this.levels,this.level);return null!==r&&(this.transports&&0!==this.transports.length?-1!==this.transports.findIndex(e=>{let i=b(this.levels,e.level);return null===i&&(i=r),i>=t}):r>=t)}log(e,t,...r){if(1==arguments.length)return e[o]=e.level,this._addDefaultMeta(e),this.write(e),this;if(2==arguments.length)return t&&"object"==typeof t?t[o]=t.level=e:t={[o]:e,level:e,message:t},this._addDefaultMeta(t),this.write(t),this;let[i]=r;if("object"==typeof i&&null!==i&&!(t&&t.match&&t.match(g))){let n=Object.assign({},this.defaultMeta,i,{[o]:e,[a]:r,level:e,message:t});return i.message&&(n.message=`${n.message} ${i.message}`),i.stack&&(n.stack=i.stack),i.cause&&(n.cause=i.cause),this.write(n),this}return this.write(Object.assign({},this.defaultMeta,{[o]:e,[a]:r,level:e,message:t})),this}_transform(e,t,r){if(this.silent)return r();e[o]||(e[o]=e.level),this.levels[e[o]]||0===this.levels[e[o]]||console.error("[winston] Unknown logger level: %s",e[o]),this._readableState.pipes||console.error("[winston] Attempt to write logs with no transports, which can increase memory usage: %j",e);try{this.push(this.format.transform(e,this.format.options))}finally{this._writableState.sync=!1,r()}}_final(e){s(this.transports.slice(),(e,t)=>{if(!e||e.finished)return setImmediate(t);e.once("finish",t),e.end()},e)}add(e){let t=!l(e)||e.log.length>2?new c({transport:e}):e;if(!t._writableState||!t._writableState.objectMode)throw Error("Transports must WritableStreams in objectMode. Set { objectMode: true }.");return this._onEvent("error",t),this._onEvent("warn",t),this.pipe(t),e.handleExceptions&&this.exceptions.handle(),e.handleRejections&&this.rejections.handle(),this}remove(e){if(!e)return this;let t=e;return(!l(e)||e.log.length>2)&&(t=this.transports.filter(t=>t.transport===e)[0]),t&&this.unpipe(t),this}clear(){return this.unpipe(),this}close(){return this.exceptions.unhandle(),this.rejections.unhandle(),this.clear(),this.emit("close"),this}setLevels(){d.deprecated("setLevels")}query(e,t){"function"==typeof e&&(t=e,e={});let r={},i=Object.assign({},(e=e||{}).query||{});function n(t,r){e.query&&"function"==typeof t.formatQuery&&(e.query=t.formatQuery(i)),t.query(e,(i,n)=>{if(i)return r(i);"function"==typeof t.formatResults&&(n=t.formatResults(n,e.format)),r(null,n)})}function o(e,t){n(e,(i,n)=>{t&&((n=i||n)&&(r[e.name]=n),t()),t=null})}s(this.transports.filter(e=>!!e.query),o,()=>t(null,r))}stream(e={}){let t=new i,r=[];return t._streams=r,t.destroy=()=>{let e=r.length;for(;e--;)r[e].destroy()},this.transports.filter(e=>!!e.stream).forEach(i=>{let n=i.stream(e);n&&(r.push(n),n.on("log",e=>{e.transport=e.transport||[],e.transport.push(i.name),t.emit("log",e)}),n.on("error",e=>{e.transport=e.transport||[],e.transport.push(i.name),t.emit("error",e)}))}),t}startTimer(){return new f(this)}profile(e,...t){let r=Date.now();if(this.profilers[e]){let i=this.profilers[e];delete this.profilers[e],"function"==typeof t[t.length-2]&&(console.warn("Callback function no longer supported as of winston@3.0.0"),t.pop());let n="object"==typeof t[t.length-1]?t.pop():{};return n.level=n.level||"info",n.durationMs=r-i,n.message=n.message||e,this.write(n)}return this.profilers[e]=r,this}handleExceptions(...e){console.warn("Deprecated: .handleExceptions() will be removed in winston@4. Use .exceptions.handle()"),this.exceptions.handle(...e)}unhandleExceptions(...e){console.warn("Deprecated: .unhandleExceptions() will be removed in winston@4. Use .exceptions.unhandle()"),this.exceptions.unhandle(...e)}cli(){throw Error("Logger.cli() was removed in winston@3.0.0\nUse a custom winston.formats.cli() instead.\nSee: https://github.com/winstonjs/winston/tree/master/UPGRADE-3.0.md")}_onEvent(e,t){function r(r){"error"!==e||this.transports.includes(t)||this.add(t),this.emit(e,r,t)}t["__winston"+e]||(t["__winston"+e]=r.bind(this),t.on(e,t["__winston"+e]))}_addDefaultMeta(e){this.defaultMeta&&Object.assign(e,this.defaultMeta)}}function b(e,t){let r=e[t];return r||0===r?r:null}Object.defineProperty(m.prototype,"transports",{configurable:!1,enumerable:!0,get(){let{pipes:e}=this._readableState;return Array.isArray(e)?e:[e].filter(Boolean)}}),e.exports=m},3659:(e,t,r)=>{"use strict";class i{constructor(e){let t=r(1190);if("object"!=typeof e||Array.isArray(e)||!(e instanceof t))throw Error("Logger is required for profiling");this.logger=e,this.start=Date.now()}done(...e){"function"==typeof e[e.length-1]&&(console.warn("Callback function no longer supported as of winston@3.0.0"),e.pop());let t="object"==typeof e[e.length-1]?e.pop():{};return t.level=t.level||"info",t.durationMs=Date.now()-this.start,this.logger.write(t)}}e.exports=i},3930:(e,t,r)=>{"use strict";let i=r(1820),n=r(3529),s=r(1298)("winston:rejection"),o=r(3927),a=r(9312),l=r(3448);e.exports=class{constructor(e){if(!e)throw Error("Logger is required to handle rejections");this.logger=e,this.handlers=new Map}handle(...e){e.forEach(e=>{if(Array.isArray(e))return e.forEach(e=>this._addHandler(e));this._addHandler(e)}),this.catcher||(this.catcher=this._unhandledRejection.bind(this),process.on("unhandledRejection",this.catcher))}unhandle(){this.catcher&&(process.removeListener("unhandledRejection",this.catcher),this.catcher=!1,Array.from(this.handlers.values()).forEach(e=>this.logger.unpipe(e)))}getAllInfo(e){let t=null;return e&&(t="string"==typeof e?e:e.message),{error:e,level:"error",message:[`unhandledRejection: ${t||"(no error message)"}`,e&&e.stack||" No stack trace"].join("\n"),stack:e&&e.stack,rejection:!0,date:new Date().toString(),process:this.getProcessInfo(),os:this.getOsInfo(),trace:this.getTrace(e)}}getProcessInfo(){return{pid:process.pid,uid:process.getuid?process.getuid():null,gid:process.getgid?process.getgid():null,cwd:process.cwd(),execPath:process.execPath,version:process.version,argv:process.argv,memoryUsage:process.memoryUsage()}}getOsInfo(){return{loadavg:i.loadavg(),uptime:i.uptime()}}getTrace(e){return(e?a.parse(e):a.get()).map(e=>({column:e.getColumnNumber(),file:e.getFileName(),function:e.getFunctionName(),line:e.getLineNumber(),method:e.getMethodName(),native:e.isNative()}))}_addHandler(e){if(!this.handlers.has(e)){e.handleRejections=!0;let t=new l(e);this.handlers.set(e,t),this.logger.pipe(t)}}_unhandledRejection(e){let t;let r=this.getAllInfo(e),i=this._getRejectionHandlers(),a="function"==typeof this.logger.exitOnError?this.logger.exitOnError(e):this.logger.exitOnError;function l(){s("doExit",a),s("process._exiting",process._exiting),a&&!process._exiting&&(t&&clearTimeout(t),process.exit(1))}if(!i.length&&a&&(console.warn("winston: exitOnError cannot be true with no rejection handlers."),console.warn("winston: not exiting process."),a=!1),!i||0===i.length)return process.nextTick(l);n(i,(e,t)=>{let r=o(t),i=e.transport||e;function n(e){return()=>{s(e),r()}}i._ending=!0,i.once("finish",n("finished")),i.once("error",n("error"))},()=>a&&l()),this.logger.log(r),a&&(t=setTimeout(l,3e3))}_getRejectionHandlers(){return this.logger.transports.filter(e=>(e.transport||e).handleRejections)}}},3448:(e,t,r)=>{"use strict";let{Writable:i}=r(2826);e.exports=class extends i{constructor(e){if(super({objectMode:!0}),!e)throw Error("RejectionStream requires a TransportStream instance.");this.handleRejections=!0,this.transport=e}_write(e,t,r){return e.rejection?this.transport.log(e,r):(r(),!0)}}},7539:(e,t,r)=>{"use strict";let i=r(9021),{StringDecoder:n}=r(1204),{Stream:s}=r(2826);function o(){}e.exports=(e,t)=>{let r=Buffer.alloc(65536),a=new n("utf8"),l=new s,u="",h=0,c=0;return(-1===e.start&&delete e.start,l.readable=!0,l.destroy=()=>{l.destroyed=!0,l.emit("end"),l.emit("close")},i.open(e.file,"a+","0644",(n,s)=>{if(n){t?t(n):l.emit("error",n),l.destroy();return}!function n(){if(l.destroyed){i.close(s,o);return}return i.read(s,r,0,r.length,h,(i,s)=>{if(i){t?t(i):l.emit("error",i),l.destroy();return}if(!s)return u&&((null==e.start||c>e.start)&&(t?t(null,u):l.emit("line",u)),c++,u=""),setTimeout(n,1e3);let o=a.write(r.slice(0,s));t||l.emit("data",o);let f=(o=(u+o).split(/\n+/)).length-1,d=0;for(;d<f;d++)(null==e.start||c>e.start)&&(t?t(null,o[d]):l.emit("line",o[d])),c++;return u=o[f],h+=s,n()})}()}),t)?l.destroy:l}},6718:(e,t,r)=>{"use strict";let i=r(1820),{LEVEL:n,MESSAGE:s}=r(2239),o=r(9747);e.exports=class extends o{constructor(e={}){super(e),this.name=e.name||"console",this.stderrLevels=this._stringArrayToSet(e.stderrLevels),this.consoleWarnLevels=this._stringArrayToSet(e.consoleWarnLevels),this.eol="string"==typeof e.eol?e.eol:i.EOL,this.forceConsole=e.forceConsole||!1,this._consoleLog=console.log.bind(console),this._consoleWarn=console.warn.bind(console),this._consoleError=console.error.bind(console),this.setMaxListeners(30)}log(e,t){if(setImmediate(()=>this.emit("logged",e)),this.stderrLevels[e[n]]){console._stderr&&!this.forceConsole?console._stderr.write(`${e[s]}${this.eol}`):this._consoleError(e[s]),t&&t();return}if(this.consoleWarnLevels[e[n]]){console._stderr&&!this.forceConsole?console._stderr.write(`${e[s]}${this.eol}`):this._consoleWarn(e[s]),t&&t();return}console._stdout&&!this.forceConsole?console._stdout.write(`${e[s]}${this.eol}`):this._consoleLog(e[s]),t&&t()}_stringArrayToSet(e,t){if(!e)return{};if(t=t||"Cannot make set from type other than Array of string elements",!Array.isArray(e))throw Error(t);return e.reduce((e,r)=>{if("string"!=typeof r)throw Error(t);return e[r]=!0,e},{})}}},2089:(e,t,r)=>{"use strict";let i=r(9021),n=r(3873),s=r(3258),o=r(4075),{MESSAGE:a}=r(2239),{Stream:l,PassThrough:u}=r(2826),h=r(9747),c=r(1298)("winston:file"),f=r(1820),d=r(7539);e.exports=class extends h{constructor(e={}){function t(r,...i){i.slice(1).forEach(t=>{if(e[t])throw Error(`Cannot set ${t} and ${r} together`)})}if(super(e),this.name=e.name||"file",this._stream=new u,this._stream.setMaxListeners(30),this._onError=this._onError.bind(this),e.filename||e.dirname)t("filename or dirname","stream"),this._basename=this.filename=e.filename?n.basename(e.filename):"winston.log",this.dirname=e.dirname||n.dirname(e.filename),this.options=e.options||{flags:"a"};else if(e.stream)console.warn("options.stream will be removed in winston@4. Use winston.transports.Stream"),t("stream","filename","maxsize"),this._dest=this._stream.pipe(this._setupStream(e.stream)),this.dirname=n.dirname(this._dest.path);else throw Error("Cannot log to file without filename or stream.");this.maxsize=e.maxsize||null,this.rotationFormat=e.rotationFormat||!1,this.zippedArchive=e.zippedArchive||!1,this.maxFiles=e.maxFiles||null,this.eol="string"==typeof e.eol?e.eol:f.EOL,this.tailable=e.tailable||!1,this.lazy=e.lazy||!1,this._size=0,this._pendingSize=0,this._created=0,this._drain=!1,this._opening=!1,this._ending=!1,this._fileExist=!1,this.dirname&&this._createLogDirIfNotExist(this.dirname),this.lazy||this.open()}finishIfEnding(){this._ending&&(this._opening?this.once("open",()=>{this._stream.once("finish",()=>this.emit("finish")),setImmediate(()=>this._stream.end())}):(this._stream.once("finish",()=>this.emit("finish")),setImmediate(()=>this._stream.end())))}log(e,t=()=>{}){if(this.silent)return t(),!0;if(this._drain){this._stream.once("drain",()=>{this._drain=!1,this.log(e,t)});return}if(this._rotate){this._stream.once("rotate",()=>{this._rotate=!1,this.log(e,t)});return}if(this.lazy){if(!this._fileExist){this._opening||this.open(),this.once("open",()=>{this._fileExist=!0,this.log(e,t)});return}if(this._needsNewFile(this._pendingSize)){this._dest.once("close",()=>{this._opening||this.open(),this.once("open",()=>{this.log(e,t)})});return}}let r=`${e[a]}${this.eol}`,i=Buffer.byteLength(r);function n(){if(this._size+=i,this._pendingSize-=i,c("logged %s %s",this._size,r),this.emit("logged",e),!this._rotate&&!this._opening&&this._needsNewFile()){if(this.lazy){this._endStream(()=>{this.emit("fileclosed")});return}this._rotate=!0,this._endStream(()=>this._rotateFile())}}this._pendingSize+=i,this._opening&&!this.rotatedWhileOpening&&this._needsNewFile(this._size+this._pendingSize)&&(this.rotatedWhileOpening=!0);let s=this._stream.write(r,n.bind(this));return s?t():(this._drain=!0,this._stream.once("drain",()=>{this._drain=!1,t()})),c("written",s,this._drain),this.finishIfEnding(),s}query(e,t){"function"==typeof e&&(t=e,e={}),e=f(e);let r=n.join(this.dirname,this.filename),s="",o=[],a=0,l=i.createReadStream(r,{encoding:"utf8"});function u(e,t){try{let t=JSON.parse(e);c(t)&&h(t)}catch(e){t||l.emit("error",e)}}function h(t){if(e.rows&&o.length>=e.rows&&"desc"!==e.order){l.readable&&l.destroy();return}e.fields&&(t=e.fields.reduce((e,r)=>(e[r]=t[r],e),{})),"desc"===e.order&&o.length>=e.rows&&o.shift(),o.push(t)}function c(t){if(!t||"object"!=typeof t)return;let r=new Date(t.timestamp);if((!e.from||!(r<e.from))&&(!e.until||!(r>e.until))&&(!e.level||e.level===t.level))return!0}function f(e){return(e=e||{}).rows=e.rows||e.limit||10,e.start=e.start||0,e.until=e.until||new Date,"object"!=typeof e.until&&(e.until=new Date(e.until)),e.from=e.from||e.until-864e5,"object"!=typeof e.from&&(e.from=new Date(e.from)),e.order=e.order||"desc",e}l.on("error",e=>{if(l.readable&&l.destroy(),t)return"ENOENT"!==e.code?t(e):t(null,o)}),l.on("data",t=>{let r=(t=(s+t).split(/\n+/)).length-1,i=0;for(;i<r;i++)(!e.start||a>=e.start)&&u(t[i]),a++;s=t[r]}),l.on("close",()=>{s&&u(s,!0),"desc"===e.order&&(o=o.reverse()),t&&t(null,o)})}stream(e={}){let t=n.join(this.dirname,this.filename),r=new l,i={file:t,start:e.start};return r.destroy=d(i,(e,t)=>{if(e)return r.emit("error",e);try{r.emit("data",t),t=JSON.parse(t),r.emit("log",t)}catch(e){r.emit("error",e)}}),r}open(){this.filename&&(this._opening||(this._opening=!0,this.stat((e,t)=>{if(e)return this.emit("error",e);c("stat done: %s { size: %s }",this.filename,t),this._size=t,this._dest=this._createStream(this._stream),this._opening=!1,this.once("open",()=>{this._stream.emit("rotate")||(this._rotate=!1)})})))}stat(e){let t=this._getFile(),r=n.join(this.dirname,t);i.stat(r,(i,n)=>i&&"ENOENT"===i.code?(c("ENOENT\xa0ok",r),this.filename=t,e(null,0)):i?(c(`err ${i.code} ${r}`),e(i)):!n||this._needsNewFile(n.size)?this._incFile(()=>this.stat(e)):void(this.filename=t,e(null,n.size)))}close(e){this._stream&&this._stream.end(()=>{e&&e(),this.emit("flush"),this.emit("closed")})}_needsNewFile(e){return e=e||this._size,this.maxsize&&e>=this.maxsize}_onError(e){this.emit("error",e)}_setupStream(e){return e.on("error",this._onError),e}_cleanupStream(e){return e.removeListener("error",this._onError),e.destroy(),e}_rotateFile(){this._incFile(()=>this.open())}_endStream(e=()=>{}){this._dest?(this._stream.unpipe(this._dest),this._dest.end(()=>{this._cleanupStream(this._dest),e()})):e()}_createStream(e){let t=n.join(this.dirname,this.filename);c("create stream start",t,this.options);let r=i.createWriteStream(t,this.options).on("error",e=>c(e)).on("close",()=>c("close",r.path,r.bytesWritten)).on("open",()=>{c("file open ok",t),this.emit("open",t),e.pipe(r),this.rotatedWhileOpening&&(this._stream=new u,this._stream.setMaxListeners(30),this._rotateFile(),this.rotatedWhileOpening=!1,this._cleanupStream(r),e.end())});return c("create stream ok",t),r}_incFile(e){c("_incFile",this.filename);let t=n.extname(this._basename),r=n.basename(this._basename,t),i=[];this.zippedArchive&&i.push((function(e){let i=this._created>0&&!this.tailable?this._created:"";this._compressFile(n.join(this.dirname,`${r}${i}${t}`),n.join(this.dirname,`${r}${i}${t}.gz`),e)}).bind(this)),i.push((function(e){this.tailable?this._checkMaxFilesTailable(t,r,e):(this._created+=1,this._checkMaxFilesIncrementing(t,r,e))}).bind(this)),s(i,e)}_getFile(){let e=n.extname(this._basename),t=n.basename(this._basename,e),r=this.rotationFormat?this.rotationFormat():this._created;return!this.tailable&&this._created?`${t}${r}${e}`:`${t}${e}`}_checkMaxFilesIncrementing(e,t,r){if(!this.maxFiles||this._created<this.maxFiles)return setImmediate(r);let s=this._created-this.maxFiles,o=0!==s?s:"",a=this.zippedArchive?".gz":"",l=`${t}${o}${e}${a}`,u=n.join(this.dirname,l);i.unlink(u,r)}_checkMaxFilesTailable(e,t,r){let o=[];if(!this.maxFiles)return;let a=this.zippedArchive?".gz":"";for(let r=this.maxFiles-1;r>1;r--)o.push((function(r,s){let o=`${t}${r-1}${e}${a}`,l=n.join(this.dirname,o);i.exists(l,u=>{if(!u)return s(null);o=`${t}${r}${e}${a}`,i.rename(l,n.join(this.dirname,o),s)})}).bind(this,r));s(o,()=>{i.rename(n.join(this.dirname,`${t}${e}${a}`),n.join(this.dirname,`${t}1${e}${a}`),r)})}_compressFile(e,t,r){i.access(e,i.F_OK,n=>{if(n)return r();var s=o.createGzip(),a=i.createReadStream(e),l=i.createWriteStream(t);l.on("finish",()=>{i.unlink(e,r)}),a.pipe(s).pipe(l)})}_createLogDirIfNotExist(e){i.existsSync(e)||i.mkdirSync(e,{recursive:!0})}}},5307:(e,t,r)=>{"use strict";let i=r(1630),n=r(5591),{Stream:s}=r(2826),o=r(9747),{configure:a}=r(900);e.exports=class extends o{constructor(e={}){super(e),this.options=e,this.name=e.name||"http",this.ssl=!!e.ssl,this.host=e.host||"localhost",this.port=e.port,this.auth=e.auth,this.path=e.path||"",this.maximumDepth=e.maximumDepth,this.agent=e.agent,this.headers=e.headers||{},this.headers["content-type"]="application/json",this.batch=e.batch||!1,this.batchInterval=e.batchInterval||5e3,this.batchCount=e.batchCount||10,this.batchOptions=[],this.batchTimeoutID=-1,this.batchCallback={},this.port||(this.port=this.ssl?443:80)}log(e,t){this._request(e,null,null,(t,r)=>{r&&200!==r.statusCode&&(t=Error(`Invalid HTTP Status Code: ${r.statusCode}`)),t?this.emit("warn",t):this.emit("logged",e)}),t&&setImmediate(t)}query(e,t){"function"==typeof e&&(t=e,e={});let r=(e={method:"query",params:this.normalizeQuery(e)}).params.auth||null;delete e.params.auth;let i=e.params.path||null;delete e.params.path,this._request(e,r,i,(e,r,i)=>{if(r&&200!==r.statusCode&&(e=Error(`Invalid HTTP Status Code: ${r.statusCode}`)),e)return t(e);if("string"==typeof i)try{i=JSON.parse(i)}catch(e){return t(e)}t(null,i)})}stream(e={}){let t=new s,r=(e={method:"stream",params:e}).params.path||null;delete e.params.path;let i=e.params.auth||null;delete e.params.auth;let n="",o=this._request(e,i,r);return t.destroy=()=>o.destroy(),o.on("data",e=>{let r=(e=(n+e).split(/\n+/)).length-1,i=0;for(;i<r;i++)try{t.emit("log",JSON.parse(e[i]))}catch(e){t.emit("error",e)}n=e[r]}),o.on("error",e=>t.emit("error",e)),t}_request(e,t,r,i){e=e||{},t=t||this.auth,r=r||this.path||"",this.batch?this._doBatch(e,i,t,r):this._doRequest(e,i,t,r)}_doBatch(e,t,r,i){if(this.batchOptions.push(e),1===this.batchOptions.length){let e=this;this.batchCallback=t,this.batchTimeoutID=setTimeout(function(){e.batchTimeoutID=-1,e._doBatchRequest(e.batchCallback,r,i)},this.batchInterval)}this.batchOptions.length===this.batchCount&&this._doBatchRequest(this.batchCallback,r,i)}_doBatchRequest(e,t,r){this.batchTimeoutID>0&&(clearTimeout(this.batchTimeoutID),this.batchTimeoutID=-1);let i=this.batchOptions.slice();this.batchOptions=[],this._doRequest(i,e,t,r)}_doRequest(e,t,r,s){let o=Object.assign({},this.headers);r&&r.bearer&&(o.Authorization=`Bearer ${r.bearer}`);let l=(this.ssl?n:i).request({...this.options,method:"POST",host:this.host,port:this.port,path:`/${s.replace(/^\//,"")}`,headers:o,auth:r&&r.username&&r.password?`${r.username}:${r.password}`:"",agent:this.agent});l.on("error",t),l.on("response",e=>e.on("end",()=>t(null,e)).resume());let u=a({...this.maximumDepth&&{maximumDepth:this.maximumDepth}});l.end(Buffer.from(u(e,this.options.replacer),"utf8"))}}},4279:(e,t,r)=>{"use strict";Object.defineProperty(t,"Console",{configurable:!0,enumerable:!0,get:()=>r(6718)}),Object.defineProperty(t,"File",{configurable:!0,enumerable:!0,get:()=>r(2089)}),Object.defineProperty(t,"Http",{configurable:!0,enumerable:!0,get:()=>r(5307)}),Object.defineProperty(t,"Stream",{configurable:!0,enumerable:!0,get:()=>r(1171)})},1171:(e,t,r)=>{"use strict";let i=r(6696),{MESSAGE:n}=r(2239),s=r(1820),o=r(9747);e.exports=class extends o{constructor(e={}){if(super(e),!e.stream||!i(e.stream))throw Error("options.stream is required.");this._stream=e.stream,this._stream.setMaxListeners(1/0),this.isObjectMode=e.stream._writableState.objectMode,this.eol="string"==typeof e.eol?e.eol:s.EOL}log(e,t){if(setImmediate(()=>this.emit("logged",e)),this.isObjectMode){this._stream.write(e),t&&t();return}this._stream.write(`${e[n]}${this.eol}`),t&&t()}}},3149:(e,t,r)=>{"use strict";r.d(t,{dJ:()=>_});var i=r(6760),n=r(1708),s=r(3024),o=r(3136);class a{value;next;constructor(e){this.value=e}}class l{#e;#t;#r;constructor(){this.clear()}enqueue(e){let t=new a(e);this.#e?this.#t.next=t:this.#e=t,this.#t=t,this.#r++}dequeue(){let e=this.#e;if(e)return this.#e=this.#e.next,this.#r--,e.value}peek(){if(this.#e)return this.#e.value}clear(){this.#e=void 0,this.#t=void 0,this.#r=0}get size(){return this.#r}*[Symbol.iterator](){let e=this.#e;for(;e;)yield e.value,e=e.next}}function u(e){if(!((Number.isInteger(e)||e===Number.POSITIVE_INFINITY)&&e>0))throw TypeError("Expected `concurrency` to be a number from 1 and up");let t=new l,r=0,i=()=>{r--,t.size>0&&t.dequeue()()},n=async(e,t,n)=>{r++;let s=(async()=>e(...n))();t(s);try{await s}catch{}i()},s=(i,s,o)=>{t.enqueue(n.bind(void 0,i,s,o)),(async()=>{await Promise.resolve(),r<e&&t.size>0&&t.dequeue()()})()},o=(e,...t)=>new Promise(r=>{s(e,r,t)});return Object.defineProperties(o,{activeCount:{get:()=>r},pendingCount:{get:()=>t.size},clearQueue:{value:()=>{t.clear()}}}),o}class h extends Error{constructor(e){super(),this.value=e}}let c=async(e,t)=>t(await e),f=async e=>{let t=await Promise.all(e);if(!0===t[1])throw new h(t[0]);return!1};async function d(e,t,{concurrency:r=Number.POSITIVE_INFINITY,preserveOrder:i=!0}={}){let n=u(r),s=[...e].map(e=>[e,n(c,e,t)]),o=u(i?1:Number.POSITIVE_INFINITY);try{await Promise.all(s.map(e=>o(f,e)))}catch(e){if(e instanceof h)return e.value;throw e}}let p={directory:"isDirectory",file:"isFile"};function g(e){if(!Object.hasOwnProperty.call(p,e))throw Error(`Invalid type specified: ${e}`)}let m=(e,t)=>t[p[e]](),b=e=>e instanceof URL?(0,o.fileURLToPath)(e):e;async function w(e,{cwd:t=n.cwd(),type:r="file",allowSymlinks:o=!0,concurrency:a,preserveOrder:l}={}){g(r),t=b(t);let u=o?s.promises.stat:s.promises.lstat;return d(e,async e=>{try{let n=await u(i.resolve(t,e));return m(r,n)}catch{return!1}},{concurrency:a,preserveOrder:l})}function y(e){return e instanceof URL?(0,o.fileURLToPath)(e):e}let v=Symbol("findUpStop");async function x(e,t={}){let r=i.resolve(y(t.cwd)??""),{root:n}=i.parse(r),s=i.resolve(r,y(t.stopAt??n)),o=t.limit??Number.POSITIVE_INFINITY,a=[e].flat(),l=async t=>{if("function"!=typeof e)return w(a,t);let r=await e(t.cwd);return"string"==typeof r?w([r],t):r},u=[];for(;;){let e=await l({...t,cwd:r});if(e===v||(e&&u.push(i.resolve(r,e)),r===s||u.length>=o))break;r=i.dirname(r)}return u}async function _(e,t={}){return(await x(e,{...t,limit:1}))[0]}},6789:(e,t,r)=>{"use strict";r.d(t,{A:()=>l});let i=Symbol("singleComment"),n=Symbol("multiComment"),s=()=>"",o=(e,t,r)=>e.slice(t,r).replace(/\S/g," "),a=(e,t)=>{let r=t-1,i=0;for(;"\\"===e[r];)r-=1,i+=1;return!!(i%2)};function l(e,{whitespace:t=!0,trailingCommas:r=!1}={}){if("string"!=typeof e)throw TypeError(`Expected argument \`jsonString\` to be a \`string\`, got \`${typeof e}\``);let u=t?o:s,h=!1,c=!1,f=0,d="",p="",g=-1;for(let t=0;t<e.length;t++){let s=e[t],o=e[t+1];if(c||'"'!==s||a(e,t)||(h=!h),!h){if(c||s+o!=="//"){if(c===i&&s+o==="\r\n"){c=!1,d+=u(e,f,++t),f=t;continue}if(c===i&&"\n"===s)c=!1,d+=u(e,f,t),f=t;else if(c||s+o!=="/*"){if(c===n&&s+o==="*/"){c=!1,d+=u(e,f,++t+1),f=t+1;continue}r&&!c&&(-1!==g?"}"===s||"]"===s?(d+=e.slice(f,t),p+=u(d,0,1)+d.slice(1),d="",f=t,g=-1):" "!==s&&" "!==s&&"\r"!==s&&"\n"!==s&&(d+=e.slice(f,t),f=t,g=-1):","===s&&(p+=d+e.slice(f,t),d="",f=t,g=t))}else{d+=e.slice(f,t),f=t,c=n,t++;continue}}else d+=e.slice(f,t),f=t,c=i,t++}}return p+d+(c?u(e.slice(f)):e.slice(f))}},5040:e=>{"use strict";e.exports={version:"3.17.0"}}};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
exports.id=801,exports.ids=[801],exports.modules={96487:()=>{},78335:()=>{},65949:(e,t,r)=>{"use strict";r.d(t,{S:()=>c});var a=r(79748),s=r(43149),i=r(72537),n=r(26789),l=r(81804);let E=null,o=null;async function c(e){try{let t;if(!e||"string"!=typeof e)throw Error("Project path is required and must be a string");if(E&&o===e)return E;let r=null,c=null;for(let t of["wrangler.toml","wrangler.json","wrangler.jsonc"])if(r=await (0,s.dJ)(t,{cwd:e})){c=t;break}if(!r)return l.A.warn(`No Wrangler configuration file found in: ${e}`),null;l.A.info(`Found ${c} at: ${r}`);let m=await (0,a.readFile)(r,"utf-8");return c.endsWith(".toml")?t=(0,i.parse)(m):(c.endsWith(".jsonc")&&(m=(0,n.A)(m)),t=JSON.parse(m)),E={config:t,projectPath:e},o=e,E}catch(e){throw l.A.error(`Error reading Wrangler configuration: ${e.message}`),e}}},81804:(e,t,r)=>{"use strict";r.d(t,{A:()=>o});var a=r(26399);let{combine:s,timestamp:i,printf:n,colorize:l}=a.format,E=(process.env.DEBUG,n(({level:e,message:t,timestamp:r})=>`${r} ${e}: ${t}`)),o=a.createLogger({level:"warn",format:s(i({format:"YYYY-MM-DD HH:mm:ss"}),l(),E),transports:[new a.transports.Console({level:"warn",silent:!1})]})},30961:(e,t,r)=>{"use strict";r.d(t,{CM:()=>A,GS:()=>R,Gc:()=>h,JD:()=>u,Sl:()=>N,ai:()=>p,hI:()=>f,k0:()=>T});var a=r(79748),s=r(28354),i=r(79646),n=r(55511),l=r(33873),E=r(19421),o=r(44218),c=r(81804);let m=(0,s.promisify)(i.exec);async function T(e,t,r="local",a=!1){let s="remote"===r?"--remote":"--local",i="remote"===r?`
|
|
2
|
+
CREATE TABLE IF NOT EXISTS d1_migrations (
|
|
3
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
4
|
+
name TEXT NOT NULL UNIQUE,
|
|
5
|
+
applied_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
|
6
|
+
);
|
|
7
|
+
`:`
|
|
8
|
+
CREATE TABLE IF NOT EXISTS d1_migrations (
|
|
9
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
10
|
+
name TEXT NOT NULL UNIQUE,
|
|
11
|
+
checksum TEXT NULL,
|
|
12
|
+
applied_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
|
13
|
+
);
|
|
14
|
+
`;try{await m(`wrangler d1 execute ${t} ${s} --command="${i.replace(/"/g,'\\"')}"`,{cwd:e}),a&&await m(`wrangler d1 execute ${t} ${s} --command="${"DELETE FROM d1_migrations;".replace(/"/g,'\\"')}"`,{cwd:e})}catch(e){throw c.A.error(`Failed to initialize migrations table in ${r}:`,e),e}}function d(e){let t=new Date().toISOString().replace(/[^0-9]/g,"").slice(0,-3),r=e.type.toLowerCase().replace(/_/g,"-");if("CREATE_INDEX"===e.type){let r=e.description.toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-_]/g,"");return`${t}_create-index_${r}.sql`}{let a=`${t}_${{"create-table":"create-table","alter-table":"alter-table","drop-table":"drop-table","drop-index":"drop-index","create-view":"create-view","drop-view":"drop-view","add-foreign-key":"add-foreign-key","drop-foreign-key":"drop-foreign-key","add-constraint":"add-constraint","drop-constraint":"drop-constraint"}[r]||r}_${e.tableName}`;return"ALTER_TABLE"===e.type&&e.description&&(a+=`_${e.description}`),(a=a.toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-_]/g,""))+".sql"}}async function u(e){let t=await (0,a.readFile)(e,"utf8");try{let e=(0,E.By)(t);return(0,E.Gq)(e),{isValid:!0,statement:e}}catch(e){return{isValid:!1,errors:e}}}async function R(e,t,r){try{let a=await (0,E.KK)(e,t,"SELECT name, applied_at FROM d1_migrations ORDER BY applied_at;",r,!0);if("string"==typeof a){let e=a.indexOf("[");if(-1!==e){let t=a.substring(e),r=JSON.parse(t);return r[0]?.results||[]}}return[]}catch(e){throw{type:E.wU.EXECUTION_ERROR,message:"Failed to get remote migrations",details:{error:e.message,suggestions:["Check remote database permissions","Verify credentials and connection"]}}}}async function p(e,t,{name:r,checksum:a},s="local"){let i="remote"===s?"--remote":"--local";if("local"===s&&a)try{await m(`wrangler d1 execute ${t} ${i} --command="SELECT checksum FROM d1_migrations LIMIT 1;"`,{cwd:e}).catch(()=>!1)||await m(`wrangler d1 execute ${t} ${i} --command="ALTER TABLE d1_migrations ADD COLUMN checksum TEXT;"`,{cwd:e})}catch(e){}let n="remote"!==s&&a?`
|
|
15
|
+
INSERT OR REPLACE INTO d1_migrations (name, checksum, applied_at)
|
|
16
|
+
VALUES ('${r}', '${a}', CURRENT_TIMESTAMP);
|
|
17
|
+
`:`
|
|
18
|
+
INSERT OR REPLACE INTO d1_migrations (name, applied_at)
|
|
19
|
+
VALUES ('${r}', CURRENT_TIMESTAMP);
|
|
20
|
+
`;try{await m(`wrangler d1 execute ${t} ${i} --command="${n.replace(/"/g,'\\"')}"`,{cwd:e})}catch(e){throw c.A.error("Failed to track migration:",e),e}}async function A(e,t,{name:r,checksum:a},s={},i=!1){let n=i||!a?`
|
|
21
|
+
INSERT OR REPLACE INTO d1_migrations (name, applied_at)
|
|
22
|
+
VALUES ('${r}', CURRENT_TIMESTAMP);
|
|
23
|
+
`:`
|
|
24
|
+
INSERT OR REPLACE INTO d1_migrations (name, checksum, applied_at)
|
|
25
|
+
VALUES ('${r}', '${a}', CURRENT_TIMESTAMP);
|
|
26
|
+
`;try{await (0,E.KK)(e,t,n,s,i)}catch(e){throw{type:E.wU.EXECUTION_ERROR,message:`Failed to record migration ${r}`,details:{file:r,error:e.message,suggestions:["Check if migration is already recorded"]}}}}async function f(e,t){try{let r=await R(e,t,{}),a=new Map(r.map(e=>[e.name,e]));return{applied:Array.from(a.keys()),count:a.size}}catch(e){throw c.A.error("Failed to compare migrations:",e),e}}function N(e){return(0,n.createHash)("sha256").update(e).digest("hex")}async function h(e,t,r){try{let s=l.join(e,"migrations");await (0,a.mkdir)(s,{recursive:!0});let i=[],n=[],c=[];for(let e of r)e.type===E.Pg.DATA_MODIFICATION?c.push(e):n.push(e);let m=new Map,T="__no_table__";for(let e of n){let t=e.tableName?e.tableName.toLowerCase():T;m.has(t)||m.set(t,[]),m.get(t).push(e)}let u=[...m.keys()].filter(e=>e!==T),R=[];if(u.length>0){let e=u.map(e=>m.get(e)[0]);R=(0,o.IC)(e)}for(let r of R){for(let n of m.get(r)||[])try{if(n.type===E.Pg.DROP_TABLE&&!await (0,E.F9)(e,t,{},n.tableName,!1))throw Error(`no such table: ${n.tableName}`);let r=await (0,E.KK)(e,t,n.sql);if(r&&(r.toLowerCase().includes("syntax error")||r.toLowerCase().includes("sqlite_error")))throw Error(r);let o=d(n),c=l.join(s,o),m=(0,E.tn)(n.sql);await (0,a.writeFile)(c,m,"utf8");let T=N(n.sql);await p(e,t,{name:o,checksum:T},"local"),i.push({type:n.type,table:n.tableName,migration:o,checksum:T})}catch(e){throw e}m.delete(r)}if(m.has(T))for(let r of m.get(T))try{await (0,E.KK)(e,t,r.sql);let n=d(r),o=l.join(s,n),c=(0,E.tn)(r.sql);await (0,a.writeFile)(o,c,"utf8");let m=N(r.sql);await p(e,t,{name:n,checksum:m},"local"),i.push({type:r.type,table:r.tableName||null,migration:n,checksum:m})}catch(e){throw e}for(let r of c)try{await (0,E.KK)(e,t,r.sql),i.push({type:r.type,table:r.tableName||null,executed:!0})}catch(e){throw e}return i}catch(e){throw e}}},44218:(e,t,r)=>{"use strict";r.d(t,{IC:()=>n,ZX:()=>i});var a=r(19421),s=r(81804);async function i(e,t,r={},n=!1){let l=`
|
|
27
|
+
SELECT name, type, sql
|
|
28
|
+
FROM sqlite_master
|
|
29
|
+
WHERE type IN ('table', 'index', 'trigger')
|
|
30
|
+
AND name NOT LIKE 'sqlite_%'
|
|
31
|
+
AND name != 'd1_migrations';
|
|
32
|
+
`;try{let s=await (0,a.KK)(e,t,l,r,n),i=JSON.parse(s);return i[0]?.results||[]}catch(e){throw s.A.error("Failed to get current schema:",e),{type:a.wU.EXECUTION_ERROR,message:"Failed to get current schema",details:{error:e.message,suggestions:["Check database permissions"]}}}}function n(e){let t=new Map;return e.filter(e=>"DATA_MODIFICATION"!==e.type).forEach(e=>{let r=(e.name||e.tableName).toLowerCase();if(t.has(r)||t.set(r,new Set),"CREATE_TABLE"===e.type){let a=e.sql.match(/FOREIGN\s+KEY\s*\([^)]+\)\s+REFERENCES\s+(\w+)/gi);a&&a.forEach(e=>{let a=e.match(/REFERENCES\s+(\w+)/i)[1].toLowerCase();t.get(r).add(a)})}}),function(e){let t=[],r=new Set,a=new Set;for(let s of e.keys())r.has(s)||function s(i){if(a.has(i))throw Error(`Circular dependency detected for table: ${i}`);if(!r.has(i)){for(let t of(a.add(i),e.get(i)||new Set)){if(!e.has(t))throw Error(`Missing table dependency: ${t}`);s(t)}a.delete(i),r.add(i),t.push(i)}}(s);return t}(t)}},19421:(e,t,r)=>{"use strict";r.d(t,{By:()=>c,F9:()=>p,Gq:()=>m,KK:()=>f,Pg:()=>l,QQ:()=>o,bp:()=>R,mA:()=>A,sP:()=>g,tn:()=>I,wU:()=>E,z6:()=>N});var a=r(28354),s=r(79646),i=r(81804);let n=(0,a.promisify)(s.exec),l={CREATE_TABLE:"CREATE_TABLE",ALTER_TABLE:"ALTER_TABLE",DROP_TABLE:"DROP_TABLE",CREATE_INDEX:"CREATE_INDEX",DROP_INDEX:"DROP_INDEX",DATA_MODIFICATION:"DATA_MODIFICATION"},E={VALIDATION_ERROR:"VALIDATION_ERROR",SYNTAX_ERROR:"SYNTAX_ERROR",EXECUTION_ERROR:"EXECUTION_ERROR",DEPENDENCY_ERROR:"DEPENDENCY_ERROR"};function o(e){return e.type!==l.DATA_MODIFICATION}function c(e){let t=e.trim().replace(/\s+/g," "),r=t.toUpperCase();if(r.startsWith("CREATE TABLE"))return{type:l.CREATE_TABLE,tableName:T(t,"CREATE TABLE"),sql:t,description:"create-table"};if(r.startsWith("ALTER TABLE")){let e=T(t,"ALTER TABLE"),a="";if(r.includes("RENAME")){let e=t.match(/RENAME\s+(?:COLUMN\s+)?([\w$]+)\s+TO\s+([\w$]+)/i);e&&(a=`rename-${e[1]}-to-${e[2]}`)}else if(r.includes("ADD COLUMN")){let e=t.match(/ADD\s+COLUMN\s+([\w$]+)(\s+[\w()]+)?/i);if(e){let t=e[1],r=e[2]?e[2].trim().replace(/\s+/g,"-"):"";a=r?`add-${t}-${r}`:`add-${t}`}}else if(r.includes("DROP COLUMN")){let e=t.match(/DROP\s+COLUMN\s+([\w$]+)/i);e&&(a=`drop-${e[1]}`)}else if(r.includes("MODIFY COLUMN")||r.includes("CHANGE COLUMN")){let e=t.match(/(?:MODIFY|CHANGE)\s+COLUMN\s+([\w$]+)(\s+[\w()]+)?/i);if(e){let t=e[1],r=e[2]?e[2].trim().replace(/\s+/g,"-"):"";a=r?`modify-${t}-to-${r}`:`modify-${t}`}}return{type:l.ALTER_TABLE,tableName:e,sql:t,description:a}}if(r.startsWith("DROP TABLE"))return{type:l.DROP_TABLE,tableName:T(t,"DROP TABLE"),sql:t,description:"drop-table"};if(r.startsWith("CREATE INDEX")||r.startsWith("CREATE UNIQUE INDEX")){let e=d(t),r=t.match(/INDEX\s+(?:IF\s+NOT\s+EXISTS\s+)?([\w$]+)/i),a=r?r[1]:"",s=t.match(/ON\s+[\w$]+\s*\(([^)]+)\)/i),i=(s?s[1].trim():"").replace(/\s+/g,"").replace(/,/g,"-").toLowerCase(),n=a;return i&&!n.toLowerCase().includes(i)&&(n+=`-${i}`),{type:l.CREATE_INDEX,tableName:e,sql:t,description:n}}if(r.startsWith("DROP INDEX")){let e=d(t),r=t.match(/DROP\s+INDEX\s+(?:IF\s+EXISTS\s+)?([\w$]+)/i),a=r?r[1]:"";return{type:l.DROP_INDEX,tableName:e,sql:t,description:a?`drop-index-${a}`:"drop-index"}}return{type:l.DATA_MODIFICATION,sql:t,description:"data-modification"}}function m(e){if(e.type!==l.DATA_MODIFICATION&&!e.tableName)throw{type:E.VALIDATION_ERROR,message:`Invalid SQL statement: unable to determine table name for "${e.type}".`,details:{sql:e.sql}};return e}function T(e,t){let r=e.match(RegExp(`${t}\\s+(?:IF\\s+(?:NOT\\s+)?EXISTS\\s+)?([\\w_]+)`,"i"));return r?r[1]:null}function d(e){let t=e.match(/ON\s+([\w_]+)/i);return t?t[1]:null}async function u(e){let t=e.match(/^\d+_create[-_]table[_-](.+)\.sql$/i);return t||(t=e.match(/^\d+_create[-](.+)-table\.sql$/i))||(t=e.match(/^\d+_alter[-_]table[_-](.+?)(?:[_-].+)?\.sql$/i))||(t=e.match(/^\d+_alter[-](.+?)-table(?:[_-].+)?\.sql$/i))||(t=e.match(/^\d+_create[-_]index[-_](.+)\.sql$/i))?t[1]:null}function R(e){return e.split("\n").filter(e=>!e.trim().startsWith("--")).join("\n").trim()}async function p(e,t,r,a,s=!1){let i=`SELECT name FROM sqlite_master WHERE type='table' AND name = '${a}' COLLATE NOCASE;`,n=await f(e,t,i,r,s);try{let e=n.indexOf("[");if(-1!==e){let t=n.substring(e),r=JSON.parse(t);return(r[0]?.results||[]).length>0}return!1}catch(e){return console.error("Error parsing tableExists result:",e),!1}}function A(e){return e.replace(/--.*$/gm,"").replace(/\/\*[\s\S]*?\*\//g,"").trim().split(";").map(e=>e.trim()).filter(e=>e.length>0).map(e=>c(e+";"))}async function f(e,t,r,a={},s=!1){try{let l=r.trim().replace(/\s+/g," "),E=l.toUpperCase();(E.startsWith("CREATE INDEX")||E.startsWith("CREATE UNIQUE INDEX"))&&!E.includes("IF NOT EXISTS")&&(l=E.startsWith("CREATE UNIQUE INDEX")?l.replace(/CREATE\s+UNIQUE\s+INDEX/i,"CREATE UNIQUE INDEX IF NOT EXISTS"):l.replace(/CREATE\s+INDEX/i,"CREATE INDEX IF NOT EXISTS"));let o="win32"===process.platform,c=`${o?"npx.cmd":"npx"} wrangler d1 execute ${t} ${s?"--remote":"--local"} --command="${l.replace(/"/g,'\\"')}"`;i.A.shouldLog("debug")&&i.A.debug("Executing command:",c);let m={cwd:e,env:{...process.env,...a},maxBuffer:0xa00000,shell:!0},{stdout:T,stderr:d}=await n(c,m);if(d&&!d.includes("\uD83C\uDF00"))throw Error(d);try{let e=T.indexOf("[");if(-1!==e)return T.substring(e)}catch(e){console.warn("JSON parse warning:",e)}return T}catch(e){throw console.error("SQL Execution error:",e),{type:E.EXECUTION_ERROR,message:"Failed to execute SQL command",details:{command:e.cmd,stderr:e.stderr,stdout:e.stdout,originalError:e.message,suggestions:["Ensure Node.js and Wrangler are installed","Check npx in PATH","Verify the D1 database exists and is configured","Check wrangler.toml configuration"]}}}}function N(e){let t=e.trim(),r=t.toUpperCase();return r.startsWith("CREATE TABLE")?function(e){let t=e.match(/CREATE\s+TABLE\s+(?:IF\s+NOT\s+EXISTS\s+)?(\w+)\s*\(([\s\S]*)\)/i);if(!t)return e;let[,r,a]=t,s=h(a).map(e=>e.trim()).filter(Boolean);return`CREATE TABLE ${r} (
|
|
33
|
+
${s.join(",\n ")}
|
|
34
|
+
);`}(t):r.startsWith("CREATE INDEX")||r.startsWith("CREATE UNIQUE INDEX")?function(e){let t=e.match(/CREATE\s+(UNIQUE\s+)?INDEX\s+(?:IF\s+NOT\s+EXISTS\s+)?(\w+)\s+ON\s+(\w+)\s*\((.*)\)/i);if(!t)return e;let[,r,a,s,i]=t,n=i.split(",").map(e=>e.trim()).join(", ");return`CREATE ${r||""}INDEX ${a} ON ${s} (${n});`}(t):r.startsWith("ALTER TABLE")?function(e){let t=e.match(/ALTER\s+TABLE\s+(\w+)\s+(.*)/i);if(!t)return e;let[,r,a]=t,s=h(a);return 1===s.length?`ALTER TABLE ${r} ${s[0]};`:`ALTER TABLE ${r}
|
|
35
|
+
${s.map((e,t)=>` ${e}${t<s.length-1?",":";"}`).join("\n")}`}(t):r.startsWith("DROP TABLE")||r.startsWith("DROP INDEX")?function(e){let t=e.match(/DROP\s+(TABLE|INDEX)\s+(?:IF\s+EXISTS\s+)?(\w+)/i);if(!t)return e;let[,r,a]=t;return`DROP ${r} IF EXISTS ${a};`}(t):r.startsWith("INSERT INTO")?function(e){let t=e.match(/INSERT\s+INTO\s+(\w+)\s*(\([^)]+\))?\s*VALUES\s*(.+)/i);if(!t)return e;let[,r,a,s]=t,i=h(s);return`INSERT INTO ${r}${a?` ${a}`:""}
|
|
36
|
+
VALUES
|
|
37
|
+
`+i.map((e,t)=>` ${e}${t<i.length-1?",":";"}`).join("\n")}(t):r.startsWith("UPDATE")?function(e){let t=e.match(/UPDATE\s+(\w+)\s+SET\s+(.+?)(?:\s+WHERE\s+(.+))?$/i);if(!t)return e;let[,r,a,s]=t,i=h(a),n=`UPDATE ${r}
|
|
38
|
+
SET
|
|
39
|
+
${i.map(e=>` ${e.trim()}`).join(",\n")}`;return s&&(n+=`
|
|
40
|
+
WHERE
|
|
41
|
+
${s.trim()}`),n+";"}(t):r.startsWith("DELETE FROM")?function(e){let t=e.match(/DELETE\s+FROM\s+(\w+)(?:\s+WHERE\s+(.+))?$/i);if(!t)return e;let[,r,a]=t,s=`DELETE FROM ${r}`;return a&&(s+=`
|
|
42
|
+
WHERE
|
|
43
|
+
${a.trim()}`),s+";"}(t):r.startsWith("SELECT")?function(e){let t=e.match(/SELECT\s+(.+?)\s+FROM\s+(.+?)(?:\s+WHERE\s+(.+?))?(?:\s+GROUP\s+BY\s+(.+?))?(?:\s+HAVING\s+(.+?))?(?:\s+ORDER\s+BY\s+(.+?))?(?:\s+LIMIT\s+(.+?))?$/i);if(!t)return e;let[,r,a,s,i,n,l,E]=t,o=`SELECT
|
|
44
|
+
${r.split(",").map(e=>e.trim()).join(",\n ")}
|
|
45
|
+
FROM
|
|
46
|
+
${a.trim()}`;return s&&(o+=`
|
|
47
|
+
WHERE
|
|
48
|
+
${s.trim()}`),i&&(o+=`
|
|
49
|
+
GROUP BY
|
|
50
|
+
${i.trim()}`),n&&(o+=`
|
|
51
|
+
HAVING
|
|
52
|
+
${n.trim()}`),l&&(o+=`
|
|
53
|
+
ORDER BY
|
|
54
|
+
${l.trim()}`),E&&(o+=`
|
|
55
|
+
LIMIT ${E.trim()}`),o+";"}(t):t+";"}function h(e){let t=[],r="",a=0,s=!1,i="";for(let n of e)'"'===n&&"\\"!==i&&(s=!s),!s&&("("===n&&a++,")"===n&&a--),","!==n||0!==a||s?r+=n:(t.push(r.trim()),r=""),i=n;return r.trim()&&t.push(r.trim()),t}function I(e){return e.split(";").map(e=>e.trim()).filter(e=>e.length>0).map(e=>N(e)).join("\n\n")+"\n"}async function g(e,t,r,a){try{let s;let i=await u(r);if(i){let r=await f(e,t,`SELECT sql FROM sqlite_master WHERE type='table' AND name='${i}';`,a,!0);try{let e=JSON.parse(r);s=e[0]?.results?.[0]?.sql}catch(e){console.error("Error parsing sqlite_master result:",e)}}if(!s&&r.includes("create-index")){let i=r.match(/create-index[-_]([^_.]+)/);if(i){let r=await f(e,t,`SELECT sql FROM sqlite_master WHERE type='index' AND name='${i[1]}';`,a,!0),n=JSON.parse(r);s=n[0]?.results?.[0]?.sql}}if(!s&&i){let r=await f(e,t,`SELECT sql FROM sqlite_master WHERE name LIKE '%${i}%' LIMIT 1;`,a,!0);try{let e=JSON.parse(r);s=e[0]?.results?.[0]?.sql}catch(e){console.error("Error parsing fallback result:",e)}}if(!s)throw Error(`Could not retrieve SQL content for migration: ${r}`);return s+";"}catch(e){throw{type:E.EXECUTION_ERROR,message:`Failed to get migration file content: ${e.message}`,details:{file:r,error:e.message,suggestions:["Check if the table exists in the remote database","Verify the migration filename follows the expected pattern","Ensure you have permissions to access the remote database"]}}}}}};
|