planx 20.66.1 → 20.67.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/agent.main.mjs +7 -7
- package/blob.main.mjs +2 -2
- package/config.main.mjs +2 -2
- package/domain.main.mjs +2 -2
- package/exit.main.mjs +2 -2
- package/explorer.main.mjs +1 -1
- package/filesystem.main.mjs +2 -2
- package/intelligence.main.mjs +1 -1
- package/log.main.mjs +1 -1
- package/main.js +242 -242
- package/nosturn.main.mjs +1 -1
- package/package.json +6 -6
- package/planx-networkd.main.mjs +1 -1
- package/presentation.main.mjs +1 -1
- package/session.main.mjs +1 -1
- package/transport.main.mjs +1 -1
package/domain.main.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
globalThis.__PLANX_SERVICE_VERSION__="20.
|
|
1
|
+
globalThis.__PLANX_SERVICE_VERSION__="20.67.0";
|
|
2
2
|
import { createRequire } from 'module';
|
|
3
3
|
const require = createRequire(import.meta.url);
|
|
4
4
|
|
|
@@ -505,7 +505,7 @@ ${I.typeDefs}`:"");try{let h={schema:(0,qB.buildSchema)(D),tables:e,docs:new Map
|
|
|
505
505
|
|
|
506
506
|
`)})},cancel(){C?.(),C=null}});return new Response(i.pipeThrough(new TextEncoderStream),{headers:{"content-type":"text/event-stream","cache-control":"no-cache"}})})}var eN=rI(PI());var EN=rI(PI());var x0=rI(PI());var bH="http://do.internal";async function V0(A,g,I,Q){let C=await Ko(A,g,{method:Q.method,url:`${bH}${Q.path}`,headers:{...I?{[Lo]:I}:{},...Q.headers},body:Q.body});if(typeof C=="string")throw new Error(`[domain-gateway] ${g} ${Q.path}: ${C}`);return{status:C.response.status,body:await H0(C)}}function O0(A,g,I){return async({document:Q,variables:C})=>{let{status:B,body:i}=await V0(A,g,I,{method:"POST",path:"/graphql",headers:{"content-type":"application/json",[f0]:Y0},body:JSON.stringify({query:(0,x0.print)(Q),variables:C})});if(B>=400)throw new Error(`[domain-gateway] ${g} /graphql failed: ${B}`);return JSON.parse(i)}}function v0(A,g,I){return async()=>{let{status:Q,body:C}=await V0(A,g,I,{method:"GET",path:"/federation"});if(Q>=300)return[];try{let B=JSON.parse(C);return Array.isArray(B?.joins)?B.joins:[]}catch{return[]}}}function qH(A){return`${A.charAt(0).toUpperCase()}${A.slice(1)}`}function TH(A){return[...A].sort((g,I)=>g.name.localeCompare(I.name)).map(g=>({field:g.name,prefix:qH(g.name),objectId:g.objectId}))}function W0(A,g){return TH(A.plugins()).map(I=>({field:I.field,prefix:I.prefix,executor:O0(A,I.objectId,g),federation:v0(A,I.objectId,g)}))}var cC=rI(PI());var jI=rI(PI()),ti="Domain";function ZQ(A){return new Set(Object.values(A.getTypeMap()).filter(g=>!g.name.startsWith("__")&&!(0,jI.isSpecifiedScalarType)(g)).map(g=>g.name))}function Z0(A,g){return{...A,value:`${g}${A.value}`}}function P0(A,g){let I=A.getSubscriptionType()?.name;return[...ZQ(A)].filter(Q=>Q!==I).map(Q=>`${g}${Q}`)}function j0(A,g=ti){let I=ZQ(A),Q=A.getSubscriptionType()?.name,C=i=>i.name.value===Q?null:I.has(i.name.value)?{...i,name:Z0(i.name,g)}:i,B=(0,jI.visit)((0,jI.parse)((0,jI.printSchema)(A)),{SchemaDefinition:()=>null,SchemaExtension:()=>null,NamedType:i=>I.has(i.name.value)?{...i,name:Z0(i.name,g)}:void 0,ObjectTypeDefinition:C,InterfaceTypeDefinition:C,UnionTypeDefinition:C,EnumTypeDefinition:C,InputObjectTypeDefinition:C,ScalarTypeDefinition:C});return(0,jI.print)({...B,kind:jI.Kind.DOCUMENT})}function X0(A,g,I=ti){let Q=A.startsWith(I)?A.slice(I.length):A;return g.has(Q)?Q:A}var CI=rI(PI());function _0(A,g,I){(0,CI.visit)(A,{FragmentSpread(Q){let C=g[Q.name.value];C&&!I.has(C.name.value)&&(I.set(C.name.value,C),_0(C.selectionSet,g,I))}})}function xH(A){let g=new Set;for(let I of A)(0,CI.visit)(I,{Variable(Q){g.add(Q.name.value)}});return g}function VH(A,g,I){return(0,CI.visit)(A,{NamedType:Q=>({...Q,name:{...Q.name,value:X0(Q.name.value,g,I)}})})}function Xn(A,g,I=ti){let Q=A.fieldNodes[0],C=new Map;Q.selectionSet&&_0(Q.selectionSet,A.fragments,C);let B=xH([Q,...C.values()]),i=(A.operation.variableDefinitions??[]).filter(D=>B.has(D.variable.name.value)),e={kind:CI.Kind.DOCUMENT,definitions:[{kind:CI.Kind.OPERATION_DEFINITION,operation:CI.OperationTypeNode.QUERY,variableDefinitions:i,selectionSet:{kind:CI.Kind.SELECTION_SET,selections:[Q]}},...C.values()]},o=Object.fromEntries(Object.entries(A.variableValues??{}).filter(([D])=>B.has(D)));return{document:VH(e,g,I),variables:o}}function OH(A,g){let[I,...Q]=A.definitions,C={kind:CI.Kind.SELECTION_SET,selections:I.selectionSet.selections},B={kind:CI.Kind.FIELD,name:{kind:CI.Kind.NAME,value:g},selectionSet:C};return{...A,definitions:[{...I,selectionSet:{kind:CI.Kind.SELECTION_SET,selections:[B]}},...Q]}}function _n(A,g,I=ti,Q,C=B=>B){let B=ZQ(g);return async(i,e,o,D)=>{let h=Xn(D,B,I),y=C(Q?OH(h.document,Q):h.document),l=await A({document:y,variables:h.variables}),u=D.fieldNodes[0].alias?.value??D.fieldNodes[0].name.value,Y=l.data,CA=Q?Y?.[Q]:Y,rA=CA?CA[u]:void 0,uA=l.errors??[];if(uA.length>0&&rA==null)throw new CI.GraphQLError(uA.map(PA=>PA.message).join("; "),{nodes:D.fieldNodes[0],path:(0,CI.responsePathAsArray)(D.path)});return vH(rA,uA,Q?[Q,u]:[u]),rA??null}}function vH(A,g,I){for(let Q of g){let C=Q.path??[];if(C.length<=I.length||I.some((e,o)=>C[o]!==e))continue;let B=C.slice(I.length),i=A;for(let e=0;e<B.length&&!(typeof i!="object"||i===null);e+=1){let o=i,D=o[B[e]];if(e===B.length-1||D===null||D===void 0){o[B[e]]=new CI.GraphQLError(Q.message);break}i=D}}}var uo=rI(PI());var zn="session";function $n(A,g,I){return A.replace(/[A-Za-z_][A-Za-z0-9_]*/g,Q=>g.has(Q)?`${I}${Q}`:Q)}function z0(A,g,I,Q,C){let B=A.getQueryType()?.getFields()[zn],i=B?(0,uo.getNamedType)(B.type):null;if(!i||!(0,uo.isObjectType)(i))return[];let e=ZQ(A),o=[];for(let D of Object.values(i.getFields())){if(I.has(D.name)){Q(`[domain-gateway] ${C} \u306E Session \u62E1\u5F35 ${D.name} \u3092\u7E2B\u308F\u306A\u3044 (\u65E2\u5B58\u306E field \u3068\u885D\u7A81)`);continue}I.add(D.name),o.push({name:D.name,type:$n(String(D.type),e,g)})}return o}var Lg=rI(PI());var $0=A=>`__planx_key_${A}`;async function AN(A,g){let I=[];for(let Q of A){let C=await Q.mount.federation?.().catch(()=>[])??[];for(let B of C){let i=A.find(y=>y.mount.field===B.plugin),e=Q.remote.getQueryType()?.getFields()[B.query],o=e?.args.find(y=>y.name===B.arg),D=i?.remote.getType(B.type),h=i?(0,Lg.isObjectType)(D)?!e||!o?`${Q.mount.field} \u306B root field ${B.query}(${B.arg}) \u304C\u7121\u3044`:D.getFields()[B.field]?`${B.field} \u306F\u65E2\u306B\u3042\u308B`:null:`\u578B ${B.type} \u304C\u7121\u3044`:`plugin ${B.plugin} \u304C\u7121\u3044`;if(h||!i||!e||!o){g(`[domain-gateway] ${Q.mount.field} \u306E join ${B.plugin}.${B.type}.${B.field} \u3092\u7E2B\u308F\u306A\u3044 (${h})`);continue}I.push({decl:B,source:Q,target:i,returnType:$n(String(e.type),ZQ(Q.remote),Q.mount.prefix),argType:String(o.type)})}}return I}function gN(A){return A.map(g=>`extend type ${g.target.mount.prefix}${g.decl.type} { ${g.decl.field}: ${g.returnType} }`)}function IN(A,g){let I=new Map;for(let Q of A)I.set(Q.decl.type,[...I.get(Q.decl.type)??[],Q]);return I.size===0?Q=>Q:Q=>{let C=new Lg.TypeInfo(g);return(0,Lg.visit)(Q,(0,Lg.visitWithTypeInfo)(C,{Field:B=>I.get(C.getParentType()?.name??"")?.some(i=>i.decl.field===B.name.value)?null:void 0,SelectionSet:B=>{let i=I.get(C.getParentType()?.name??"");if(!i)return;let o=[...new Set(i.map(D=>D.decl.key))].map(D=>({kind:Lg.Kind.FIELD,alias:{kind:Lg.Kind.NAME,value:$0(D)},name:{kind:Lg.Kind.NAME,value:D}}));return{...B,selections:[...B.selections,...o]}}}))}}function QN(A){let g=new WeakMap,I=async(Q,C)=>{g.delete(Q);let B=[...C.keys.keys()],i=Xn(C.info,ZQ(A.source.remote),A.source.mount.prefix),[e,...o]=i.document.definitions,D=B.map((u,Y)=>({kind:Lg.Kind.FIELD,alias:{kind:Lg.Kind.NAME,value:`k${Y}`},name:{kind:Lg.Kind.NAME,value:A.decl.query},arguments:[{kind:Lg.Kind.ARGUMENT,name:{kind:Lg.Kind.NAME,value:A.decl.arg},value:{kind:Lg.Kind.VARIABLE,name:{kind:Lg.Kind.NAME,value:`__k${Y}`}}}],selectionSet:Q.selectionSet})),h=[...e.variableDefinitions??[],...B.map((u,Y)=>({kind:Lg.Kind.VARIABLE_DEFINITION,variable:{kind:Lg.Kind.VARIABLE,name:{kind:Lg.Kind.NAME,value:`__k${Y}`}},type:(0,Lg.parseType)(A.argType)}))],y={kind:Lg.Kind.DOCUMENT,definitions:[{...e,variableDefinitions:h,selectionSet:{kind:Lg.Kind.SELECTION_SET,selections:D}},...o]},l={...i.variables,...Object.fromEntries(B.map((u,Y)=>[`__k${Y}`,u]))};try{let u=await A.source.mount.executor({document:y,variables:l}),Y=u.data??{};B.forEach((CA,rA)=>{let uA=C.keys.get(CA)??[];if(Y[`k${rA}`]===void 0&&u.errors?.length){let PA=new Lg.GraphQLError(u.errors.map(jA=>jA.message).join("; "));uA.forEach(jA=>jA.reject(PA))}else uA.forEach(PA=>PA.resolve(Y[`k${rA}`]??null))})}catch(u){C.keys.forEach(Y=>Y.forEach(CA=>CA.reject(u)))}};return(Q,C,B,i)=>{let e=String(Q[$0(A.decl.key)]??Q[A.decl.key]??""),o=i.fieldNodes[0],D=g.get(o);if(!D){let y={keys:new Map,info:i};D=y,g.set(o,y),queueMicrotask(()=>{I(o,y)})}let h=D.keys.get(e)??[];return D.keys.set(e,h),new Promise((y,l)=>h.push({resolve:y,reject:l}))}}var CN="Query";async function WH(A){let g=await A({document:(0,cC.parse)((0,cC.getIntrospectionQuery)())});if(!g.data||g.errors&&g.errors.length>0)throw new Error(`[domain-gateway] introspection failed: ${JSON.stringify(g.errors??null)}`);return(0,cC.buildClientSchema)(g.data)}var Aa=A=>A.getFields();async function ZH(A,g){let I=new Set([CN]),Q=new Set,C=[];for(let B of A){let i=await WH(B.executor).catch(h=>(g(`[domain-gateway] ${B.field}: ${h instanceof Error?h.message:String(h)}`),null)),e=i?.getQueryType();if(!i||!e)continue;let o=P0(i,B.prefix),D=[...o.filter(h=>I.has(h)),...Q.has(B.field)?[B.field]:[]];if(D.length>0){g(`[domain-gateway] ${B.field} \u3092\u7E2B\u308F\u306A\u3044 (\u885D\u7A81: ${D.join(", ")})`);continue}o.forEach(h=>I.add(h)),Q.add(B.field),C.push({mount:B,remote:i,queryName:`${B.prefix}${e.name}`})}return C}async function BN(A,g=()=>{}){let I=await ZH(A,g);if(I.length===0)return null;let Q=new Set(I.map(h=>h.mount.field)),C=I.map(h=>({...h,hoist:z0(h.remote,h.mount.prefix,Q,g,h.mount.field)})),B=[...I.map(h=>`${h.mount.field}: ${h.queryName}`),...C.flatMap(h=>h.hoist.map(y=>`${y.name}: ${y.type}`))],i=await AN(I,g),e=[...I.map(({mount:h,remote:y})=>j0(y,h.prefix)),`type ${CN} { ${B.join(" ")} }`,...gN(i)].join(`
|
|
507
507
|
`),o=(0,cC.buildSchema)(e),D=Aa(o.getQueryType());for(let{mount:h,remote:y,queryName:l,hoist:u}of C){let Y=IN(i.filter(rA=>rA.target.mount===h),y);D[h.field].resolve=()=>({});let CA=Aa(o.getType(l));for(let rA of Object.keys(y.getQueryType()?.getFields()??{}))CA[rA]&&(CA[rA].resolve=_n(h.executor,y,h.prefix,void 0,Y));for(let rA of u)D[rA.name].resolve=_n(h.executor,y,h.prefix,zn,Y)}for(let h of i)Aa(o.getType(`${h.target.mount.prefix}${h.decl.type}`))[h.decl.field].resolve=QN(h);return o}var PH="\0server";function iN(A,g=()=>{}){let I=new Map;A.onChange(()=>I.clear());async function Q(C){try{let B=await BN(W0(A,C),e=>g(C,e));if(!B)return null;let i=await crypto.subtle.digest("SHA-256",new TextEncoder().encode((0,EN.printSchema)(B)));return{schema:B,hash:Buffer.from(i).toString("hex")}}catch(B){return g(C,B instanceof Error?B.message:String(B)),null}}return{schemaFor(C){let B=C??PH,i=I.get(B);if(i)return i;let e=Q(C);return I.set(B,e),e}}}function jH(A){if(typeof A!="object"||A===null)return null;let{query:g,variables:I,operationName:Q}=A;return typeof g!="string"||I!=null&&(typeof I!="object"||Array.isArray(I))||Q!=null&&typeof Q!="string"?null:{query:g,variables:I,operationName:Q}}function oN(A,g){let I=null,Q=()=>I??=g().then(e=>iN(e,(o,D)=>process.stderr.write(`[domain-gateway] ${o??"(server)"}: ${D}
|
|
508
|
-
`))),C={error:{code:"NO_GATEWAY",message:"no domain object is mounted"}},B=async(e,o)=>{let D=await(await Q()).schemaFor(o);return D?e.json({hash:D.hash}):e.json(C,404)},i=async(e,o)=>{let D=await(await Q()).schemaFor(o);if(!D)return e.json(C,404);let h=jH(await e.req.json().catch(()=>null));if(!h)return e.json({error:{code:"INVALID_BODY",message:"expected { query, variables?, operationName? }"}},400);let y=await(0,eN.graphql)({schema:D.schema,source:h.query,variableValues:h.variables??void 0,operationName:h.operationName??void 0});return e.json(y)};A.get("/domain/sessions/:sessionId/graphql/hash",e=>B(e,e.req.param("sessionId"))),A.post("/domain/sessions/:sessionId/graphql",e=>i(e,e.req.param("sessionId"))),A.get("/graphql/hash",e=>B(e,null)),A.post("/graphql",e=>i(e,null))}import{isIP as XH}from"node:net";var _H="x-planx-l7-peer",tN=new Set(["127.0.0.1","localhost","::1","[::1]"]);function sN(A){let g=A.trim().toLowerCase();return g.startsWith("[")?g.slice(0,g.indexOf("]")+1):g.replace(/:\d+$/,"")}function zH(A){return!!A&&tN.has(sN(A))}function $H(A){return A?XH(sN(A).replace(/^\[|\]$/g,""))!==0:!1}function Ap(A){if(!A)return!1;try{let g=new URL(A);return(g.protocol==="http:"||g.protocol==="https:")&&tN.has(g.hostname.toLowerCase())}catch{return!1}}function gp(A){return A.host&&!zH(A.host)&&!$H(A.host)?"bad-host":A.origin&&!Ap(A.origin)&&!A.l7Peer?"bad-origin":"allow"}function DN(){return async(A,g)=>{let I=gp({host:A.req.header("host"),origin:A.req.header("origin"),l7Peer:A.req.header(_H)});if(I!=="allow")return new Response(JSON.stringify({error:"Forbidden",reason:I}),{status:403,headers:{"content-type":"application/json"}});await g()}}function rN(A){return[Go,Uo].some(I=>A.message.includes(I))?{status:503,headers:{"retry-after":"1"}}:{status:500,headers:{}}}var Bp="20.
|
|
508
|
+
`))),C={error:{code:"NO_GATEWAY",message:"no domain object is mounted"}},B=async(e,o)=>{let D=await(await Q()).schemaFor(o);return D?e.json({hash:D.hash}):e.json(C,404)},i=async(e,o)=>{let D=await(await Q()).schemaFor(o);if(!D)return e.json(C,404);let h=jH(await e.req.json().catch(()=>null));if(!h)return e.json({error:{code:"INVALID_BODY",message:"expected { query, variables?, operationName? }"}},400);let y=await(0,eN.graphql)({schema:D.schema,source:h.query,variableValues:h.variables??void 0,operationName:h.operationName??void 0});return e.json(y)};A.get("/domain/sessions/:sessionId/graphql/hash",e=>B(e,e.req.param("sessionId"))),A.post("/domain/sessions/:sessionId/graphql",e=>i(e,e.req.param("sessionId"))),A.get("/graphql/hash",e=>B(e,null)),A.post("/graphql",e=>i(e,null))}import{isIP as XH}from"node:net";var _H="x-planx-l7-peer",tN=new Set(["127.0.0.1","localhost","::1","[::1]"]);function sN(A){let g=A.trim().toLowerCase();return g.startsWith("[")?g.slice(0,g.indexOf("]")+1):g.replace(/:\d+$/,"")}function zH(A){return!!A&&tN.has(sN(A))}function $H(A){return A?XH(sN(A).replace(/^\[|\]$/g,""))!==0:!1}function Ap(A){if(!A)return!1;try{let g=new URL(A);return(g.protocol==="http:"||g.protocol==="https:")&&tN.has(g.hostname.toLowerCase())}catch{return!1}}function gp(A){return A.host&&!zH(A.host)&&!$H(A.host)?"bad-host":A.origin&&!Ap(A.origin)&&!A.l7Peer?"bad-origin":"allow"}function DN(){return async(A,g)=>{let I=gp({host:A.req.header("host"),origin:A.req.header("origin"),l7Peer:A.req.header(_H)});if(I!=="allow")return new Response(JSON.stringify({error:"Forbidden",reason:I}),{status:403,headers:{"content-type":"application/json"}});await g()}}function rN(A){return[Go,Uo].some(I=>A.message.includes(I))?{status:503,headers:{"retry-after":"1"}}:{status:500,headers:{}}}var Bp="20.67.0";function nN(A,g={}){let I=new Ct;I.onError((o,D)=>{let h=o.message||String(o)||o.name||"unknown";process.stderr.write(`[domain-http] ${D.req.method} ${D.req.path} failed: ${h}
|
|
509
509
|
${o.stack??""}
|
|
510
510
|
`);let{status:y,headers:l}=rN(o);return D.json({error:{message:h}},y,l)}),I.use("/*",DN());let{injectWebSocket:Q,upgradeWebSocket:C}=rc({app:I}),B=A,i=null,e=()=>(B??=Ip(Cp(Qp(),"domain-objects-")),i??=ko.restore({dbDir:B,doWorkerEntry:g.doWorkerEntry}),i);return b0(I,e,C),q0(I,e),T0(I,e),oN(I,e),I.get("/health",o=>o.json({status:"ok",service:"domain",version:Bp})),{app:I,injectWebSocket:Q}}function aN(){return{port:Number(process.env.PORT??0),portFile:process.env.PLANX_DOMAIN_PORT_FILE,pidFile:process.env.PLANX_DOMAIN_PID_FILE,dbDir:process.env.PLANX_DOMAIN_DB_DIR}}import{existsSync as Ep}from"node:fs";import{fileURLToPath as wN}from"node:url";var cN="do-worker.mjs";function FN(A,g=()=>{}){let I=new URL(`./${cN}`,A);if(Ep(wN(I)))return I;g(`[domain] ${cN} not found next to ${wN(A)}; domain objects run on the main thread`)}import{renameSync as ip,rmSync as ep,writeFileSync as op}from"fs";var tp=0;function si(A,g){let I=`${A}.${process.pid}.${++tp}.tmp`;try{op(I,g,"utf-8"),ip(I,A)}catch(Q){throw ep(I,{force:!0}),Q}}function ga(A,g){si(A,String(g))}function Ia(A,g){si(A,String(g))}async function Dp(){let{port:A,portFile:g,pidFile:I,dbDir:Q}=aN();Q&&Di.mkdirSync(Q,{recursive:!0});let C=Q?sp(Q,"objects"):void 0,{app:B,injectWebSocket:i}=nN(C,{doWorkerEntry:FN(import.meta.url,o=>process.stderr.write(`${o}
|
|
511
511
|
`))}),e=await new Promise(o=>{let D=Ra({fetch:B.fetch,port:A,hostname:"127.0.0.1"},y=>o(y.port));i(D);let h=()=>{try{D.close?.()}catch{}if(I)try{Di.unlinkSync(I)}catch{}if(g)try{Di.unlinkSync(g)}catch{}process.exit(0)};process.on("SIGTERM",h),process.on("SIGINT",h)});g&&Ia(g,e),I&&ga(I,process.pid),process.stdout.write(JSON.stringify({service:"domain",port:e,pid:process.pid})+`
|