@uploadista/server 0.0.17-beta.6 → 0.0.17-beta.9

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.
@@ -1 +1 @@
1
- const e=require(`../auth-B3XCQncE.cjs`);exports.getAuthCredentials=e.t;
1
+ const e=require(`../auth-Ck4gisA2.cjs`);exports.getAuthCredentials=e.t;
@@ -1 +1 @@
1
- import{t as e}from"../auth-D2lKhlzK.mjs";export{e as getAuthCredentials};
1
+ import{t as e}from"../auth-DG0enyjj.mjs";export{e as getAuthCredentials};
@@ -1,2 +1,2 @@
1
1
  const e=async({uploadistaClientId:e,uploadistaApiKey:t,baseUrl:n=`https://api.uploadista.com`})=>{let r=await fetch(`${n}/uploadista/auth/jwt?apiKey=${t}&clientId=${e}`,{method:`GET`,headers:{"Content-Type":`application/json`}});return r.ok===!0?{isValid:!0,data:await r.json()}:{isValid:!1,error:`Failed to get auth credentials`}};export{e as t};
2
- //# sourceMappingURL=auth-D2lKhlzK.mjs.map
2
+ //# sourceMappingURL=auth-DG0enyjj.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"auth-D2lKhlzK.mjs","names":[],"sources":["../src/auth/get-auth-credentials.ts"],"sourcesContent":["/**\n * Response type for authentication credential requests.\n * - `isValid: true` with token and expiration\n * - `isValid: false` with error message\n *\n * @example\n * ```typescript\n * const response = await getAuthCredentials({\n * uploadistaClientId: \"my-client\",\n * uploadistaApiKey: \"sk_...\"\n * });\n * if (response.isValid) {\n * console.log(`Token: ${response.data.token}`);\n * } else {\n * console.error(`Auth failed: ${response.error}`);\n * }\n * ```\n */\nexport type AuthCredentialsResponse =\n | {\n isValid: true;\n data: { token: string; expiresIn: number };\n }\n | {\n isValid: false;\n error: string;\n };\n\n/**\n * Retrieve JWT authentication credentials from the Uploadista server.\n * This function exchanges client credentials (ID + API key) for a signed JWT token.\n *\n * The JWT token is then used in subsequent API requests via the Authorization header.\n * Tokens are time-limited and should be refreshed before expiration.\n *\n * @param params - Credential exchange parameters\n * @param params.uploadistaClientId - Your Uploadista client ID\n * @param params.uploadistaApiKey - Your Uploadista API key (secret)\n * @param params.baseUrl - Uploadista server base URL (default: https://api.uploadista.com)\n * @returns Promise resolving to authentication response with token or error\n *\n * @example\n * ```typescript\n * import { getAuthCredentials } from \"@uploadista/server\";\n *\n * // Get JWT token for API requests\n * const response = await getAuthCredentials({\n * uploadistaClientId: process.env.UPLOADISTA_CLIENT_ID,\n * uploadistaApiKey: process.env.UPLOADISTA_API_KEY,\n * });\n *\n * if (response.isValid) {\n * // Use token in API requests\n * const headers = {\n * Authorization: `Bearer ${response.data.token}`,\n * };\n *\n * // Token expires in response.data.expiresIn seconds\n * setTimeout(\n * () => {\n * // Refresh token before expiration\n * },\n * response.data.expiresIn * 1000,\n * );\n * }\n * ```\n */\nexport const getAuthCredentials = async ({\n uploadistaClientId,\n uploadistaApiKey,\n baseUrl = \"https://api.uploadista.com\",\n}: {\n uploadistaClientId: string;\n uploadistaApiKey: string;\n baseUrl?: string;\n}): Promise<AuthCredentialsResponse> => {\n const response = await fetch(\n `${baseUrl}/uploadista/auth/jwt?apiKey=${uploadistaApiKey}&clientId=${uploadistaClientId}`,\n {\n method: \"GET\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n },\n );\n\n if (response.ok !== true) {\n return { isValid: false, error: \"Failed to get auth credentials\" };\n }\n\n const data = (await response.json()) as { token: string; expiresIn: number };\n\n return {\n isValid: true,\n data,\n };\n};\n"],"mappings":"AAmEA,MAAa,EAAqB,MAAO,CACvC,qBACA,mBACA,UAAU,gCAK4B,CACtC,IAAM,EAAW,MAAM,MACrB,GAAG,EAAQ,8BAA8B,EAAiB,YAAY,IACtE,CACE,OAAQ,MACR,QAAS,CACP,eAAgB,mBACjB,CACF,CACF,CAQD,OANI,EAAS,KAAO,GAMb,CACL,QAAS,GACT,KAJY,MAAM,EAAS,MAAM,CAKlC,CARQ,CAAE,QAAS,GAAO,MAAO,iCAAkC"}
1
+ {"version":3,"file":"auth-DG0enyjj.mjs","names":[],"sources":["../src/auth/get-auth-credentials.ts"],"sourcesContent":["/**\n * Response type for authentication credential requests.\n * - `isValid: true` with token and expiration\n * - `isValid: false` with error message\n *\n * @example\n * ```typescript\n * const response = await getAuthCredentials({\n * uploadistaClientId: \"my-client\",\n * uploadistaApiKey: \"sk_...\"\n * });\n * if (response.isValid) {\n * console.log(`Token: ${response.data.token}`);\n * } else {\n * console.error(`Auth failed: ${response.error}`);\n * }\n * ```\n */\nexport type AuthCredentialsResponse =\n | {\n isValid: true;\n data: { token: string; expiresIn: number };\n }\n | {\n isValid: false;\n error: string;\n };\n\n/**\n * Retrieve JWT authentication credentials from the Uploadista server.\n * This function exchanges client credentials (ID + API key) for a signed JWT token.\n *\n * The JWT token is then used in subsequent API requests via the Authorization header.\n * Tokens are time-limited and should be refreshed before expiration.\n *\n * @param params - Credential exchange parameters\n * @param params.uploadistaClientId - Your Uploadista client ID\n * @param params.uploadistaApiKey - Your Uploadista API key (secret)\n * @param params.baseUrl - Uploadista server base URL (default: https://api.uploadista.com)\n * @returns Promise resolving to authentication response with token or error\n *\n * @example\n * ```typescript\n * import { getAuthCredentials } from \"@uploadista/server\";\n *\n * // Get JWT token for API requests\n * const response = await getAuthCredentials({\n * uploadistaClientId: process.env.UPLOADISTA_CLIENT_ID,\n * uploadistaApiKey: process.env.UPLOADISTA_API_KEY,\n * });\n *\n * if (response.isValid) {\n * // Use token in API requests\n * const headers = {\n * Authorization: `Bearer ${response.data.token}`,\n * };\n *\n * // Token expires in response.data.expiresIn seconds\n * setTimeout(\n * () => {\n * // Refresh token before expiration\n * },\n * response.data.expiresIn * 1000,\n * );\n * }\n * ```\n */\nexport const getAuthCredentials = async ({\n uploadistaClientId,\n uploadistaApiKey,\n baseUrl = \"https://api.uploadista.com\",\n}: {\n uploadistaClientId: string;\n uploadistaApiKey: string;\n baseUrl?: string;\n}): Promise<AuthCredentialsResponse> => {\n const response = await fetch(\n `${baseUrl}/uploadista/auth/jwt?apiKey=${uploadistaApiKey}&clientId=${uploadistaClientId}`,\n {\n method: \"GET\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n },\n );\n\n if (response.ok !== true) {\n return { isValid: false, error: \"Failed to get auth credentials\" };\n }\n\n const data = (await response.json()) as { token: string; expiresIn: number };\n\n return {\n isValid: true,\n data,\n };\n};\n"],"mappings":"AAmEA,MAAa,EAAqB,MAAO,CACvC,qBACA,mBACA,UAAU,gCAK4B,CACtC,IAAM,EAAW,MAAM,MACrB,GAAG,EAAQ,8BAA8B,EAAiB,YAAY,IACtE,CACE,OAAQ,MACR,QAAS,CACP,eAAgB,mBACjB,CACF,CACF,CAQD,OANI,EAAS,KAAO,GAMb,CACL,QAAS,GACT,KAJY,MAAM,EAAS,MAAM,CAKlC,CARQ,CAAE,QAAS,GAAO,MAAO,iCAAkC"}
package/dist/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- const e=require(`./auth-B3XCQncE.cjs`);let t=require(`effect`),n=require(`@uploadista/core/flow`),r=require(`@uploadista/core/types`),i=require(`@uploadista/core/utils`),a=require(`@uploadista/event-broadcaster-memory`),o=require(`@uploadista/event-emitter-websocket`),s=require(`@uploadista/observability`),c=require(`@uploadista/core/upload`),l=require(`@uploadista/core/errors`);var u=class extends t.Context.Tag(`AuthCacheService`)(){};const d=(e={})=>{let n=e.maxSize??1e4,r=e.ttl??36e5,i=new Map,a=()=>{let e=Date.now();for(let[t,n]of i.entries())e-n.timestamp>r&&i.delete(t)},o=()=>{if(i.size<=n)return;let e=null,t=1/0;for(let[n,r]of i.entries())r.timestamp<t&&(t=r.timestamp,e=n);e&&i.delete(e)};return t.Layer.succeed(u,{set:(e,n)=>t.Effect.sync(()=>{i.size%100==0&&a(),i.set(e,{authContext:n,timestamp:Date.now()}),o()}),get:e=>t.Effect.sync(()=>{let t=i.get(e);return t?Date.now()-t.timestamp>r?(i.delete(e),null):t.authContext:null}),delete:e=>t.Effect.sync(()=>{i.delete(e)}),clear:()=>t.Effect.sync(()=>{i.clear()}),size:()=>t.Effect.sync(()=>i.size)})},f=t.Layer.succeed(u,{set:()=>t.Effect.void,get:()=>t.Effect.succeed(null),delete:()=>t.Effect.void,clear:()=>t.Effect.void,size:()=>t.Effect.succeed(0)}),p=e=>e.split(`/`).filter(Boolean),m=e=>{let t=p(e);return t[t.length-1]},h=(e,t)=>e.includes(`${t}/api/`),g=(e,t)=>e.replace(`${t}/api/`,``).split(`/`).filter(Boolean),_=e=>{let t=500,n=`UNKNOWN_ERROR`,r=`Internal server error`,i;if(typeof e==`object`&&e){let a=e;if(`code`in a&&typeof a.code==`string`&&(n=a.code),`message`in a&&typeof a.message==`string`?r=a.message:`body`in a&&typeof a.body==`string`&&(r=a.body),`details`in a&&(i=a.details),`status`in a&&typeof a.status==`number`)t=a.status;else if(`code`in a)switch(a.code){case`FILE_NOT_FOUND`:case`FLOW_JOB_NOT_FOUND`:case`UPLOAD_ID_NOT_FOUND`:t=404;break;case`FLOW_JOB_ERROR`:case`VALIDATION_ERROR`:case`INVALID_METADATA`:case`INVALID_LENGTH`:case`ABORTED`:case`INVALID_TERMINATION`:t=400;break;case`INVALID_OFFSET`:t=409;break;case`ERR_SIZE_EXCEEDED`:case`ERR_MAX_SIZE_EXCEEDED`:t=413;break;case`FILE_NO_LONGER_EXISTS`:t=410;break;case`MISSING_OFFSET`:case`INVALID_CONTENT_TYPE`:t=403;break;default:t=500}`message`in a&&a.message===`Invalid JSON body`&&(t=400,n=`VALIDATION_ERROR`)}let a={status:t,code:n,message:r};return i!==void 0&&(a.details=i),a},v=e=>e[e.length-2],y=e=>({jobId:e[e.length-3],nodeId:e[e.length-1]}),b=e=>({storageId:e.pop(),flowId:e.pop()}),x=({kvStore:e,eventEmitter:n,dataStore:i,bufferedDataStore:a,generateId:o})=>{let s=t.Layer.provide(r.uploadFileKvStore,e),l=t.Layer.provide(i,s),u=a?t.Layer.provide(a,s):t.Layer.empty,d=t.Layer.provide(r.uploadEventEmitter,n),f=t.Layer.mergeAll(l,s,d,...o?[o]:[],u);return t.Layer.provide(c.uploadServer,f)},S=({kvStore:e,eventEmitter:i,flowProvider:a,uploadServer:o})=>{let s=t.Layer.provide(r.flowJobKvStore,e),c=t.Layer.provide(r.flowEventEmitter,i),l=t.Layer.mergeAll(a,c,s,o);return t.Layer.provide(n.flowServer,l)};var C=class extends t.Context.Tag(`AuthContextService`)(){};const w=e=>t.Layer.succeed(C,{getClientId:()=>t.Effect.succeed(e?.clientId??null),getMetadata:()=>t.Effect.succeed(e?.metadata??{}),hasPermission:n=>t.Effect.succeed(e?.permissions?.includes(n)??!1),getAuthContext:()=>t.Effect.succeed(e)}),T=w(null),E=({flowId:e})=>t.Effect.gen(function*(){let r=yield*n.FlowServer,i=yield*(yield*C).getClientId();return i&&(yield*t.Effect.logInfo(`[Flow] Getting flow data: ${e}, client: ${i}`)),{status:200,body:yield*r.getFlowData(e,i)}}),D=({flowId:e,storageId:r,inputs:i})=>t.Effect.gen(function*(){let a=yield*n.FlowServer,o=yield*C,s=yield*u,c=yield*o.getClientId();c?(yield*t.Effect.logInfo(`[Flow] Executing flow: ${e}, storage: ${r}, client: ${c}`),yield*t.Effect.logInfo(JSON.stringify(i,null,2))):(yield*t.Effect.logInfo(`[Flow] Executing flow: ${e}, storage: ${r}`),yield*t.Effect.logInfo(`[Flow] Inputs: ${JSON.stringify(i,null,2)}`)),yield*t.Effect.logInfo(`[Flow] Calling flowServer.runFlow...`);let l=yield*a.runFlow({flowId:e,storageId:r,clientId:c,inputs:i}).pipe(t.Effect.tap(()=>t.Effect.logInfo(`[Flow] runFlow completed successfully`)),t.Effect.tapError(e=>t.Effect.logError(`[Flow] runFlow failed with error: ${e}`))),d=yield*o.getAuthContext();return d&&(yield*s.set(l.id,d)),yield*t.Effect.logInfo(`[Flow] Flow started with jobId: ${l.id}`),{status:200,body:l}}),O=({jobId:e})=>t.Effect.gen(function*(){let r=yield*n.FlowServer,i=yield*C,a=yield*u,o=yield*i.getClientId();if(!e)throw Error(`No job id`);o&&(yield*t.Effect.logInfo(`[Flow] Getting job status: ${e}, client: ${o}`));let s=yield*r.getJobStatus(e);return(s.status===`completed`||s.status===`failed`)&&(yield*a.delete(e),o&&(yield*t.Effect.logInfo(`[Flow] Flow ${s.status}, cleared auth cache: ${e}`))),{status:200,body:s}}),k=({jobId:e,nodeId:r,newData:i})=>t.Effect.gen(function*(){let a=yield*n.FlowServer,o=yield*C,s=yield*u,c=yield*o.getClientId();if(c||=(yield*s.get(e))?.clientId??null,c&&(yield*t.Effect.logInfo(`[Flow] Continuing flow: jobId=${e}, nodeId=${r}, client: ${c}`)),i===void 0)throw Error(`Missing newData`);let l=yield*a.resumeFlow({jobId:e,nodeId:r,newData:i,clientId:c});return(l.status===`completed`||l.status===`failed`)&&(yield*s.delete(e),c&&(yield*t.Effect.logInfo(`[Flow] Flow ${l.status}, cleared auth cache: ${e}`))),{status:200,body:l}}),A=({jobId:e})=>t.Effect.gen(function*(){let r=yield*n.FlowServer,i=yield*C,a=yield*u,o=yield*i.getClientId();o||=(yield*a.get(e))?.clientId??null,o&&(yield*t.Effect.logInfo(`[Flow] Pausing flow: jobId=${e}, client: ${o}`));let s=yield*r.pauseFlow(e,o);return o&&(yield*t.Effect.logInfo(`[Flow] Flow paused: ${e}, status: ${s.status}`)),{status:200,body:s}}),j=({jobId:e})=>t.Effect.gen(function*(){let r=yield*n.FlowServer,i=yield*C,a=yield*u;if(!e)throw Error(`No job id`);let o=yield*i.getClientId();o||=(yield*a.get(e))?.clientId??null,o&&(yield*t.Effect.logInfo(`[Flow] Cancelling flow: jobId=${e}, client: ${o}`));let s=yield*r.cancelFlow(e,o);return yield*a.delete(e),o&&(yield*t.Effect.logInfo(`[Flow] Flow cancelled, cleared auth cache: ${e}`)),{status:200,body:s}});var M=class extends Error{constructor(e,t=500,n=`INTERNAL_ERROR`){super(e),this.statusCode=t,this.errorCode=n,this.name=`AdapterError`}},N=class extends M{constructor(e){super(e,400,`VALIDATION_ERROR`),this.name=`ValidationError`}},P=class extends M{constructor(e){super(`${e} not found`,404,`NOT_FOUND`),this.name=`NotFoundError`}},F=class extends M{constructor(e){super(e,400,`BAD_REQUEST`),this.name=`BadRequestError`}};const I=e=>({error:e.message,code:e.errorCode,timestamp:new Date().toISOString()}),L=e=>{let t={error:e.body,code:e.code,timestamp:new Date().toISOString()};return e.details!==void 0&&(t.details=e.details),t},R=(e=`Internal server error`)=>({error:e,code:`INTERNAL_ERROR`,timestamp:new Date().toISOString()}),ee=e=>t.Effect.gen(function*(){let n=yield*c.UploadServer,a=yield*C,o=yield*u,s=yield*a.getClientId();s&&(yield*t.Effect.logInfo(`[Upload] Creating upload for client: ${s}`));let l=yield*t.Effect.sync(()=>r.inputFileSchema.safeParse(e.data));if(!l.success)return yield*t.Effect.fail(new N(`Invalid input file schema`));if(l.data.checksumAlgorithm&&!(0,i.isSupportedAlgorithm)(l.data.checksumAlgorithm))return yield*t.Effect.fail(new N(`Unsupported checksum algorithm: ${l.data.checksumAlgorithm}. Supported algorithms: sha256`));let d=yield*n.createUpload(l.data,s),f=yield*a.getAuthContext();return f&&(yield*o.set(d.id,f)),s&&(yield*t.Effect.logInfo(`[Upload] Upload created: ${d.id} for client: ${s}`)),{status:200,body:d}}),z=({storageId:e})=>t.Effect.gen(function*(){let t=yield*c.UploadServer,n=yield*(yield*C).getClientId();return{status:200,body:{storageId:e,capabilities:yield*t.getCapabilities(e,n),timestamp:new Date().toISOString()}}}),B=({uploadId:e})=>t.Effect.gen(function*(){return{status:200,body:yield*(yield*c.UploadServer).getUpload(e)}}),V=e=>t.Effect.gen(function*(){let n=yield*c.UploadServer,r=yield*C,i=yield*u,a=yield*s.MetricsService,{uploadId:o,data:l}=e,d=yield*r.getClientId(),f=yield*r.getMetadata();if(!d){let e=yield*i.get(o);d=e?.clientId??null,f=e?.metadata??{}}d&&(yield*t.Effect.logInfo(`[Upload] Uploading chunk for upload: ${o}, client: ${d}`));let p=yield*n.uploadChunk(o,d,l);return p.size&&p.offset>=p.size&&(yield*i.delete(o),d&&(yield*t.Effect.logInfo(`[Upload] Upload completed, cleared auth cache: ${o}`)),d&&p.size?(yield*t.Effect.logInfo(`[Upload] Recording metrics for org: ${d}, size: ${p.size}`),yield*t.Effect.forkDaemon(a.recordUpload(d,p.size,f))):yield*t.Effect.logWarning(`[Upload] Cannot record metrics - missing organizationId or size`)),d&&(yield*t.Effect.logInfo(`[Upload] Chunk uploaded for upload: ${o}, client: ${d}`)),{status:200,body:p}}),H=e=>t.Effect.gen(function*(){switch(e.type){case`create-upload`:return yield*ee(e);case`get-capabilities`:return yield*z(e);case`get-upload`:return yield*B(e);case`upload-chunk`:return yield*V(e);case`get-flow`:return yield*E(e);case`run-flow`:return yield*D(e);case`job-status`:return yield*O(e);case`resume-flow`:return yield*k(e);case`pause-flow`:return yield*A(e);case`cancel-flow`:return yield*j(e);case`not-found`:return{status:404,headers:{"Content-Type":`application/json`},body:{error:`Not found`}};case`bad-request`:return{status:400,body:{error:`Bad request`,message:e.message}};case`method-not-allowed`:return{status:405,headers:{"Content-Type":`application/json`},body:{error:`Method not allowed`}};case`unsupported-content-type`:return{status:415,headers:{"Content-Type":`application/json`},body:{error:`Unsupported content type`}}}}),U=async({flows:e,dataStore:c,kvStore:l,plugins:u=[],eventEmitter:f,eventBroadcaster:p=a.memoryEventBroadcaster,withTracing:m=!1,baseUrl:h=`uploadista`,generateId:g=i.GenerateIdLive,metricsLayer:v,bufferedDataStore:y,adapter:b,authCacheConfig:C})=>{let T=f??(0,o.webSocketEventEmitter)(p),E=h.endsWith(`/`)?h.slice(0,-1):h,D=t.Layer.effect(n.FlowProvider,t.Effect.succeed({getFlow:(t,n)=>e(t,n)}));if(!T)throw Error(`eventEmitter is required. Provide an event emitter layer in the configuration.`);let O=x({kvStore:l,eventEmitter:T,dataStore:await(0,r.createDataStoreLayer)(c),bufferedDataStore:y,generateId:g}),k=S({kvStore:l,eventEmitter:T,flowProvider:D,uploadServer:O}),A=d(C),j=v??s.NoOpMetricsServiceLive,M=t.Layer.mergeAll(O,k,j,A,...u),N=t.ManagedRuntime.make(M);return{handler:async e=>{let r=t.Effect.gen(function*(){let r=yield*b.extractRequest(e,{baseUrl:E}),i=null;if(b.runAuthMiddleware){let n=yield*b.runAuthMiddleware(e).pipe(t.Effect.timeout(`5 seconds`),t.Effect.catchAll(()=>(console.error(`Auth middleware timeout exceeded (5 seconds)`),t.Effect.succeed({_tag:`TimeoutError`}))),t.Effect.catchAllCause(e=>(console.error(`Auth middleware error:`,e),t.Effect.succeed({_tag:`AuthError`,error:e}))));if(n&&typeof n==`object`&&`_tag`in n&&n._tag===`TimeoutError`)return yield*b.sendResponse({status:503,headers:{"Content-Type":`application/json`},body:{error:`Authentication service unavailable`,message:`Authentication took too long to respond. Please try again.`}},e);if(n&&typeof n==`object`&&`_tag`in n&&n._tag===`AuthError`)return yield*b.sendResponse({status:500,headers:{"Content-Type":`application/json`},body:{error:`Internal Server Error`,message:`An error occurred during authentication`}},e);if(n===null)return yield*b.sendResponse({status:401,headers:{"Content-Type":`application/json`},body:{error:`Unauthorized`,message:`Invalid credentials`}},e);i=n}let a=w(i),o=[];if(b.extractWaitUntil){let r=b.extractWaitUntil(e);r&&o.push(t.Layer.succeed(n.FlowWaitUntil,r))}let s=t.Layer.mergeAll(a,A,j,...u,...o);if(r.type===`not-found`)return yield*b.sendResponse({type:`not-found`,status:404,headers:{"Content-Type":`application/json`},body:{error:`Not found`}},e);let c=yield*H(r).pipe(t.Effect.provide(s));return yield*b.sendResponse(c,e)}).pipe(t.Effect.catchAll(t=>{let n=_(t),r={code:n.code,message:n.message};n.details!==void 0&&(r.details=n.details);let i={status:n.status,headers:{"Content-Type":`application/json`},body:r};return b.sendResponse(i,e)}));return m?N.runPromise(r.pipe(t.Effect.provide(s.NodeSdkLive))):N.runPromise(r)},websocketHandler:await N.runPromise(b.webSocketHandler({baseUrl:E})),baseUrl:E,dispose:()=>N.dispose()}};async function W(e){return U(e)}function G(e){return e}function K(e){return e}const q={ImagePlugin:{packageName:`@uploadista/flow-images-sharp`,variableName:`sharpImagePlugin`},ImageAiPlugin:{packageName:`@uploadista/flow-images-replicate`,variableName:`replicateImagePlugin`},ZipPlugin:{packageName:`@uploadista/flow-utility-zipjs`,variableName:`zipPlugin`},CredentialProvider:{packageName:`@uploadista/core`,variableName:`credentialProviderLayer`}};function J(e){try{let t=e;if(t._tag)return t._tag;if(t.constructor?.name)return t.constructor.name;if(t.context?.services){let e=Array.from(t.context.services.keys());if(e.length>0){let t=e[0];if(t.key)return t.key}}return null}catch{return null}}function Y(e){return e.map(e=>J(e)).filter(e=>e!==null)}function X(e){let{plugins:t,expectedServices:n=[]}=e,r=Y(t),i=n.filter(e=>!r.includes(e));return i.length===0?{success:!0}:{success:!1,required:n,provided:r,missing:i,suggestions:i.map(e=>{let t=q[e];return t?{name:e,packageName:t.packageName,importStatement:`import { ${t.variableName} } from '${t.packageName}';`}:null}).filter(e=>e!==null)}}function Z(e){let t=[`Server initialization failed: Missing required plugins`,``,`Required: ${e.required.join(`, `)}`,`Provided: ${e.provided.length>0?e.provided.join(`, `):`(none)`}`,`Missing: ${e.missing.join(`, `)}`,``];if(e.suggestions.length>0){t.push(`Add the missing plugins to your configuration:`),t.push(``);for(let n of e.suggestions)t.push(` ${n.importStatement}`);t.push(``),t.push(` const server = await createUploadistaServer({`),t.push(` plugins: [${[...e.provided,...e.missing.map(e=>q[e]?.variableName||e)].join(`, `)}],`),t.push(` // ...`),t.push(` });`)}else t.push(`Note: Could not determine package names for missing plugins.`),t.push(`Please ensure all required plugin layers are provided.`);return t.join(`
1
+ const e=require(`./auth-Ck4gisA2.cjs`);let t=require(`effect`),n=require(`@uploadista/core/flow`),r=require(`@uploadista/core/types`),i=require(`@uploadista/core/utils`),a=require(`@uploadista/event-broadcaster-memory`),o=require(`@uploadista/event-emitter-websocket`),s=require(`@uploadista/observability`),c=require(`@uploadista/core/upload`),l=require(`@uploadista/core/errors`);var u=class extends t.Context.Tag(`AuthCacheService`)(){};const d=(e={})=>{let n=e.maxSize??1e4,r=e.ttl??36e5,i=new Map,a=()=>{let e=Date.now();for(let[t,n]of i.entries())e-n.timestamp>r&&i.delete(t)},o=()=>{if(i.size<=n)return;let e=null,t=1/0;for(let[n,r]of i.entries())r.timestamp<t&&(t=r.timestamp,e=n);e&&i.delete(e)};return t.Layer.succeed(u,{set:(e,n)=>t.Effect.sync(()=>{i.size%100==0&&a(),i.set(e,{authContext:n,timestamp:Date.now()}),o()}),get:e=>t.Effect.sync(()=>{let t=i.get(e);return t?Date.now()-t.timestamp>r?(i.delete(e),null):t.authContext:null}),delete:e=>t.Effect.sync(()=>{i.delete(e)}),clear:()=>t.Effect.sync(()=>{i.clear()}),size:()=>t.Effect.sync(()=>i.size)})},f=t.Layer.succeed(u,{set:()=>t.Effect.void,get:()=>t.Effect.succeed(null),delete:()=>t.Effect.void,clear:()=>t.Effect.void,size:()=>t.Effect.succeed(0)}),p=e=>e.split(`/`).filter(Boolean),m=e=>{let t=p(e);return t[t.length-1]},h=(e,t)=>e.includes(`${t}/api/`),g=(e,t)=>e.replace(`${t}/api/`,``).split(`/`).filter(Boolean),_=e=>{let t=500,n=`UNKNOWN_ERROR`,r=`Internal server error`,i;if(typeof e==`object`&&e){let a=e;if(`code`in a&&typeof a.code==`string`&&(n=a.code),`message`in a&&typeof a.message==`string`?r=a.message:`body`in a&&typeof a.body==`string`&&(r=a.body),`details`in a&&(i=a.details),`status`in a&&typeof a.status==`number`)t=a.status;else if(`code`in a)switch(a.code){case`FILE_NOT_FOUND`:case`FLOW_JOB_NOT_FOUND`:case`UPLOAD_ID_NOT_FOUND`:t=404;break;case`FLOW_JOB_ERROR`:case`VALIDATION_ERROR`:case`INVALID_METADATA`:case`INVALID_LENGTH`:case`ABORTED`:case`INVALID_TERMINATION`:t=400;break;case`INVALID_OFFSET`:t=409;break;case`ERR_SIZE_EXCEEDED`:case`ERR_MAX_SIZE_EXCEEDED`:t=413;break;case`FILE_NO_LONGER_EXISTS`:t=410;break;case`MISSING_OFFSET`:case`INVALID_CONTENT_TYPE`:t=403;break;default:t=500}`message`in a&&a.message===`Invalid JSON body`&&(t=400,n=`VALIDATION_ERROR`)}let a={status:t,code:n,message:r};return i!==void 0&&(a.details=i),a},v=e=>e[e.length-2],y=e=>({jobId:e[e.length-3],nodeId:e[e.length-1]}),b=e=>({storageId:e.pop(),flowId:e.pop()}),x=({kvStore:e,eventEmitter:n,dataStore:i,bufferedDataStore:a,generateId:o})=>{let s=t.Layer.provide(r.uploadFileKvStore,e),l=t.Layer.provide(i,s),u=a?t.Layer.provide(a,s):t.Layer.empty,d=t.Layer.provide(r.uploadEventEmitter,n),f=t.Layer.mergeAll(l,s,d,...o?[o]:[],u);return t.Layer.provide(c.uploadServer,f)},S=({kvStore:e,eventEmitter:i,flowProvider:a,uploadServer:o})=>{let s=t.Layer.provide(r.flowJobKvStore,e),c=t.Layer.provide(r.flowEventEmitter,i),l=t.Layer.mergeAll(a,c,s,o);return t.Layer.provide(n.flowServer,l)};var C=class extends t.Context.Tag(`AuthContextService`)(){};const w=e=>t.Layer.succeed(C,{getClientId:()=>t.Effect.succeed(e?.clientId??null),getMetadata:()=>t.Effect.succeed(e?.metadata??{}),hasPermission:n=>t.Effect.succeed(e?.permissions?.includes(n)??!1),getAuthContext:()=>t.Effect.succeed(e)}),T=w(null),E=({flowId:e})=>t.Effect.gen(function*(){let r=yield*n.FlowServer,i=yield*(yield*C).getClientId();return i&&(yield*t.Effect.logInfo(`[Flow] Getting flow data: ${e}, client: ${i}`)),{status:200,body:yield*r.getFlowData(e,i)}}),D=({flowId:e,storageId:r,inputs:i})=>t.Effect.gen(function*(){let a=yield*n.FlowServer,o=yield*C,s=yield*u,c=yield*o.getClientId();c?(yield*t.Effect.logInfo(`[Flow] Executing flow: ${e}, storage: ${r}, client: ${c}`),yield*t.Effect.logInfo(JSON.stringify(i,null,2))):(yield*t.Effect.logInfo(`[Flow] Executing flow: ${e}, storage: ${r}`),yield*t.Effect.logInfo(`[Flow] Inputs: ${JSON.stringify(i,null,2)}`)),yield*t.Effect.logInfo(`[Flow] Calling flowServer.runFlow...`);let l=yield*a.runFlow({flowId:e,storageId:r,clientId:c,inputs:i}).pipe(t.Effect.tap(()=>t.Effect.logInfo(`[Flow] runFlow completed successfully`)),t.Effect.tapError(e=>t.Effect.logError(`[Flow] runFlow failed with error: ${e}`))),d=yield*o.getAuthContext();return d&&(yield*s.set(l.id,d)),yield*t.Effect.logInfo(`[Flow] Flow started with jobId: ${l.id}`),{status:200,body:l}}),O=({jobId:e})=>t.Effect.gen(function*(){let r=yield*n.FlowServer,i=yield*C,a=yield*u,o=yield*i.getClientId();if(!e)throw Error(`No job id`);o&&(yield*t.Effect.logInfo(`[Flow] Getting job status: ${e}, client: ${o}`));let s=yield*r.getJobStatus(e);return(s.status===`completed`||s.status===`failed`)&&(yield*a.delete(e),o&&(yield*t.Effect.logInfo(`[Flow] Flow ${s.status}, cleared auth cache: ${e}`))),{status:200,body:s}}),k=({jobId:e,nodeId:r,newData:i})=>t.Effect.gen(function*(){let a=yield*n.FlowServer,o=yield*C,s=yield*u,c=yield*o.getClientId();if(c||=(yield*s.get(e))?.clientId??null,c&&(yield*t.Effect.logInfo(`[Flow] Continuing flow: jobId=${e}, nodeId=${r}, client: ${c}`)),i===void 0)throw Error(`Missing newData`);let l=yield*a.resumeFlow({jobId:e,nodeId:r,newData:i,clientId:c});return(l.status===`completed`||l.status===`failed`)&&(yield*s.delete(e),c&&(yield*t.Effect.logInfo(`[Flow] Flow ${l.status}, cleared auth cache: ${e}`))),{status:200,body:l}}),A=({jobId:e})=>t.Effect.gen(function*(){let r=yield*n.FlowServer,i=yield*C,a=yield*u,o=yield*i.getClientId();o||=(yield*a.get(e))?.clientId??null,o&&(yield*t.Effect.logInfo(`[Flow] Pausing flow: jobId=${e}, client: ${o}`));let s=yield*r.pauseFlow(e,o);return o&&(yield*t.Effect.logInfo(`[Flow] Flow paused: ${e}, status: ${s.status}`)),{status:200,body:s}}),j=({jobId:e})=>t.Effect.gen(function*(){let r=yield*n.FlowServer,i=yield*C,a=yield*u;if(!e)throw Error(`No job id`);let o=yield*i.getClientId();o||=(yield*a.get(e))?.clientId??null,o&&(yield*t.Effect.logInfo(`[Flow] Cancelling flow: jobId=${e}, client: ${o}`));let s=yield*r.cancelFlow(e,o);return yield*a.delete(e),o&&(yield*t.Effect.logInfo(`[Flow] Flow cancelled, cleared auth cache: ${e}`)),{status:200,body:s}});var M=class extends Error{constructor(e,t=500,n=`INTERNAL_ERROR`){super(e),this.statusCode=t,this.errorCode=n,this.name=`AdapterError`}},N=class extends M{constructor(e){super(e,400,`VALIDATION_ERROR`),this.name=`ValidationError`}},P=class extends M{constructor(e){super(`${e} not found`,404,`NOT_FOUND`),this.name=`NotFoundError`}},F=class extends M{constructor(e){super(e,400,`BAD_REQUEST`),this.name=`BadRequestError`}};const I=e=>({error:e.message,code:e.errorCode,timestamp:new Date().toISOString()}),L=e=>{let t={error:e.body,code:e.code,timestamp:new Date().toISOString()};return e.details!==void 0&&(t.details=e.details),t},R=(e=`Internal server error`)=>({error:e,code:`INTERNAL_ERROR`,timestamp:new Date().toISOString()}),ee=e=>t.Effect.gen(function*(){let n=yield*c.UploadServer,a=yield*C,o=yield*u,s=yield*a.getClientId();s&&(yield*t.Effect.logInfo(`[Upload] Creating upload for client: ${s}`));let l=yield*t.Effect.sync(()=>r.inputFileSchema.safeParse(e.data));if(!l.success)return yield*t.Effect.fail(new N(`Invalid input file schema`));if(l.data.checksumAlgorithm&&!(0,i.isSupportedAlgorithm)(l.data.checksumAlgorithm))return yield*t.Effect.fail(new N(`Unsupported checksum algorithm: ${l.data.checksumAlgorithm}. Supported algorithms: sha256`));let d=yield*n.createUpload(l.data,s),f=yield*a.getAuthContext();return f&&(yield*o.set(d.id,f)),s&&(yield*t.Effect.logInfo(`[Upload] Upload created: ${d.id} for client: ${s}`)),{status:200,body:d}}),z=({storageId:e})=>t.Effect.gen(function*(){let t=yield*c.UploadServer,n=yield*(yield*C).getClientId();return{status:200,body:{storageId:e,capabilities:yield*t.getCapabilities(e,n),timestamp:new Date().toISOString()}}}),B=({uploadId:e})=>t.Effect.gen(function*(){return{status:200,body:yield*(yield*c.UploadServer).getUpload(e)}}),V=e=>t.Effect.gen(function*(){let n=yield*c.UploadServer,r=yield*C,i=yield*u,a=yield*s.MetricsService,{uploadId:o,data:l}=e,d=yield*r.getClientId(),f=yield*r.getMetadata();if(!d){let e=yield*i.get(o);d=e?.clientId??null,f=e?.metadata??{}}d&&(yield*t.Effect.logInfo(`[Upload] Uploading chunk for upload: ${o}, client: ${d}`));let p=yield*n.uploadChunk(o,d,l);return p.size&&p.offset>=p.size&&(yield*i.delete(o),d&&(yield*t.Effect.logInfo(`[Upload] Upload completed, cleared auth cache: ${o}`)),d&&p.size?(yield*t.Effect.logInfo(`[Upload] Recording metrics for org: ${d}, size: ${p.size}`),yield*t.Effect.forkDaemon(a.recordUpload(d,p.size,f))):yield*t.Effect.logWarning(`[Upload] Cannot record metrics - missing organizationId or size`)),d&&(yield*t.Effect.logInfo(`[Upload] Chunk uploaded for upload: ${o}, client: ${d}`)),{status:200,body:p}}),H=e=>t.Effect.gen(function*(){switch(e.type){case`create-upload`:return yield*ee(e);case`get-capabilities`:return yield*z(e);case`get-upload`:return yield*B(e);case`upload-chunk`:return yield*V(e);case`get-flow`:return yield*E(e);case`run-flow`:return yield*D(e);case`job-status`:return yield*O(e);case`resume-flow`:return yield*k(e);case`pause-flow`:return yield*A(e);case`cancel-flow`:return yield*j(e);case`not-found`:return{status:404,headers:{"Content-Type":`application/json`},body:{error:`Not found`}};case`bad-request`:return{status:400,body:{error:`Bad request`,message:e.message}};case`method-not-allowed`:return{status:405,headers:{"Content-Type":`application/json`},body:{error:`Method not allowed`}};case`unsupported-content-type`:return{status:415,headers:{"Content-Type":`application/json`},body:{error:`Unsupported content type`}}}}),U=async({flows:e,dataStore:c,kvStore:l,plugins:u=[],eventEmitter:f,eventBroadcaster:p=a.memoryEventBroadcaster,withTracing:m=!1,baseUrl:h=`uploadista`,generateId:g=i.GenerateIdLive,metricsLayer:v,bufferedDataStore:y,adapter:b,authCacheConfig:C})=>{let T=f??(0,o.webSocketEventEmitter)(p),E=h.endsWith(`/`)?h.slice(0,-1):h,D=t.Layer.effect(n.FlowProvider,t.Effect.succeed({getFlow:(t,n)=>e(t,n)}));if(!T)throw Error(`eventEmitter is required. Provide an event emitter layer in the configuration.`);let O=x({kvStore:l,eventEmitter:T,dataStore:await(0,r.createDataStoreLayer)(c),bufferedDataStore:y,generateId:g}),k=S({kvStore:l,eventEmitter:T,flowProvider:D,uploadServer:O}),A=d(C),j=v??s.NoOpMetricsServiceLive,M=t.Layer.mergeAll(O,k,j,A,...u),N=t.ManagedRuntime.make(M);return{handler:async e=>{let r=t.Effect.gen(function*(){let r=yield*b.extractRequest(e,{baseUrl:E}),i=null;if(b.runAuthMiddleware){let n=yield*b.runAuthMiddleware(e).pipe(t.Effect.timeout(`5 seconds`),t.Effect.catchAll(()=>(console.error(`Auth middleware timeout exceeded (5 seconds)`),t.Effect.succeed({_tag:`TimeoutError`}))),t.Effect.catchAllCause(e=>(console.error(`Auth middleware error:`,e),t.Effect.succeed({_tag:`AuthError`,error:e}))));if(n&&typeof n==`object`&&`_tag`in n&&n._tag===`TimeoutError`)return yield*b.sendResponse({status:503,headers:{"Content-Type":`application/json`},body:{error:`Authentication service unavailable`,message:`Authentication took too long to respond. Please try again.`}},e);if(n&&typeof n==`object`&&`_tag`in n&&n._tag===`AuthError`)return yield*b.sendResponse({status:500,headers:{"Content-Type":`application/json`},body:{error:`Internal Server Error`,message:`An error occurred during authentication`}},e);if(n===null)return yield*b.sendResponse({status:401,headers:{"Content-Type":`application/json`},body:{error:`Unauthorized`,message:`Invalid credentials`}},e);i=n}let a=w(i),o=[];if(b.extractWaitUntil){let r=b.extractWaitUntil(e);r&&o.push(t.Layer.succeed(n.FlowWaitUntil,r))}let s=t.Layer.mergeAll(a,A,j,...u,...o);if(r.type===`not-found`)return yield*b.sendResponse({type:`not-found`,status:404,headers:{"Content-Type":`application/json`},body:{error:`Not found`}},e);let c=yield*H(r).pipe(t.Effect.provide(s));return yield*b.sendResponse(c,e)}).pipe(t.Effect.catchAll(t=>{let n=_(t),r={code:n.code,message:n.message};n.details!==void 0&&(r.details=n.details);let i={status:n.status,headers:{"Content-Type":`application/json`},body:r};return b.sendResponse(i,e)}));return m?N.runPromise(r.pipe(t.Effect.provide(s.NodeSdkLive))):N.runPromise(r)},websocketHandler:await N.runPromise(b.webSocketHandler({baseUrl:E})),baseUrl:E,dispose:()=>N.dispose()}};async function W(e){return U(e)}function G(e){return e}function K(e){return e}const q={ImagePlugin:{packageName:`@uploadista/flow-images-sharp`,variableName:`sharpImagePlugin`},ImageAiPlugin:{packageName:`@uploadista/flow-images-replicate`,variableName:`replicateImagePlugin`},ZipPlugin:{packageName:`@uploadista/flow-utility-zipjs`,variableName:`zipPlugin`},CredentialProvider:{packageName:`@uploadista/core`,variableName:`credentialProviderLayer`}};function J(e){try{let t=e;if(t._tag)return t._tag;if(t.constructor?.name)return t.constructor.name;if(t.context?.services){let e=Array.from(t.context.services.keys());if(e.length>0){let t=e[0];if(t.key)return t.key}}return null}catch{return null}}function Y(e){return e.map(e=>J(e)).filter(e=>e!==null)}function X(e){let{plugins:t,expectedServices:n=[]}=e,r=Y(t),i=n.filter(e=>!r.includes(e));return i.length===0?{success:!0}:{success:!1,required:n,provided:r,missing:i,suggestions:i.map(e=>{let t=q[e];return t?{name:e,packageName:t.packageName,importStatement:`import { ${t.variableName} } from '${t.packageName}';`}:null}).filter(e=>e!==null)}}function Z(e){let t=[`Server initialization failed: Missing required plugins`,``,`Required: ${e.required.join(`, `)}`,`Provided: ${e.provided.length>0?e.provided.join(`, `):`(none)`}`,`Missing: ${e.missing.join(`, `)}`,``];if(e.suggestions.length>0){t.push(`Add the missing plugins to your configuration:`),t.push(``);for(let n of e.suggestions)t.push(` ${n.importStatement}`);t.push(``),t.push(` const server = await createUploadistaServer({`),t.push(` plugins: [${[...e.provided,...e.missing.map(e=>q[e]?.variableName||e)].join(`, `)}],`),t.push(` // ...`),t.push(` });`)}else t.push(`Note: Could not determine package names for missing plugins.`),t.push(`Please ensure all required plugin layers are provided.`);return t.join(`
2
2
  `)}function Q(e){return t.Effect.sync(()=>{let t=X(e);if(!t.success){let e=Z(t);throw Error(e)}})}function te(e){let t=X(e);if(!t.success){let e=Z(t);throw Error(e)}}const ne=(e,n,r)=>t.Effect.gen(function*(){if(!n){yield*t.Effect.sync(()=>{r.send(JSON.stringify({type:`error`,message:`Job ID is required for flow event subscription`,code:`MISSING_JOB_ID`}))});return}yield*e.subscribeToFlowEvents(n,r)}),re=(e,n)=>t.Effect.gen(function*(){n&&(yield*e.unsubscribeFromFlowEvents(n))}),$=(e,n,r)=>t.Effect.gen(function*(){if(!n){yield*t.Effect.sync(()=>{r.send(JSON.stringify({type:`error`,message:`Upload ID is required for upload event subscription`,code:`MISSING_UPLOAD_ID`}))});return}yield*e.subscribeToUploadEvents(n,r)}),ie=(e,n)=>t.Effect.gen(function*(){n&&(yield*e.unsubscribeFromUploadEvents(n))}),ae=(e,n,r)=>{let{connection:i,isFlowRoute:a,isUploadRoute:o,jobId:s,uploadId:c,eventId:u}=e;return t.Effect.gen(function*(){a&&(yield*ne(r,s,i)),o&&(yield*$(n,c,i)),i.send(JSON.stringify({type:`connection`,message:`Uploadista WebSocket connected`,id:u,jobId:s,uploadId:c,timestamp:new Date().toISOString()}))}).pipe(t.Effect.catchAll(e=>t.Effect.sync(()=>{console.error(`Error subscribing to events:`,e);let t=e instanceof l.UploadistaError?e.body:`Failed to subscribe to events`;i.send(JSON.stringify({type:`error`,message:t,code:e instanceof l.UploadistaError?e.code:`SUBSCRIPTION_ERROR`}))})))},oe=(e,n)=>t.Effect.sync(()=>{try{JSON.parse(e).type===`ping`&&n.send(JSON.stringify({type:`pong`,timestamp:new Date().toISOString()}))}catch(e){console.error(`Error handling WebSocket message:`,e),n.send(JSON.stringify({type:`error`,message:`Invalid message format`}))}}),se=(e,n,r)=>{let{isFlowRoute:i,isUploadRoute:a,jobId:o,uploadId:s}=e;return t.Effect.gen(function*(){i&&(yield*re(r,o)),a&&(yield*ie(n,s))}).pipe(t.Effect.catchAll(e=>t.Effect.sync(()=>{console.error(`Error unsubscribing from events:`,e instanceof l.UploadistaError?e.body:e)})))},ce=(e,n)=>t.Effect.sync(()=>{console.error(`WebSocket error for event ${n}:`,e)});exports.AdapterError=M,exports.AuthCacheService=u,exports.AuthCacheServiceLive=d,exports.AuthContextService=C,exports.AuthContextServiceLive=w,exports.BadRequestError=F,exports.NoAuthCacheServiceLive=f,exports.NoAuthContextServiceLive=T,exports.NotFoundError=P,exports.ValidationError=N,exports.createErrorResponseBody=I,exports.createFlowServerLayer=S,exports.createGenericErrorResponseBody=R,exports.createTypeSafeServer=W,exports.createUploadServerLayer=x,exports.createUploadistaErrorResponseBody=L,exports.createUploadistaServer=U,exports.defineFlow=G,exports.defineSimpleFlow=K,exports.extractFlowAndStorageId=b,exports.extractJobAndNodeId=y,exports.extractJobIdFromStatus=v,exports.extractServiceIdentifiers=Y,exports.formatPluginValidationError=Z,exports.getAuthCredentials=e.t,exports.getLastSegment=m,exports.getRouteSegments=g,exports.handleFlowError=_,exports.handleWebSocketClose=se,exports.handleWebSocketError=ce,exports.handleWebSocketMessage=oe,exports.handleWebSocketOpen=ae,exports.hasBasePath=h,exports.parseUrlSegments=p,exports.validatePluginRequirements=X,exports.validatePluginRequirementsEffect=Q,exports.validatePluginsOrThrow=te;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../src/core/routes.ts","../src/types.ts","../src/adapter/types.ts","../src/cache.ts","../src/core/plugin-types.ts","../src/core/types.ts","../src/core/create-type-safe-server.ts","../src/core/plugin-validation.ts","../src/core/server.ts","../src/core/websocket-routes.ts","../src/core/websocket-handlers/websocket-handlers.ts","../src/error-types.ts","../src/http-utils.ts","../src/layer-utils.ts","../src/plugins-typing.ts","../src/service.ts"],"sourcesContent":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iGX,CAAA;;;;;;AAMA,cezFS,wBfyFT,EezFmC,KAAA,CAAM,KfyFzC,CezF+C,kBfyF/C,CAAA"}
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../src/core/routes.ts","../src/types.ts","../src/adapter/types.ts","../src/cache.ts","../src/core/plugin-types.ts","../src/core/types.ts","../src/core/create-type-safe-server.ts","../src/core/plugin-validation.ts","../src/core/server.ts","../src/core/websocket-routes.ts","../src/core/websocket-handlers/websocket-handlers.ts","../src/error-types.ts","../src/http-utils.ts","../src/layer-utils.ts","../src/plugins-typing.ts","../src/service.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;KAQY,mBAAA;KAgBA,0BAA0B;QAC9B;;KAGI,qCACA,kEAGR,gBAAgB;UACV;;;;QAEF;;KAGI,eAAA,GAAkB;AA9BlB,KAgCA,gBAAA,GAAmB,0BAhCA,CAAA,WAAA,EAAA;EAgBnB,KAAA,EAAA,WAAe;AAI3B,CAAA,EAAA,GAAY,CAAA;AACA,KAiBA,uBAAA,GAA0B,eAjB1B,CAAA,oBAAA,CAAA;AAGQ,KAgBR,wBAAA,GAA2B,0BAhBnB,CAAA,oBAAA,EAAA;EAAhB,KAAA,EAAA,oBAAA;CACM,EAAA,GAAA,CAAA;AAEF,KAmBI,iBAAA,GAAoB,eAnBxB,CAAA,aAAA,CAAA,GAAA;EAAY,OAAA,EAAA,MAAA;AAGpB,CAAA;AAEY,KAkBA,kBAAA,GAAqB,0BAlBF,CAAA,aAA0B,EAAA;EAM7C,KAAA,EAAA,aAAA;EAEA,OAAA,EAAA,MAAA;AAMZ,CAAA,EAAA,GAAY,CAAA;AAIA,KAMA,6BAAA,GACV,eAP+B,CAAA,0BAA0B,CAAA;AAM/C,KAGA,8BAAA,GAAiC,0BAF5B,CAAA,0BAAA,EAAA;EAEL,KAAA,EAAA,0BAA8B;AAK1C,CAAA,EAAA,GAAY,CAAA;AAGA,KAHA,mBAAA,GAAsB,eAKhC,CAAA,eAFiC,CAAA,GAA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AA,CAAO,MfdtB,Cec6B,Wfd7B,GAAA,IAAA,CAAA;AAGpB,CAAA,CAAA;AAEA;AAMA;AAEA;AAMA;AAIA;AAMA;AAGA;AAKA;AAGA;AAIA;AAGA;AASA;AAIA;AAKA;AAKA;AAKA;AAGA;AAEA;AAKA;AAEA;AAGA;AAKY,ce1GC,kBAAA,SAA2B,uBAAA,Cf0GO;AAU/C;AAGA;AAKA;AAGA;AAKA;;;AAGI,cenGS,sBfmGT,EAAA,CAAA,WAAA,EelGW,WfkGX,GAAA,IAAA,EAAA,GejGD,KAAA,CAAM,KfiGL,CejGW,kBfiGX,CAAA;;;;;;AAMA,cezFS,wBfyFT,EezFmC,KAAA,CAAM,KfyFzC,CezF+C,kBfyF/C,CAAA"}
package/dist/index.mjs CHANGED
@@ -1,3 +1,3 @@
1
- import{t as e}from"./auth-D2lKhlzK.mjs";import{Context as t,Effect as n,Layer as r,ManagedRuntime as i}from"effect";import{FlowProvider as a,FlowServer as o,FlowWaitUntil as s,flowServer as c}from"@uploadista/core/flow";import{createDataStoreLayer as l,flowEventEmitter as u,flowJobKvStore as d,inputFileSchema as f,uploadEventEmitter as p,uploadFileKvStore as m}from"@uploadista/core/types";import{GenerateIdLive as ee,isSupportedAlgorithm as h}from"@uploadista/core/utils";import{memoryEventBroadcaster as te}from"@uploadista/event-broadcaster-memory";import{webSocketEventEmitter as ne}from"@uploadista/event-emitter-websocket";import{MetricsService as g,NoOpMetricsServiceLive as re,NodeSdkLive as _}from"@uploadista/observability";import{UploadServer as v,uploadServer as y}from"@uploadista/core/upload";import{UploadistaError as b}from"@uploadista/core/errors";var x=class extends t.Tag(`AuthCacheService`)(){};const S=(e={})=>{let t=e.maxSize??1e4,i=e.ttl??36e5,a=new Map,o=()=>{let e=Date.now();for(let[t,n]of a.entries())e-n.timestamp>i&&a.delete(t)},s=()=>{if(a.size<=t)return;let e=null,n=1/0;for(let[t,r]of a.entries())r.timestamp<n&&(n=r.timestamp,e=t);e&&a.delete(e)};return r.succeed(x,{set:(e,t)=>n.sync(()=>{a.size%100==0&&o(),a.set(e,{authContext:t,timestamp:Date.now()}),s()}),get:e=>n.sync(()=>{let t=a.get(e);return t?Date.now()-t.timestamp>i?(a.delete(e),null):t.authContext:null}),delete:e=>n.sync(()=>{a.delete(e)}),clear:()=>n.sync(()=>{a.clear()}),size:()=>n.sync(()=>a.size)})},C=r.succeed(x,{set:()=>n.void,get:()=>n.succeed(null),delete:()=>n.void,clear:()=>n.void,size:()=>n.succeed(0)}),w=e=>e.split(`/`).filter(Boolean),T=e=>{let t=w(e);return t[t.length-1]},E=(e,t)=>e.includes(`${t}/api/`),D=(e,t)=>e.replace(`${t}/api/`,``).split(`/`).filter(Boolean),O=e=>{let t=500,n=`UNKNOWN_ERROR`,r=`Internal server error`,i;if(typeof e==`object`&&e){let a=e;if(`code`in a&&typeof a.code==`string`&&(n=a.code),`message`in a&&typeof a.message==`string`?r=a.message:`body`in a&&typeof a.body==`string`&&(r=a.body),`details`in a&&(i=a.details),`status`in a&&typeof a.status==`number`)t=a.status;else if(`code`in a)switch(a.code){case`FILE_NOT_FOUND`:case`FLOW_JOB_NOT_FOUND`:case`UPLOAD_ID_NOT_FOUND`:t=404;break;case`FLOW_JOB_ERROR`:case`VALIDATION_ERROR`:case`INVALID_METADATA`:case`INVALID_LENGTH`:case`ABORTED`:case`INVALID_TERMINATION`:t=400;break;case`INVALID_OFFSET`:t=409;break;case`ERR_SIZE_EXCEEDED`:case`ERR_MAX_SIZE_EXCEEDED`:t=413;break;case`FILE_NO_LONGER_EXISTS`:t=410;break;case`MISSING_OFFSET`:case`INVALID_CONTENT_TYPE`:t=403;break;default:t=500}`message`in a&&a.message===`Invalid JSON body`&&(t=400,n=`VALIDATION_ERROR`)}let a={status:t,code:n,message:r};return i!==void 0&&(a.details=i),a},k=e=>e[e.length-2],A=e=>({jobId:e[e.length-3],nodeId:e[e.length-1]}),j=e=>({storageId:e.pop(),flowId:e.pop()}),M=({kvStore:e,eventEmitter:t,dataStore:n,bufferedDataStore:i,generateId:a})=>{let o=r.provide(m,e),s=r.provide(n,o),c=i?r.provide(i,o):r.empty,l=r.provide(p,t),u=r.mergeAll(s,o,l,...a?[a]:[],c);return r.provide(y,u)},N=({kvStore:e,eventEmitter:t,flowProvider:n,uploadServer:i})=>{let a=r.provide(d,e),o=r.provide(u,t),s=r.mergeAll(n,o,a,i);return r.provide(c,s)};var P=class extends t.Tag(`AuthContextService`)(){};const F=e=>r.succeed(P,{getClientId:()=>n.succeed(e?.clientId??null),getMetadata:()=>n.succeed(e?.metadata??{}),hasPermission:t=>n.succeed(e?.permissions?.includes(t)??!1),getAuthContext:()=>n.succeed(e)}),ie=F(null),ae=({flowId:e})=>n.gen(function*(){let t=yield*o,r=yield*(yield*P).getClientId();return r&&(yield*n.logInfo(`[Flow] Getting flow data: ${e}, client: ${r}`)),{status:200,body:yield*t.getFlowData(e,r)}}),oe=({flowId:e,storageId:t,inputs:r})=>n.gen(function*(){let i=yield*o,a=yield*P,s=yield*x,c=yield*a.getClientId();c?(yield*n.logInfo(`[Flow] Executing flow: ${e}, storage: ${t}, client: ${c}`),yield*n.logInfo(JSON.stringify(r,null,2))):(yield*n.logInfo(`[Flow] Executing flow: ${e}, storage: ${t}`),yield*n.logInfo(`[Flow] Inputs: ${JSON.stringify(r,null,2)}`)),yield*n.logInfo(`[Flow] Calling flowServer.runFlow...`);let l=yield*i.runFlow({flowId:e,storageId:t,clientId:c,inputs:r}).pipe(n.tap(()=>n.logInfo(`[Flow] runFlow completed successfully`)),n.tapError(e=>n.logError(`[Flow] runFlow failed with error: ${e}`))),u=yield*a.getAuthContext();return u&&(yield*s.set(l.id,u)),yield*n.logInfo(`[Flow] Flow started with jobId: ${l.id}`),{status:200,body:l}}),I=({jobId:e})=>n.gen(function*(){let t=yield*o,r=yield*P,i=yield*x,a=yield*r.getClientId();if(!e)throw Error(`No job id`);a&&(yield*n.logInfo(`[Flow] Getting job status: ${e}, client: ${a}`));let s=yield*t.getJobStatus(e);return(s.status===`completed`||s.status===`failed`)&&(yield*i.delete(e),a&&(yield*n.logInfo(`[Flow] Flow ${s.status}, cleared auth cache: ${e}`))),{status:200,body:s}}),L=({jobId:e,nodeId:t,newData:r})=>n.gen(function*(){let i=yield*o,a=yield*P,s=yield*x,c=yield*a.getClientId();if(c||=(yield*s.get(e))?.clientId??null,c&&(yield*n.logInfo(`[Flow] Continuing flow: jobId=${e}, nodeId=${t}, client: ${c}`)),r===void 0)throw Error(`Missing newData`);let l=yield*i.resumeFlow({jobId:e,nodeId:t,newData:r,clientId:c});return(l.status===`completed`||l.status===`failed`)&&(yield*s.delete(e),c&&(yield*n.logInfo(`[Flow] Flow ${l.status}, cleared auth cache: ${e}`))),{status:200,body:l}}),R=({jobId:e})=>n.gen(function*(){let t=yield*o,r=yield*P,i=yield*x,a=yield*r.getClientId();a||=(yield*i.get(e))?.clientId??null,a&&(yield*n.logInfo(`[Flow] Pausing flow: jobId=${e}, client: ${a}`));let s=yield*t.pauseFlow(e,a);return a&&(yield*n.logInfo(`[Flow] Flow paused: ${e}, status: ${s.status}`)),{status:200,body:s}}),z=({jobId:e})=>n.gen(function*(){let t=yield*o,r=yield*P,i=yield*x;if(!e)throw Error(`No job id`);let a=yield*r.getClientId();a||=(yield*i.get(e))?.clientId??null,a&&(yield*n.logInfo(`[Flow] Cancelling flow: jobId=${e}, client: ${a}`));let s=yield*t.cancelFlow(e,a);return yield*i.delete(e),a&&(yield*n.logInfo(`[Flow] Flow cancelled, cleared auth cache: ${e}`)),{status:200,body:s}});var B=class extends Error{constructor(e,t=500,n=`INTERNAL_ERROR`){super(e),this.statusCode=t,this.errorCode=n,this.name=`AdapterError`}},V=class extends B{constructor(e){super(e,400,`VALIDATION_ERROR`),this.name=`ValidationError`}},H=class extends B{constructor(e){super(`${e} not found`,404,`NOT_FOUND`),this.name=`NotFoundError`}},U=class extends B{constructor(e){super(e,400,`BAD_REQUEST`),this.name=`BadRequestError`}};const W=e=>({error:e.message,code:e.errorCode,timestamp:new Date().toISOString()}),G=e=>{let t={error:e.body,code:e.code,timestamp:new Date().toISOString()};return e.details!==void 0&&(t.details=e.details),t},K=(e=`Internal server error`)=>({error:e,code:`INTERNAL_ERROR`,timestamp:new Date().toISOString()}),q=e=>n.gen(function*(){let t=yield*v,r=yield*P,i=yield*x,a=yield*r.getClientId();a&&(yield*n.logInfo(`[Upload] Creating upload for client: ${a}`));let o=yield*n.sync(()=>f.safeParse(e.data));if(!o.success)return yield*n.fail(new V(`Invalid input file schema`));if(o.data.checksumAlgorithm&&!h(o.data.checksumAlgorithm))return yield*n.fail(new V(`Unsupported checksum algorithm: ${o.data.checksumAlgorithm}. Supported algorithms: sha256`));let s=yield*t.createUpload(o.data,a),c=yield*r.getAuthContext();return c&&(yield*i.set(s.id,c)),a&&(yield*n.logInfo(`[Upload] Upload created: ${s.id} for client: ${a}`)),{status:200,body:s}}),se=({storageId:e})=>n.gen(function*(){let t=yield*v,n=yield*(yield*P).getClientId();return{status:200,body:{storageId:e,capabilities:yield*t.getCapabilities(e,n),timestamp:new Date().toISOString()}}}),ce=({uploadId:e})=>n.gen(function*(){return{status:200,body:yield*(yield*v).getUpload(e)}}),le=e=>n.gen(function*(){let t=yield*v,r=yield*P,i=yield*x,a=yield*g,{uploadId:o,data:s}=e,c=yield*r.getClientId(),l=yield*r.getMetadata();if(!c){let e=yield*i.get(o);c=e?.clientId??null,l=e?.metadata??{}}c&&(yield*n.logInfo(`[Upload] Uploading chunk for upload: ${o}, client: ${c}`));let u=yield*t.uploadChunk(o,c,s);return u.size&&u.offset>=u.size&&(yield*i.delete(o),c&&(yield*n.logInfo(`[Upload] Upload completed, cleared auth cache: ${o}`)),c&&u.size?(yield*n.logInfo(`[Upload] Recording metrics for org: ${c}, size: ${u.size}`),yield*n.forkDaemon(a.recordUpload(c,u.size,l))):yield*n.logWarning(`[Upload] Cannot record metrics - missing organizationId or size`)),c&&(yield*n.logInfo(`[Upload] Chunk uploaded for upload: ${o}, client: ${c}`)),{status:200,body:u}}),ue=e=>n.gen(function*(){switch(e.type){case`create-upload`:return yield*q(e);case`get-capabilities`:return yield*se(e);case`get-upload`:return yield*ce(e);case`upload-chunk`:return yield*le(e);case`get-flow`:return yield*ae(e);case`run-flow`:return yield*oe(e);case`job-status`:return yield*I(e);case`resume-flow`:return yield*L(e);case`pause-flow`:return yield*R(e);case`cancel-flow`:return yield*z(e);case`not-found`:return{status:404,headers:{"Content-Type":`application/json`},body:{error:`Not found`}};case`bad-request`:return{status:400,body:{error:`Bad request`,message:e.message}};case`method-not-allowed`:return{status:405,headers:{"Content-Type":`application/json`},body:{error:`Method not allowed`}};case`unsupported-content-type`:return{status:415,headers:{"Content-Type":`application/json`},body:{error:`Unsupported content type`}}}}),J=async({flows:e,dataStore:t,kvStore:o,plugins:c=[],eventEmitter:u,eventBroadcaster:d=te,withTracing:f=!1,baseUrl:p=`uploadista`,generateId:m=ee,metricsLayer:h,bufferedDataStore:g,adapter:v,authCacheConfig:y})=>{let b=u??ne(d),x=p.endsWith(`/`)?p.slice(0,-1):p,C=r.effect(a,n.succeed({getFlow:(t,n)=>e(t,n)}));if(!b)throw Error(`eventEmitter is required. Provide an event emitter layer in the configuration.`);let w=M({kvStore:o,eventEmitter:b,dataStore:await l(t),bufferedDataStore:g,generateId:m}),T=N({kvStore:o,eventEmitter:b,flowProvider:C,uploadServer:w}),E=S(y),D=h??re,k=r.mergeAll(w,T,D,E,...c),A=i.make(k);return{handler:async e=>{let t=n.gen(function*(){let t=yield*v.extractRequest(e,{baseUrl:x}),i=null;if(v.runAuthMiddleware){let t=yield*v.runAuthMiddleware(e).pipe(n.timeout(`5 seconds`),n.catchAll(()=>(console.error(`Auth middleware timeout exceeded (5 seconds)`),n.succeed({_tag:`TimeoutError`}))),n.catchAllCause(e=>(console.error(`Auth middleware error:`,e),n.succeed({_tag:`AuthError`,error:e}))));if(t&&typeof t==`object`&&`_tag`in t&&t._tag===`TimeoutError`)return yield*v.sendResponse({status:503,headers:{"Content-Type":`application/json`},body:{error:`Authentication service unavailable`,message:`Authentication took too long to respond. Please try again.`}},e);if(t&&typeof t==`object`&&`_tag`in t&&t._tag===`AuthError`)return yield*v.sendResponse({status:500,headers:{"Content-Type":`application/json`},body:{error:`Internal Server Error`,message:`An error occurred during authentication`}},e);if(t===null)return yield*v.sendResponse({status:401,headers:{"Content-Type":`application/json`},body:{error:`Unauthorized`,message:`Invalid credentials`}},e);i=t}let a=F(i),o=[];if(v.extractWaitUntil){let t=v.extractWaitUntil(e);t&&o.push(r.succeed(s,t))}let l=r.mergeAll(a,E,D,...c,...o);if(t.type===`not-found`)return yield*v.sendResponse({type:`not-found`,status:404,headers:{"Content-Type":`application/json`},body:{error:`Not found`}},e);let u=yield*ue(t).pipe(n.provide(l));return yield*v.sendResponse(u,e)}).pipe(n.catchAll(t=>{let n=O(t),r={code:n.code,message:n.message};n.details!==void 0&&(r.details=n.details);let i={status:n.status,headers:{"Content-Type":`application/json`},body:r};return v.sendResponse(i,e)}));return f?A.runPromise(t.pipe(n.provide(_))):A.runPromise(t)},websocketHandler:await A.runPromise(v.webSocketHandler({baseUrl:x})),baseUrl:x,dispose:()=>A.dispose()}};async function de(e){return J(e)}function fe(e){return e}function pe(e){return e}const Y={ImagePlugin:{packageName:`@uploadista/flow-images-sharp`,variableName:`sharpImagePlugin`},ImageAiPlugin:{packageName:`@uploadista/flow-images-replicate`,variableName:`replicateImagePlugin`},ZipPlugin:{packageName:`@uploadista/flow-utility-zipjs`,variableName:`zipPlugin`},CredentialProvider:{packageName:`@uploadista/core`,variableName:`credentialProviderLayer`}};function me(e){try{let t=e;if(t._tag)return t._tag;if(t.constructor?.name)return t.constructor.name;if(t.context?.services){let e=Array.from(t.context.services.keys());if(e.length>0){let t=e[0];if(t.key)return t.key}}return null}catch{return null}}function X(e){return e.map(e=>me(e)).filter(e=>e!==null)}function Z(e){let{plugins:t,expectedServices:n=[]}=e,r=X(t),i=n.filter(e=>!r.includes(e));return i.length===0?{success:!0}:{success:!1,required:n,provided:r,missing:i,suggestions:i.map(e=>{let t=Y[e];return t?{name:e,packageName:t.packageName,importStatement:`import { ${t.variableName} } from '${t.packageName}';`}:null}).filter(e=>e!==null)}}function Q(e){let t=[`Server initialization failed: Missing required plugins`,``,`Required: ${e.required.join(`, `)}`,`Provided: ${e.provided.length>0?e.provided.join(`, `):`(none)`}`,`Missing: ${e.missing.join(`, `)}`,``];if(e.suggestions.length>0){t.push(`Add the missing plugins to your configuration:`),t.push(``);for(let n of e.suggestions)t.push(` ${n.importStatement}`);t.push(``),t.push(` const server = await createUploadistaServer({`),t.push(` plugins: [${[...e.provided,...e.missing.map(e=>Y[e]?.variableName||e)].join(`, `)}],`),t.push(` // ...`),t.push(` });`)}else t.push(`Note: Could not determine package names for missing plugins.`),t.push(`Please ensure all required plugin layers are provided.`);return t.join(`
1
+ import{t as e}from"./auth-DG0enyjj.mjs";import{Context as t,Effect as n,Layer as r,ManagedRuntime as i}from"effect";import{FlowProvider as a,FlowServer as o,FlowWaitUntil as s,flowServer as c}from"@uploadista/core/flow";import{createDataStoreLayer as l,flowEventEmitter as u,flowJobKvStore as d,inputFileSchema as f,uploadEventEmitter as p,uploadFileKvStore as m}from"@uploadista/core/types";import{GenerateIdLive as ee,isSupportedAlgorithm as h}from"@uploadista/core/utils";import{memoryEventBroadcaster as te}from"@uploadista/event-broadcaster-memory";import{webSocketEventEmitter as ne}from"@uploadista/event-emitter-websocket";import{MetricsService as g,NoOpMetricsServiceLive as re,NodeSdkLive as _}from"@uploadista/observability";import{UploadServer as v,uploadServer as y}from"@uploadista/core/upload";import{UploadistaError as b}from"@uploadista/core/errors";var x=class extends t.Tag(`AuthCacheService`)(){};const S=(e={})=>{let t=e.maxSize??1e4,i=e.ttl??36e5,a=new Map,o=()=>{let e=Date.now();for(let[t,n]of a.entries())e-n.timestamp>i&&a.delete(t)},s=()=>{if(a.size<=t)return;let e=null,n=1/0;for(let[t,r]of a.entries())r.timestamp<n&&(n=r.timestamp,e=t);e&&a.delete(e)};return r.succeed(x,{set:(e,t)=>n.sync(()=>{a.size%100==0&&o(),a.set(e,{authContext:t,timestamp:Date.now()}),s()}),get:e=>n.sync(()=>{let t=a.get(e);return t?Date.now()-t.timestamp>i?(a.delete(e),null):t.authContext:null}),delete:e=>n.sync(()=>{a.delete(e)}),clear:()=>n.sync(()=>{a.clear()}),size:()=>n.sync(()=>a.size)})},C=r.succeed(x,{set:()=>n.void,get:()=>n.succeed(null),delete:()=>n.void,clear:()=>n.void,size:()=>n.succeed(0)}),w=e=>e.split(`/`).filter(Boolean),T=e=>{let t=w(e);return t[t.length-1]},E=(e,t)=>e.includes(`${t}/api/`),D=(e,t)=>e.replace(`${t}/api/`,``).split(`/`).filter(Boolean),O=e=>{let t=500,n=`UNKNOWN_ERROR`,r=`Internal server error`,i;if(typeof e==`object`&&e){let a=e;if(`code`in a&&typeof a.code==`string`&&(n=a.code),`message`in a&&typeof a.message==`string`?r=a.message:`body`in a&&typeof a.body==`string`&&(r=a.body),`details`in a&&(i=a.details),`status`in a&&typeof a.status==`number`)t=a.status;else if(`code`in a)switch(a.code){case`FILE_NOT_FOUND`:case`FLOW_JOB_NOT_FOUND`:case`UPLOAD_ID_NOT_FOUND`:t=404;break;case`FLOW_JOB_ERROR`:case`VALIDATION_ERROR`:case`INVALID_METADATA`:case`INVALID_LENGTH`:case`ABORTED`:case`INVALID_TERMINATION`:t=400;break;case`INVALID_OFFSET`:t=409;break;case`ERR_SIZE_EXCEEDED`:case`ERR_MAX_SIZE_EXCEEDED`:t=413;break;case`FILE_NO_LONGER_EXISTS`:t=410;break;case`MISSING_OFFSET`:case`INVALID_CONTENT_TYPE`:t=403;break;default:t=500}`message`in a&&a.message===`Invalid JSON body`&&(t=400,n=`VALIDATION_ERROR`)}let a={status:t,code:n,message:r};return i!==void 0&&(a.details=i),a},k=e=>e[e.length-2],A=e=>({jobId:e[e.length-3],nodeId:e[e.length-1]}),j=e=>({storageId:e.pop(),flowId:e.pop()}),M=({kvStore:e,eventEmitter:t,dataStore:n,bufferedDataStore:i,generateId:a})=>{let o=r.provide(m,e),s=r.provide(n,o),c=i?r.provide(i,o):r.empty,l=r.provide(p,t),u=r.mergeAll(s,o,l,...a?[a]:[],c);return r.provide(y,u)},N=({kvStore:e,eventEmitter:t,flowProvider:n,uploadServer:i})=>{let a=r.provide(d,e),o=r.provide(u,t),s=r.mergeAll(n,o,a,i);return r.provide(c,s)};var P=class extends t.Tag(`AuthContextService`)(){};const F=e=>r.succeed(P,{getClientId:()=>n.succeed(e?.clientId??null),getMetadata:()=>n.succeed(e?.metadata??{}),hasPermission:t=>n.succeed(e?.permissions?.includes(t)??!1),getAuthContext:()=>n.succeed(e)}),ie=F(null),ae=({flowId:e})=>n.gen(function*(){let t=yield*o,r=yield*(yield*P).getClientId();return r&&(yield*n.logInfo(`[Flow] Getting flow data: ${e}, client: ${r}`)),{status:200,body:yield*t.getFlowData(e,r)}}),oe=({flowId:e,storageId:t,inputs:r})=>n.gen(function*(){let i=yield*o,a=yield*P,s=yield*x,c=yield*a.getClientId();c?(yield*n.logInfo(`[Flow] Executing flow: ${e}, storage: ${t}, client: ${c}`),yield*n.logInfo(JSON.stringify(r,null,2))):(yield*n.logInfo(`[Flow] Executing flow: ${e}, storage: ${t}`),yield*n.logInfo(`[Flow] Inputs: ${JSON.stringify(r,null,2)}`)),yield*n.logInfo(`[Flow] Calling flowServer.runFlow...`);let l=yield*i.runFlow({flowId:e,storageId:t,clientId:c,inputs:r}).pipe(n.tap(()=>n.logInfo(`[Flow] runFlow completed successfully`)),n.tapError(e=>n.logError(`[Flow] runFlow failed with error: ${e}`))),u=yield*a.getAuthContext();return u&&(yield*s.set(l.id,u)),yield*n.logInfo(`[Flow] Flow started with jobId: ${l.id}`),{status:200,body:l}}),I=({jobId:e})=>n.gen(function*(){let t=yield*o,r=yield*P,i=yield*x,a=yield*r.getClientId();if(!e)throw Error(`No job id`);a&&(yield*n.logInfo(`[Flow] Getting job status: ${e}, client: ${a}`));let s=yield*t.getJobStatus(e);return(s.status===`completed`||s.status===`failed`)&&(yield*i.delete(e),a&&(yield*n.logInfo(`[Flow] Flow ${s.status}, cleared auth cache: ${e}`))),{status:200,body:s}}),L=({jobId:e,nodeId:t,newData:r})=>n.gen(function*(){let i=yield*o,a=yield*P,s=yield*x,c=yield*a.getClientId();if(c||=(yield*s.get(e))?.clientId??null,c&&(yield*n.logInfo(`[Flow] Continuing flow: jobId=${e}, nodeId=${t}, client: ${c}`)),r===void 0)throw Error(`Missing newData`);let l=yield*i.resumeFlow({jobId:e,nodeId:t,newData:r,clientId:c});return(l.status===`completed`||l.status===`failed`)&&(yield*s.delete(e),c&&(yield*n.logInfo(`[Flow] Flow ${l.status}, cleared auth cache: ${e}`))),{status:200,body:l}}),R=({jobId:e})=>n.gen(function*(){let t=yield*o,r=yield*P,i=yield*x,a=yield*r.getClientId();a||=(yield*i.get(e))?.clientId??null,a&&(yield*n.logInfo(`[Flow] Pausing flow: jobId=${e}, client: ${a}`));let s=yield*t.pauseFlow(e,a);return a&&(yield*n.logInfo(`[Flow] Flow paused: ${e}, status: ${s.status}`)),{status:200,body:s}}),z=({jobId:e})=>n.gen(function*(){let t=yield*o,r=yield*P,i=yield*x;if(!e)throw Error(`No job id`);let a=yield*r.getClientId();a||=(yield*i.get(e))?.clientId??null,a&&(yield*n.logInfo(`[Flow] Cancelling flow: jobId=${e}, client: ${a}`));let s=yield*t.cancelFlow(e,a);return yield*i.delete(e),a&&(yield*n.logInfo(`[Flow] Flow cancelled, cleared auth cache: ${e}`)),{status:200,body:s}});var B=class extends Error{constructor(e,t=500,n=`INTERNAL_ERROR`){super(e),this.statusCode=t,this.errorCode=n,this.name=`AdapterError`}},V=class extends B{constructor(e){super(e,400,`VALIDATION_ERROR`),this.name=`ValidationError`}},H=class extends B{constructor(e){super(`${e} not found`,404,`NOT_FOUND`),this.name=`NotFoundError`}},U=class extends B{constructor(e){super(e,400,`BAD_REQUEST`),this.name=`BadRequestError`}};const W=e=>({error:e.message,code:e.errorCode,timestamp:new Date().toISOString()}),G=e=>{let t={error:e.body,code:e.code,timestamp:new Date().toISOString()};return e.details!==void 0&&(t.details=e.details),t},K=(e=`Internal server error`)=>({error:e,code:`INTERNAL_ERROR`,timestamp:new Date().toISOString()}),q=e=>n.gen(function*(){let t=yield*v,r=yield*P,i=yield*x,a=yield*r.getClientId();a&&(yield*n.logInfo(`[Upload] Creating upload for client: ${a}`));let o=yield*n.sync(()=>f.safeParse(e.data));if(!o.success)return yield*n.fail(new V(`Invalid input file schema`));if(o.data.checksumAlgorithm&&!h(o.data.checksumAlgorithm))return yield*n.fail(new V(`Unsupported checksum algorithm: ${o.data.checksumAlgorithm}. Supported algorithms: sha256`));let s=yield*t.createUpload(o.data,a),c=yield*r.getAuthContext();return c&&(yield*i.set(s.id,c)),a&&(yield*n.logInfo(`[Upload] Upload created: ${s.id} for client: ${a}`)),{status:200,body:s}}),se=({storageId:e})=>n.gen(function*(){let t=yield*v,n=yield*(yield*P).getClientId();return{status:200,body:{storageId:e,capabilities:yield*t.getCapabilities(e,n),timestamp:new Date().toISOString()}}}),ce=({uploadId:e})=>n.gen(function*(){return{status:200,body:yield*(yield*v).getUpload(e)}}),le=e=>n.gen(function*(){let t=yield*v,r=yield*P,i=yield*x,a=yield*g,{uploadId:o,data:s}=e,c=yield*r.getClientId(),l=yield*r.getMetadata();if(!c){let e=yield*i.get(o);c=e?.clientId??null,l=e?.metadata??{}}c&&(yield*n.logInfo(`[Upload] Uploading chunk for upload: ${o}, client: ${c}`));let u=yield*t.uploadChunk(o,c,s);return u.size&&u.offset>=u.size&&(yield*i.delete(o),c&&(yield*n.logInfo(`[Upload] Upload completed, cleared auth cache: ${o}`)),c&&u.size?(yield*n.logInfo(`[Upload] Recording metrics for org: ${c}, size: ${u.size}`),yield*n.forkDaemon(a.recordUpload(c,u.size,l))):yield*n.logWarning(`[Upload] Cannot record metrics - missing organizationId or size`)),c&&(yield*n.logInfo(`[Upload] Chunk uploaded for upload: ${o}, client: ${c}`)),{status:200,body:u}}),ue=e=>n.gen(function*(){switch(e.type){case`create-upload`:return yield*q(e);case`get-capabilities`:return yield*se(e);case`get-upload`:return yield*ce(e);case`upload-chunk`:return yield*le(e);case`get-flow`:return yield*ae(e);case`run-flow`:return yield*oe(e);case`job-status`:return yield*I(e);case`resume-flow`:return yield*L(e);case`pause-flow`:return yield*R(e);case`cancel-flow`:return yield*z(e);case`not-found`:return{status:404,headers:{"Content-Type":`application/json`},body:{error:`Not found`}};case`bad-request`:return{status:400,body:{error:`Bad request`,message:e.message}};case`method-not-allowed`:return{status:405,headers:{"Content-Type":`application/json`},body:{error:`Method not allowed`}};case`unsupported-content-type`:return{status:415,headers:{"Content-Type":`application/json`},body:{error:`Unsupported content type`}}}}),J=async({flows:e,dataStore:t,kvStore:o,plugins:c=[],eventEmitter:u,eventBroadcaster:d=te,withTracing:f=!1,baseUrl:p=`uploadista`,generateId:m=ee,metricsLayer:h,bufferedDataStore:g,adapter:v,authCacheConfig:y})=>{let b=u??ne(d),x=p.endsWith(`/`)?p.slice(0,-1):p,C=r.effect(a,n.succeed({getFlow:(t,n)=>e(t,n)}));if(!b)throw Error(`eventEmitter is required. Provide an event emitter layer in the configuration.`);let w=M({kvStore:o,eventEmitter:b,dataStore:await l(t),bufferedDataStore:g,generateId:m}),T=N({kvStore:o,eventEmitter:b,flowProvider:C,uploadServer:w}),E=S(y),D=h??re,k=r.mergeAll(w,T,D,E,...c),A=i.make(k);return{handler:async e=>{let t=n.gen(function*(){let t=yield*v.extractRequest(e,{baseUrl:x}),i=null;if(v.runAuthMiddleware){let t=yield*v.runAuthMiddleware(e).pipe(n.timeout(`5 seconds`),n.catchAll(()=>(console.error(`Auth middleware timeout exceeded (5 seconds)`),n.succeed({_tag:`TimeoutError`}))),n.catchAllCause(e=>(console.error(`Auth middleware error:`,e),n.succeed({_tag:`AuthError`,error:e}))));if(t&&typeof t==`object`&&`_tag`in t&&t._tag===`TimeoutError`)return yield*v.sendResponse({status:503,headers:{"Content-Type":`application/json`},body:{error:`Authentication service unavailable`,message:`Authentication took too long to respond. Please try again.`}},e);if(t&&typeof t==`object`&&`_tag`in t&&t._tag===`AuthError`)return yield*v.sendResponse({status:500,headers:{"Content-Type":`application/json`},body:{error:`Internal Server Error`,message:`An error occurred during authentication`}},e);if(t===null)return yield*v.sendResponse({status:401,headers:{"Content-Type":`application/json`},body:{error:`Unauthorized`,message:`Invalid credentials`}},e);i=t}let a=F(i),o=[];if(v.extractWaitUntil){let t=v.extractWaitUntil(e);t&&o.push(r.succeed(s,t))}let l=r.mergeAll(a,E,D,...c,...o);if(t.type===`not-found`)return yield*v.sendResponse({type:`not-found`,status:404,headers:{"Content-Type":`application/json`},body:{error:`Not found`}},e);let u=yield*ue(t).pipe(n.provide(l));return yield*v.sendResponse(u,e)}).pipe(n.catchAll(t=>{let n=O(t),r={code:n.code,message:n.message};n.details!==void 0&&(r.details=n.details);let i={status:n.status,headers:{"Content-Type":`application/json`},body:r};return v.sendResponse(i,e)}));return f?A.runPromise(t.pipe(n.provide(_))):A.runPromise(t)},websocketHandler:await A.runPromise(v.webSocketHandler({baseUrl:x})),baseUrl:x,dispose:()=>A.dispose()}};async function de(e){return J(e)}function fe(e){return e}function pe(e){return e}const Y={ImagePlugin:{packageName:`@uploadista/flow-images-sharp`,variableName:`sharpImagePlugin`},ImageAiPlugin:{packageName:`@uploadista/flow-images-replicate`,variableName:`replicateImagePlugin`},ZipPlugin:{packageName:`@uploadista/flow-utility-zipjs`,variableName:`zipPlugin`},CredentialProvider:{packageName:`@uploadista/core`,variableName:`credentialProviderLayer`}};function me(e){try{let t=e;if(t._tag)return t._tag;if(t.constructor?.name)return t.constructor.name;if(t.context?.services){let e=Array.from(t.context.services.keys());if(e.length>0){let t=e[0];if(t.key)return t.key}}return null}catch{return null}}function X(e){return e.map(e=>me(e)).filter(e=>e!==null)}function Z(e){let{plugins:t,expectedServices:n=[]}=e,r=X(t),i=n.filter(e=>!r.includes(e));return i.length===0?{success:!0}:{success:!1,required:n,provided:r,missing:i,suggestions:i.map(e=>{let t=Y[e];return t?{name:e,packageName:t.packageName,importStatement:`import { ${t.variableName} } from '${t.packageName}';`}:null}).filter(e=>e!==null)}}function Q(e){let t=[`Server initialization failed: Missing required plugins`,``,`Required: ${e.required.join(`, `)}`,`Provided: ${e.provided.length>0?e.provided.join(`, `):`(none)`}`,`Missing: ${e.missing.join(`, `)}`,``];if(e.suggestions.length>0){t.push(`Add the missing plugins to your configuration:`),t.push(``);for(let n of e.suggestions)t.push(` ${n.importStatement}`);t.push(``),t.push(` const server = await createUploadistaServer({`),t.push(` plugins: [${[...e.provided,...e.missing.map(e=>Y[e]?.variableName||e)].join(`, `)}],`),t.push(` // ...`),t.push(` });`)}else t.push(`Note: Could not determine package names for missing plugins.`),t.push(`Please ensure all required plugin layers are provided.`);return t.join(`
2
2
  `)}function $(e){return n.sync(()=>{let t=Z(e);if(!t.success){let e=Q(t);throw Error(e)}})}function he(e){let t=Z(e);if(!t.success){let e=Q(t);throw Error(e)}}const ge=(e,t,r)=>n.gen(function*(){if(!t){yield*n.sync(()=>{r.send(JSON.stringify({type:`error`,message:`Job ID is required for flow event subscription`,code:`MISSING_JOB_ID`}))});return}yield*e.subscribeToFlowEvents(t,r)}),_e=(e,t)=>n.gen(function*(){t&&(yield*e.unsubscribeFromFlowEvents(t))}),ve=(e,t,r)=>n.gen(function*(){if(!t){yield*n.sync(()=>{r.send(JSON.stringify({type:`error`,message:`Upload ID is required for upload event subscription`,code:`MISSING_UPLOAD_ID`}))});return}yield*e.subscribeToUploadEvents(t,r)}),ye=(e,t)=>n.gen(function*(){t&&(yield*e.unsubscribeFromUploadEvents(t))}),be=(e,t,r)=>{let{connection:i,isFlowRoute:a,isUploadRoute:o,jobId:s,uploadId:c,eventId:l}=e;return n.gen(function*(){a&&(yield*ge(r,s,i)),o&&(yield*ve(t,c,i)),i.send(JSON.stringify({type:`connection`,message:`Uploadista WebSocket connected`,id:l,jobId:s,uploadId:c,timestamp:new Date().toISOString()}))}).pipe(n.catchAll(e=>n.sync(()=>{console.error(`Error subscribing to events:`,e);let t=e instanceof b?e.body:`Failed to subscribe to events`;i.send(JSON.stringify({type:`error`,message:t,code:e instanceof b?e.code:`SUBSCRIPTION_ERROR`}))})))},xe=(e,t)=>n.sync(()=>{try{JSON.parse(e).type===`ping`&&t.send(JSON.stringify({type:`pong`,timestamp:new Date().toISOString()}))}catch(e){console.error(`Error handling WebSocket message:`,e),t.send(JSON.stringify({type:`error`,message:`Invalid message format`}))}}),Se=(e,t,r)=>{let{isFlowRoute:i,isUploadRoute:a,jobId:o,uploadId:s}=e;return n.gen(function*(){i&&(yield*_e(r,o)),a&&(yield*ye(t,s))}).pipe(n.catchAll(e=>n.sync(()=>{console.error(`Error unsubscribing from events:`,e instanceof b?e.body:e)})))},Ce=(e,t)=>n.sync(()=>{console.error(`WebSocket error for event ${t}:`,e)});export{B as AdapterError,x as AuthCacheService,S as AuthCacheServiceLive,P as AuthContextService,F as AuthContextServiceLive,U as BadRequestError,C as NoAuthCacheServiceLive,ie as NoAuthContextServiceLive,H as NotFoundError,V as ValidationError,W as createErrorResponseBody,N as createFlowServerLayer,K as createGenericErrorResponseBody,de as createTypeSafeServer,M as createUploadServerLayer,G as createUploadistaErrorResponseBody,J as createUploadistaServer,fe as defineFlow,pe as defineSimpleFlow,j as extractFlowAndStorageId,A as extractJobAndNodeId,k as extractJobIdFromStatus,X as extractServiceIdentifiers,Q as formatPluginValidationError,e as getAuthCredentials,T as getLastSegment,D as getRouteSegments,O as handleFlowError,Se as handleWebSocketClose,Ce as handleWebSocketError,xe as handleWebSocketMessage,be as handleWebSocketOpen,E as hasBasePath,w as parseUrlSegments,Z as validatePluginRequirements,$ as validatePluginRequirementsEffect,he as validatePluginsOrThrow};
3
3
  //# sourceMappingURL=index.mjs.map
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@uploadista/server",
3
3
  "type": "module",
4
- "version": "0.0.17-beta.6",
4
+ "version": "0.0.17-beta.9",
5
5
  "description": "Core Server package for Uploadista",
6
6
  "license": "MIT",
7
7
  "author": "Uploadista",
@@ -20,23 +20,23 @@
20
20
  }
21
21
  },
22
22
  "dependencies": {
23
- "effect": "3.19.4",
24
- "zod": "4.1.12",
25
- "@uploadista/observability": "0.0.17-beta.6",
26
- "@uploadista/event-emitter-websocket": "0.0.17-beta.6",
27
- "@uploadista/event-broadcaster-memory": "0.0.17-beta.6",
28
- "@uploadista/core": "0.0.17-beta.6"
23
+ "effect": "3.19.6",
24
+ "zod": "4.1.13",
25
+ "@uploadista/core": "0.0.17-beta.9",
26
+ "@uploadista/event-emitter-websocket": "0.0.17-beta.9",
27
+ "@uploadista/event-broadcaster-memory": "0.0.17-beta.9",
28
+ "@uploadista/observability": "0.0.17-beta.9"
29
29
  },
30
30
  "devDependencies": {
31
- "@cloudflare/workers-types": "4.20251118.0",
31
+ "@cloudflare/workers-types": "4.20251121.0",
32
32
  "@effect/vitest": "0.27.0",
33
33
  "@types/express": "^5.0.0",
34
34
  "@types/node": "24.10.1",
35
35
  "tsd": "0.33.0",
36
- "tsdown": "0.16.5",
36
+ "tsdown": "0.16.6",
37
37
  "typescript": "5.9.3",
38
- "vitest": "4.0.10",
39
- "@uploadista/typescript-config": "0.0.17-beta.6"
38
+ "vitest": "4.0.13",
39
+ "@uploadista/typescript-config": "0.0.17-beta.9"
40
40
  },
41
41
  "peerDependencies": {
42
42
  "express": "^4.0.0 || ^5.0.0",
File without changes