@panter/cloud-tasks 3.1.0 → 3.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/httpCall.cjs +1 -0
- package/dist/httpCall.d.ts +37 -0
- package/dist/httpCall.d.ts.map +1 -0
- package/dist/httpCall.mjs +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/server.cjs +1 -1
- package/dist/server.d.ts +2 -2
- package/dist/server.d.ts.map +1 -1
- package/dist/server.mjs +1 -1
- package/package.json +11 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var p=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var a=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var s=(e,t)=>p(e,"name",{value:t,configurable:!0});var c=(e,t)=>{for(var r in t)p(e,r,{get:t[r],enumerable:!0})},y=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of a(t))!d.call(e,n)&&n!==r&&p(e,n,{get:()=>t[n],enumerable:!(o=i(t,n))||o.enumerable});return e};var R=e=>y(p({},"__esModule",{value:!0}),e);var l={};c(l,{TRPC_PATH_PREFIX:()=>u,trpcHttpCall:()=>f});module.exports=R(l);var u="/trpc";function f(e){let t=e?.pathPrefix??u;return(r,o)=>({path:`${t}/${r}`,method:"POST",body:JSON.stringify(o),headers:{"Content-Type":"application/json"}})}s(f,"trpcHttpCall");
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { AnyMutationProcedure, AnyRouter, inferRouterInputs } from "@trpc/server";
|
|
2
|
+
export declare const TRPC_PATH_PREFIX = "/trpc";
|
|
3
|
+
/** Extract only mutation procedure keys from a Router */
|
|
4
|
+
type MutationKeys<R extends AnyRouter> = {
|
|
5
|
+
[K in keyof R["_def"]["procedures"]]: R["_def"]["procedures"][K] extends AnyMutationProcedure ? K : never;
|
|
6
|
+
}[keyof R["_def"]["procedures"]];
|
|
7
|
+
type TrpcHttpCallResult = {
|
|
8
|
+
path: string;
|
|
9
|
+
method: "POST";
|
|
10
|
+
body: string;
|
|
11
|
+
headers: {
|
|
12
|
+
"Content-Type": "application/json";
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Create a typesafe helper to produce HTTP call details for tRPC task procedures.
|
|
17
|
+
*
|
|
18
|
+
* Useful for constructing cron job / Cloud Scheduler HTTP targets without importing
|
|
19
|
+
* the service module (which would trigger side effects).
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```ts
|
|
23
|
+
* import type { Router } from "@repo/zfv-factsheet-syncer/api"
|
|
24
|
+
* import { trpcHttpCall } from "@panter/cloud-tasks/httpCall"
|
|
25
|
+
*
|
|
26
|
+
* const syncAll = trpcHttpCall<Router>()("syncAll", { syncOpeningHours: "upcoming" })
|
|
27
|
+
* // syncAll.path === "/trpc/syncAll"
|
|
28
|
+
* // syncAll.method === "POST"
|
|
29
|
+
* // syncAll.body === '{"syncOpeningHours":"upcoming"}'
|
|
30
|
+
* // syncAll.headers === { "Content-Type": "application/json" }
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export declare function trpcHttpCall<Router extends AnyRouter>(options?: {
|
|
34
|
+
pathPrefix?: string;
|
|
35
|
+
}): <K extends string & MutationKeys<Router>>(procedureName: K, input: inferRouterInputs<Router>[K]) => TrpcHttpCallResult;
|
|
36
|
+
export {};
|
|
37
|
+
//# sourceMappingURL=httpCall.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"httpCall.d.ts","sourceRoot":"","sources":["../src/httpCall.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EACpB,SAAS,EACT,iBAAiB,EAClB,MAAM,cAAc,CAAC;AAEtB,eAAO,MAAM,gBAAgB,UAAU,CAAC;AAExC,yDAAyD;AACzD,KAAK,YAAY,CAAC,CAAC,SAAS,SAAS,IAAI;KACtC,CAAC,IAAI,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,SAAS,oBAAoB,GACzF,CAAC,GACD,KAAK;CACV,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC;AAEjC,KAAK,kBAAkB,GAAG;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE;QAAE,cAAc,EAAE,kBAAkB,CAAA;KAAE,CAAC;CACjD,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,YAAY,CAAC,MAAM,SAAS,SAAS,EAAE,OAAO,CAAC,EAAE;IAC/D,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,IAES,CAAC,SAAS,MAAM,GAAG,YAAY,CAAC,MAAM,CAAC,EAC7C,eAAe,CAAC,EAChB,OAAO,iBAAiB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAClC,kBAAkB,CAMtB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var p=Object.defineProperty;var r=(t,e)=>p(t,"name",{value:e,configurable:!0});var s="/trpc";function i(t){let e=t?.pathPrefix??s;return(n,o)=>({path:`${e}/${n}`,method:"POST",body:JSON.stringify(o),headers:{"Content-Type":"application/json"}})}r(i,"trpcHttpCall");export{s as TRPC_PATH_PREFIX,i as trpcHttpCall};
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var b=Object.create;var d=Object.defineProperty;var K=Object.getOwnPropertyDescriptor;var _=Object.getOwnPropertyNames;var j=Object.getPrototypeOf,Q=Object.prototype.hasOwnProperty;var s=(r,t)=>d(r,"name",{value:t,configurable:!0});var G=(r,t)=>{for(var e in t)d(r,e,{get:t[e],enumerable:!0})},x=(r,t,e,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of _(t))!Q.call(r,n)&&n!==e&&d(r,n,{get:()=>t[n],enumerable:!(o=K(t,n))||o.enumerable});return r};var F=(r,t,e)=>(e=r!=null?b(j(r)):{},x(t||!r||!r.__esModule?d(e,"default",{value:r,enumerable:!0}):e,r)),H=r=>x(d({},"__esModule",{value:!0}),r);var $={};G($,{TRPC_PATH_PREFIX:()=>y,createExpressTaskServer:()=>B,createExpressTaskServerMiddleware:()=>M,createTasksClient:()=>U,trpcHttpCall:()=>S});module.exports=H($);var E=require("@google-cloud/tasks"),q=require("@grpc/grpc-js"),v=require("google-gax"),g=require("ts-results-es");var w=require("google-auth-library"),k=require("google-gax"),i=require("ts-results-es");function l(r){return r instanceof Error&&"code"in r&&Number.isInteger(r.code)}s(l,"isRpcError");function c(r){return l(r)?{...r,type:"rpc"}:{type:"unknown",error:r}}s(c,"toTasksError");function P(r){let t=new Uint8Array(3);crypto.getRandomValues(t);let e=Buffer.from(t).toString("hex");return`${r}-${Date.now()}-${e}`}s(P,"createUniqueName");var m=class{constructor(t,e,o,n){this.client=t;this.location=e;this.queueName=o;this.logger=n;this.projectIdPromise=this.client.getProjectId(),this.serviceAccountEmailPromise=new w.GoogleAuth().getCredentials().then(a=>a.client_email??null)}static{s(this,"CommonTasksClient")}serviceAccountEmailPromise;projectIdPromise;async upsertQueue(t){try{let e=await this.projectIdPromise,o=this.client.queuePath(e,this.location,this.queueName),n=this.client.locationPath(e,this.location);this.logger.info({queuePath:o,parentPath:n},"upserting tasks queue");let a="create";try{await this.client.getQueue({name:o}),a="update"}catch(u){if(l(u)&&u.code===k.Status.NOT_FOUND)a="create";else throw u}return a==="update"?(this.logger.info({queuePath:o},"updating existing queue"),await this.client.updateQueue({queue:{name:o,...t}})):(this.logger.info({queuePath:o},"creating new queue"),await this.client.createQueue({parent:n,queue:{name:o,...t}})),i.Ok.EMPTY}catch(e){return(0,i.Err)(c(e))}}async listTasks(){try{let t=await this.projectIdPromise,e=this.client.queuePath(t,this.location,this.queueName),[o]=await this.client.listTasks({parent:e});return(0,i.Ok)(o)}catch(t){return(0,i.Err)(c(t))}}async createTask(t,e){try{let o=await this.projectIdPromise,n=this.client.queuePath(o,this.location,this.queueName),a=this.client.taskPath(o,this.location,this.queueName,P(t)),u=await this.serviceAccountEmailPromise;return this.logger.info({queuePath:n,taskPath:a,url:e?.httpRequest?.url,payload:e?.httpRequest?.body,serviceAccountEmail:u},"scheduling task"),await this.client.createTask({parent:n,task:{...e,name:a,httpRequest:{...e?.httpRequest,oidcToken:{serviceAccountEmail:u}}}}),(0,i.Ok)(a)}catch(o){return(0,i.Err)(c(o))}}async getTask(t){try{let[e]=await this.client.getTask({name:t});return(0,i.Ok)(e)}catch(e){return l(e)&&e.code===k.Status.NOT_FOUND?(0,i.Ok)(null):(0,i.Err)(c(e))}}};var f=class extends m{static{s(this,"EmulatorTasksClient")}constructor(t,e,o,n){super(new E.CloudTasksClient({sslCreds:q.credentials.createInsecure(),servicePath:n.host??"localhost",port:n.port}),t,e,o)}async upsertQueue(t){try{let e=await this.projectIdPromise,o=this.client.queuePath(e,this.location,this.queueName),n=this.client.locationPath(e,this.location);this.logger.info({queuePath:o,parentPath:n},"upserting simulator tasks queue");try{return await this.client.createQueue({parent:n,queue:{name:o,...t}}),g.Ok.EMPTY}catch(a){return l(a)&&a.code!==v.Status.ALREADY_EXISTS?(0,g.Err)(c(a)):(this.logger.warn({},"dev warning: the queue was not updated due to the emulator not supporting update"),this.logger.warn({},"if you need to update queue options, restart the emulator"),g.Ok.EMPTY)}}catch(e){return(0,g.Err)(c(e))}}async createTask(t,e){return super.createTask(t,{...e,httpRequest:{...e?.httpRequest,url:e?.httpRequest?.url?.replace("//localhost","//host.containers.internal")}})}};var I=require("@google-cloud/tasks");var h=class extends m{static{s(this,"RegularTasksClient")}constructor(t,e,o){super(new I.CloudTasksClient({}),t,e,o)}};function A({queueName:r,emulator:t=!1,location:e="europe-west6",logger:o={error:console.error,info:console.info,warn:console.warn}}){return o.info({queueName:r,emulator:t,location:e},"creating base tasks client"),t?new f(e,r,o,t):new h(e,r,o)}s(A,"createBaseTaskClient");function U({tasksWorkerUrl:r,queueOptions:t,...e}){let o=A(e),n=e.logger??{error:console.error,info:console.info,warn:console.warn};return new Proxy({},{get:s((a,u)=>u==="_manage"?{find:s(p=>o.getTask(p).then(T=>T.unwrap()),"find"),list:s(()=>o.listTasks().then(p=>p.unwrap()),"list")}:{schedule:s(async(p,T)=>{let C=u.toString();await o.upsertQueue(t);let R=new URL(`/trpc/${C}`,r).toString();return n.info({url:R,input:p},"scheduling http request that calls trpc mutation of tasks worker"),(await o.createTask(C,{...T,httpRequest:{httpMethod:"POST",url:R,headers:{"Content-Type":"application/json"},body:p?Buffer.from(JSON.stringify(p)).toString("base64"):null}})).unwrap()},"schedule")},"get")})}s(U,"createTasksClient");var N=require("@trpc/server"),O=require("@trpc/server/adapters/express"),L=F(require("express"));var y="/trpc";function S(r){let t=r?.pathPrefix??y;return(e,o)=>({path:`${t}/${e}`,method:"POST",body:JSON.stringify(o),headers:{"Content-Type":"application/json"}})}s(S,"trpcHttpCall");var M=s(({createRouter:r,createContext:t})=>{let e=N.initTRPC.context().create(),o=r(e);return{expressMiddleware:(0,O.createExpressMiddleware)({router:o,createContext:t}),router:o}},"createExpressTaskServerMiddleware");function B({createRouter:r,createContext:t,app:e=(0,L.default)()}){let{expressMiddleware:o,router:n}=M({createRouter:r,createContext:t});return e.use(y,o),{runServer:s(a=>{e.listen({port:a})},"runServer"),router:n}}s(B,"createExpressTaskServer");
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var E=Object.defineProperty;var s=(o,r)=>E(o,"name",{value:r,configurable:!0});import{CloudTasksClient as v}from"@google-cloud/tasks";import{credentials as I}from"@grpc/grpc-js";import{Status as A}from"google-gax";import{Err as x,Ok as P}from"ts-results-es";import{GoogleAuth as q}from"google-auth-library";import{Status as R}from"google-gax";import{Err as f,Ok as m}from"ts-results-es";function p(o){return o instanceof Error&&"code"in o&&Number.isInteger(o.code)}s(p,"isRpcError");function u(o){return p(o)?{...o,type:"rpc"}:{type:"unknown",error:o}}s(u,"toTasksError");function C(o){let r=new Uint8Array(3);crypto.getRandomValues(r);let e=Buffer.from(r).toString("hex");return`${o}-${Date.now()}-${e}`}s(C,"createUniqueName");var l=class{constructor(r,e,t,n){this.client=r;this.location=e;this.queueName=t;this.logger=n;this.projectIdPromise=this.client.getProjectId(),this.serviceAccountEmailPromise=new q().getCredentials().then(a=>a.client_email??null)}static{s(this,"CommonTasksClient")}serviceAccountEmailPromise;projectIdPromise;async upsertQueue(r){try{let e=await this.projectIdPromise,t=this.client.queuePath(e,this.location,this.queueName),n=this.client.locationPath(e,this.location);this.logger.info({queuePath:t,parentPath:n},"upserting tasks queue");let a="create";try{await this.client.getQueue({name:t}),a="update"}catch(i){if(p(i)&&i.code===R.NOT_FOUND)a="create";else throw i}return a==="update"?(this.logger.info({queuePath:t},"updating existing queue"),await this.client.updateQueue({queue:{name:t,...r}})):(this.logger.info({queuePath:t},"creating new queue"),await this.client.createQueue({parent:n,queue:{name:t,...r}})),m.EMPTY}catch(e){return f(u(e))}}async listTasks(){try{let r=await this.projectIdPromise,e=this.client.queuePath(r,this.location,this.queueName),[t]=await this.client.listTasks({parent:e});return m(t)}catch(r){return f(u(r))}}async createTask(r,e){try{let t=await this.projectIdPromise,n=this.client.queuePath(t,this.location,this.queueName),a=this.client.taskPath(t,this.location,this.queueName,C(r)),i=await this.serviceAccountEmailPromise;return this.logger.info({queuePath:n,taskPath:a,url:e?.httpRequest?.url,payload:e?.httpRequest?.body,serviceAccountEmail:i},"scheduling task"),await this.client.createTask({parent:n,task:{...e,name:a,httpRequest:{...e?.httpRequest,oidcToken:{serviceAccountEmail:i}}}}),m(a)}catch(t){return f(u(t))}}async getTask(r){try{let[e]=await this.client.getTask({name:r});return m(e)}catch(e){return p(e)&&e.code===R.NOT_FOUND?m(null):f(u(e))}}};var g=class extends l{static{s(this,"EmulatorTasksClient")}constructor(r,e,t,n){super(new v({sslCreds:I.createInsecure(),servicePath:n.host??"localhost",port:n.port}),r,e,t)}async upsertQueue(r){try{let e=await this.projectIdPromise,t=this.client.queuePath(e,this.location,this.queueName),n=this.client.locationPath(e,this.location);this.logger.info({queuePath:t,parentPath:n},"upserting simulator tasks queue");try{return await this.client.createQueue({parent:n,queue:{name:t,...r}}),P.EMPTY}catch(a){return p(a)&&a.code!==A.ALREADY_EXISTS?x(u(a)):(this.logger.warn({},"dev warning: the queue was not updated due to the emulator not supporting update"),this.logger.warn({},"if you need to update queue options, restart the emulator"),P.EMPTY)}}catch(e){return x(u(e))}}async createTask(r,e){return super.createTask(r,{...e,httpRequest:{...e?.httpRequest,url:e?.httpRequest?.url?.replace("//localhost","//host.containers.internal")}})}};import{CloudTasksClient as S}from"@google-cloud/tasks";var d=class extends l{static{s(this,"RegularTasksClient")}constructor(r,e,t){super(new S({}),r,e,t)}};function w({queueName:o,emulator:r=!1,location:e="europe-west6",logger:t={error:console.error,info:console.info,warn:console.warn}}){return t.info({queueName:o,emulator:r,location:e},"creating base tasks client"),r?new g(e,o,t,r):new d(e,o,t)}s(w,"createBaseTaskClient");function le({tasksWorkerUrl:o,queueOptions:r,...e}){let t=w(e),n=e.logger??{error:console.error,info:console.info,warn:console.warn};return new Proxy({},{get:s((a,i)=>i==="_manage"?{find:s(c=>t.getTask(c).then(y=>y.unwrap()),"find"),list:s(()=>t.listTasks().then(c=>c.unwrap()),"list")}:{schedule:s(async(c,y)=>{let T=i.toString();await t.upsertQueue(r);let k=new URL(`/trpc/${T}`,o).toString();return n.info({url:k,input:c},"scheduling http request that calls trpc mutation of tasks worker"),(await t.createTask(T,{...y,httpRequest:{httpMethod:"POST",url:k,headers:{"Content-Type":"application/json"},body:c?Buffer.from(JSON.stringify(c)).toString("base64"):null}})).unwrap()},"schedule")},"get")})}s(le,"createTasksClient");import{initTRPC as O}from"@trpc/server";import{createExpressMiddleware as L}from"@trpc/server/adapters/express";import M from"express";var h="/trpc";function N(o){let r=o?.pathPrefix??h;return(e,t)=>({path:`${r}/${e}`,method:"POST",body:JSON.stringify(t),headers:{"Content-Type":"application/json"}})}s(N,"trpcHttpCall");var b=s(({createRouter:o,createContext:r})=>{let e=O.context().create(),t=o(e);return{expressMiddleware:L({router:t,createContext:r}),router:t}},"createExpressTaskServerMiddleware");function Ce({createRouter:o,createContext:r,app:e=M()}){let{expressMiddleware:t,router:n}=b({createRouter:o,createContext:r});return e.use(h,t),{runServer:s(a=>{e.listen({port:a})},"runServer"),router:n}}s(Ce,"createExpressTaskServer");export{h as TRPC_PATH_PREFIX,Ce as createExpressTaskServer,b as createExpressTaskServerMiddleware,le as createTasksClient,N as trpcHttpCall};
|
package/dist/server.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var y=Object.create;var p=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var P=Object.getOwnPropertyNames;var f=Object.getPrototypeOf,l=Object.prototype.hasOwnProperty;var s=(e,t)=>p(e,"name",{value:t,configurable:!0});var m=(e,t)=>{for(var r in t)p(e,r,{get:t[r],enumerable:!0})},u=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of P(t))!l.call(e,n)&&n!==r&&p(e,n,{get:()=>t[n],enumerable:!(o=T(t,n))||o.enumerable});return e};var A=(e,t,r)=>(r=e!=null?y(f(e)):{},u(t||!e||!e.__esModule?p(r,"default",{value:e,enumerable:!0}):r,e)),h=e=>u(p({},"__esModule",{value:!0}),e);var M={};m(M,{TRPC_PATH_PREFIX:()=>a,createExpressTaskServer:()=>H,createExpressTaskServerMiddleware:()=>d,trpcHttpCall:()=>x});module.exports=h(M);var R=require("@trpc/server"),i=require("@trpc/server/adapters/express"),C=A(require("express"));var a="/trpc";function x(e){let t=e?.pathPrefix??a;return(r,o)=>({path:`${t}/${r}`,method:"POST",body:JSON.stringify(o),headers:{"Content-Type":"application/json"}})}s(x,"trpcHttpCall");var d=s(({createRouter:e,createContext:t})=>{let r=R.initTRPC.context().create(),o=e(r);return{expressMiddleware:(0,i.createExpressMiddleware)({router:o,createContext:t}),router:o}},"createExpressTaskServerMiddleware");function H({createRouter:e,createContext:t,app:r=(0,C.default)()}){let{expressMiddleware:o,router:n}=d({createRouter:e,createContext:t});return r.use(a,o),{runServer:s(c=>{r.listen({port:c})},"runServer"),router:n}}s(H,"createExpressTaskServer");
|
package/dist/server.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { AnyRouter } from "@trpc/server";
|
|
2
2
|
import { initTRPC } from "@trpc/server";
|
|
3
|
-
import { NodeHTTPCreateContextFnOptions } from "@trpc/server/adapters/node-http";
|
|
3
|
+
import type { NodeHTTPCreateContextFnOptions } from "@trpc/server/adapters/node-http";
|
|
4
4
|
import express from "express";
|
|
5
|
+
export { TRPC_PATH_PREFIX, trpcHttpCall } from "./httpCall";
|
|
5
6
|
type TRPCInstance<Context extends object> = ReturnType<ReturnType<typeof initTRPC.context<Context>>["create"]>;
|
|
6
7
|
type CreateRouter<Router extends AnyRouter, Context extends object> = (t: TRPCInstance<Context>) => Router;
|
|
7
8
|
export declare const createExpressTaskServerMiddleware: <Router extends AnyRouter, CreateContext extends (opts: NodeHTTPCreateContextFnOptions<express.Request, express.Response>) => any>({ createRouter, createContext, }: {
|
|
@@ -19,5 +20,4 @@ export declare function createExpressTaskServer<Router extends AnyRouter, Create
|
|
|
19
20
|
runServer: (port: number) => void;
|
|
20
21
|
router: Router;
|
|
21
22
|
};
|
|
22
|
-
export {};
|
|
23
23
|
//# sourceMappingURL=server.d.ts.map
|
package/dist/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,OAAO,EAAE,8BAA8B,EAAE,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,iCAAiC,CAAC;AACtF,OAAO,OAAO,MAAM,SAAS,CAAC;AAI9B,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE5D,KAAK,YAAY,CAAC,OAAO,SAAS,MAAM,IAAI,UAAU,CACpD,UAAU,CAAC,OAAO,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,CACvD,CAAC;AAEF,KAAK,YAAY,CAAC,MAAM,SAAS,SAAS,EAAE,OAAO,SAAS,MAAM,IAAI,CACpE,CAAC,EAAE,YAAY,CAAC,OAAO,CAAC,KACrB,MAAM,CAAC;AAEZ,eAAO,MAAM,iCAAiC,GAC5C,MAAM,SAAS,SAAS,EACxB,aAAa,SAAS,CACpB,IAAI,EAAE,8BAA8B,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,QAAQ,CAAC,KACpE,GAAG,EACR,kCAGC;IACD,YAAY,EAAE,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;IACvE,aAAa,CAAC,EAAE,aAAa,CAAC;CAC/B;;;CAaA,CAAC;AACF,wBAAgB,uBAAuB,CACrC,MAAM,SAAS,SAAS,EACxB,aAAa,SAAS,CACpB,IAAI,EAAE,8BAA8B,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,QAAQ,CAAC,KACpE,GAAG,EACR,EACA,YAAY,EACZ,aAAa,EACb,GAAe,GAChB,EAAE;IACD,YAAY,EAAE,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;IACvE,aAAa,EAAE,aAAa,CAAC;IAC7B,GAAG,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC;CAC3B;sBAQqB,MAAM;;EAK3B"}
|
package/dist/server.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var u=Object.defineProperty;var n=(e,t)=>u(e,"name",{value:t,configurable:!0});import{initTRPC as R}from"@trpc/server";import{createExpressMiddleware as i}from"@trpc/server/adapters/express";import C from"express";var s="/trpc";function x(e){let t=e?.pathPrefix??s;return(r,o)=>({path:`${t}/${r}`,method:"POST",body:JSON.stringify(o),headers:{"Content-Type":"application/json"}})}n(x,"trpcHttpCall");var d=n(({createRouter:e,createContext:t})=>{let r=R.context().create(),o=e(r);return{expressMiddleware:i({router:o,createContext:t}),router:o}},"createExpressTaskServerMiddleware");function A({createRouter:e,createContext:t,app:r=C()}){let{expressMiddleware:o,router:p}=d({createRouter:e,createContext:t});return r.use(s,o),{runServer:n(a=>{r.listen({port:a})},"runServer"),router:p}}n(A,"createExpressTaskServer");export{s as TRPC_PATH_PREFIX,A as createExpressTaskServer,d as createExpressTaskServerMiddleware,x as trpcHttpCall};
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"type": "git",
|
|
5
5
|
"url": "https://git.panter.ch/open-source/cloud-tasks.git"
|
|
6
6
|
},
|
|
7
|
-
"version": "3.
|
|
7
|
+
"version": "3.3.0",
|
|
8
8
|
"sideEffects": false,
|
|
9
9
|
"exports": {
|
|
10
10
|
".": {
|
|
@@ -37,6 +37,16 @@
|
|
|
37
37
|
"default": "./dist/base.cjs"
|
|
38
38
|
}
|
|
39
39
|
},
|
|
40
|
+
"./httpCall": {
|
|
41
|
+
"import": {
|
|
42
|
+
"types": "./dist/httpCall.d.ts",
|
|
43
|
+
"default": "./dist/httpCall.mjs"
|
|
44
|
+
},
|
|
45
|
+
"require": {
|
|
46
|
+
"types": "./dist/httpCall.d.ts",
|
|
47
|
+
"default": "./dist/httpCall.cjs"
|
|
48
|
+
}
|
|
49
|
+
},
|
|
40
50
|
"./server": {
|
|
41
51
|
"import": {
|
|
42
52
|
"types": "./dist/server.d.ts",
|