@jackchuka/gql-ingest 1.0.2 → 1.1.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/bin/cli.js CHANGED
@@ -1,2 +1,49 @@
1
1
  #!/usr/bin/env node
2
- "use strict";var R=Object.create;var u=Object.defineProperty;var L=Object.getOwnPropertyDescriptor;var F=Object.getOwnPropertyNames;var S=Object.getPrototypeOf,G=Object.prototype.hasOwnProperty;var Q=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var k=(t,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of F(e))!G.call(t,n)&&n!==r&&u(t,n,{get:()=>e[n],enumerable:!(s=L(e,n))||s.enumerable});return t};var a=(t,e,r)=>(r=t!=null?R(S(t)):{},k(e||!t||!t.__esModule?u(r,"default",{value:t,enumerable:!0}):r,t));var C=Q((A,x)=>{x.exports={name:"@jackchuka/gql-ingest",version:"1.0.2",description:"A CLI tool for ingesting data from CSV files into a GraphQL API",main:"dist/cli.js",bin:{"gql-ingest":"bin/cli.js"},scripts:{build:"node esbuild.config.js","build:types":"tsc --emitDeclarationOnly","build:all":"npm run build && npm run build:types",dev:"ts-node src/cli.ts",test:"jest","test:watch":"jest --watch",prepublishOnly:"npm run build:all"},keywords:["graphql","cli","csv","ingest","api"],author:"jackchuka",license:"MIT",repository:{type:"git",url:"https://github.com/jackchuka/gql-ingest.git"},dependencies:{commander:"^14.0.0","csv-parser":"^3.0.0","graphql-request":"^7.2.0"},devDependencies:{"@types/jest":"^30.0.0","@types/node":"^24.0.4",esbuild:"^0.25.5",jest:"^30.0.3","ts-jest":"^29.4.0","ts-node":"^10.9.0",typescript:"^5.3.0"},files:["dist/**/*","src/**/*"]}});var b=require("commander");var f=require("graphql-request"),c=class{constructor(e,r){this.client=new f.GraphQLClient(e,{headers:r||{}})}async executeMutation(e,r){try{return await this.client.request(e,r)}catch(s){throw console.error("GraphQL mutation failed:",s),s}}setHeaders(e){this.client.setHeaders(e)}};var p=a(require("fs")),o=a(require("path"));var v=a(require("fs")),y=a(require("csv-parser"));async function w(t){return new Promise((e,r)=>{let s=[];v.default.createReadStream(t).pipe((0,y.default)()).on("data",n=>s.push(n)).on("end",()=>e(s)).on("error",n=>r(n))})}var l=class{constructor(e,r=process.cwd()){this.client=e,this.basePath=r}discoverMappings(e){let r=o.default.resolve(this.basePath,e,"mappings");try{let n=p.default.readdirSync(r).filter(i=>i.endsWith(".json")).sort();return console.log(`Discovered ${n.length} mapping files: ${n.join(", ")}`),n.map(i=>o.default.join(e,"mappings",i))}catch(s){return console.error(`Error reading mappings directory ${r}:`,s),[]}}async processEntity(e){console.log(`Processing entity: ${e}`);let r=o.default.resolve(this.basePath,e),s=JSON.parse(p.default.readFileSync(r,"utf8")),n=o.default.dirname(o.default.dirname(r)),i=o.default.resolve(n,s.csvFile),g=await w(i),q=o.default.resolve(n,s.graphqlFile),P=p.default.readFileSync(q,"utf8");for(let m of g){let j=this.mapCsvRowToVariables(m,s.mapping);try{let d=await this.client.executeMutation(P,j);console.log("\u2713 Created entity with result:",d)}catch(d){console.error("\u2717 Failed to create entity for row:",m,d)}}}mapCsvRowToVariables(e,r){let s={};for(let[n,i]of Object.entries(r))e[i]!==void 0&&(s[n]=e[i]);return s}};var h=new b.Command;h.name("gql-ingest").description("A CLI tool for ingesting data from CSV files into a GraphQL API").version(C().version);h.requiredOption("-e, --endpoint <url>","GraphQL endpoint URL").requiredOption("-c, --config <path>","Path to configuration directory (containing data/, graphql/, mappings/ subdirectories)").option("-h, --headers <headers>","JSON string of headers to include in requests").action(async t=>{try{console.log("Starting seed data generation...");let e=t.headers?JSON.parse(t.headers):{},r=new c(t.endpoint,e),s=new l(r),n=s.discoverMappings(t.config);if(n.length===0){console.warn(`No mapping files found in ${t.config}/mappings`);return}for(let i of n)try{await s.processEntity(i)}catch(g){console.warn(`Warning: Could not process ${i}:`,g)}console.log("Seed data generation completed!")}catch(e){console.error("Error:",e),process.exit(1)}});h.parse();
2
+ var an=(e,n)=>()=>(n||e((n={exports:{}}).exports,n),n.exports);var un=an((fo,qr)=>{qr.exports={name:"@jackchuka/gql-ingest",version:"1.1.0",description:"A CLI tool for ingesting data from CSV files into a GraphQL API",type:"module",main:"dist/cli.js",bin:{"gql-ingest":"bin/cli.js"},scripts:{build:"node esbuild.config.js","build:types":"tsc --emitDeclarationOnly","build:all":"npm run build && npm run build:types",dev:"ts-node src/cli.ts",test:"jest","test:watch":"jest --watch",prepublishOnly:"npm run build:all"},keywords:["graphql","cli","csv","ingest","api"],author:"jackchuka",license:"MIT",repository:{type:"git",url:"https://github.com/jackchuka/gql-ingest.git"},dependencies:{commander:"^14.0.0","csv-parser":"^3.0.0","graphql-request":"^7.2.0","js-yaml":"^4.1.0"},devDependencies:{"@types/jest":"^30.0.0","@types/js-yaml":"^4.0.9","@types/node":"^24.0.4",esbuild:"^0.25.5",jest:"^30.0.3","ts-jest":"^29.4.0","ts-node":"^10.9.0",typescript:"^5.3.0"},files:["dist/**/*","src/**/*"]}});import{Command as Yr}from"commander";import{GraphQLClient as fn}from"graphql-request";var H=class{constructor(n,i,o,r=!1){this.client=new fn(n,{headers:i||{}}),this.metrics=o,this.verbose=r}async executeMutation(n,i){let o=Date.now();try{let r=await this.client.request(n,i);if(this.metrics){let l=Date.now()-o;this.metrics.recordRequestDuration(l)}return this.verbose&&console.log(`\u2713 GraphQL request completed in ${Date.now()-o}ms:`,r),r}catch(r){if(this.metrics){let l=Date.now()-o;this.metrics.recordRequestDuration(l)}throw this.verbose?console.error(`\u2717 GraphQL request failed in ${Date.now()-o}ms:`,r):console.error("GraphQL mutation failed:",r),r}}setHeaders(n){this.client.setHeaders(n)}};import J from"fs";import T from"path";import pn from"fs";import hn from"csv-parser";async function ge(e){return new Promise((n,i)=>{let o=[];pn.createReadStream(e).pipe(hn()).on("data",r=>o.push(r)).on("end",()=>n(o)).on("error",r=>i(r))})}var P=class{constructor(){this.metrics={totalEntities:0,totalSuccesses:0,totalFailures:0,entityMetrics:new Map,requestDurations:[],startTime:Date.now()}}startEntityProcessing(n){this.metrics.entityMetrics.has(n)||this.metrics.entityMetrics.set(n,{entityName:n,successCount:0,failureCount:0,startTime:Date.now()})}recordSuccess(n){let i=this.metrics.entityMetrics.get(n);i&&(i.successCount++,this.metrics.totalSuccesses++,this.metrics.totalEntities++)}recordFailure(n){let i=this.metrics.entityMetrics.get(n);i&&(i.failureCount++,this.metrics.totalFailures++,this.metrics.totalEntities++)}finishEntityProcessing(n){let i=this.metrics.entityMetrics.get(n);i&&(i.endTime=Date.now())}finishProcessing(){return this.metrics.endTime=Date.now(),{...this.metrics}}getEntityMetrics(n){return this.metrics.entityMetrics.get(n)}getTotalProcessed(){return this.metrics.totalEntities}getSuccessRate(){return this.metrics.totalEntities===0?0:this.metrics.totalSuccesses/this.metrics.totalEntities*100}recordRequestDuration(n){this.metrics.requestDurations.push(n)}getAverageRequestDuration(){return this.metrics.requestDurations.length===0?0:this.metrics.requestDurations.reduce((i,o)=>i+o,0)/this.metrics.requestDurations.length}getDurationMs(){return(this.metrics.endTime||Date.now())-this.metrics.startTime}generateSummary(){let n=this.getDurationMs(),i=this.getSuccessRate(),o=this.getAverageRequestDuration(),r=`
3
+ \u{1F4CA} Processing Summary:
4
+ `;if(r+=` Total Processed: ${this.metrics.totalEntities}
5
+ `,r+=` \u2713 Successes: ${this.metrics.totalSuccesses}
6
+ `,r+=` \u2717 Failures: ${this.metrics.totalFailures}
7
+ `,r+=` Success Rate: ${i.toFixed(1)}%
8
+ `,r+=` Duration: ${(n/1e3).toFixed(2)}s
9
+ `,this.metrics.requestDurations.length>0&&(r+=` Avg Request Time: ${o.toFixed(0)}ms
10
+ `),this.metrics.entityMetrics.size>1){r+=`
11
+ \u{1F4CB} Per-Entity Breakdown:
12
+ `;for(let[l,t]of this.metrics.entityMetrics){let c=t.successCount+t.failureCount,u=c>0?t.successCount/c*100:0,s=t.endTime?t.endTime-t.startTime:0;r+=` ${l}: ${c} total (${t.successCount} \u2713, ${t.failureCount} \u2717) - ${u.toFixed(1)}% success - ${(s/1e3).toFixed(2)}s
13
+ `}}return r}};var U=class{constructor(n,i=process.cwd(),o,r=!1){this.client=n,this.basePath=i,this.metrics=o||new P,this.verbose=r}discoverMappings(n){let i=T.resolve(this.basePath,n,"mappings");try{let r=J.readdirSync(i).filter(l=>l.endsWith(".json")).sort();return console.log(`Discovered ${r.length} mapping files: ${r.join(", ")}`),r.map(l=>T.join(n,"mappings",l))}catch(o){return console.error(`Error reading mappings directory ${i}:`,o),[]}}async processEntity(n,i){let o=T.basename(n,".json");console.log(`Processing entity: ${n}`),this.metrics.startEntityProcessing(o);let r=T.resolve(this.basePath,n),l=JSON.parse(J.readFileSync(r,"utf8")),t=T.dirname(T.dirname(r)),c=T.resolve(t,l.csvFile),u=await ge(c),s=T.resolve(t,l.graphqlFile),f=J.readFileSync(s,"utf8");i&&i.concurrency>1?await this.processRowsConcurrently(u,f,l.mapping,o,i):await this.processRowsSequentially(u,f,l.mapping,o),this.metrics.finishEntityProcessing(o)}async processRowsSequentially(n,i,o,r){let l=n.length;for(let t=0;t<n.length;t++){let c=n[t],u=this.mapCsvRowToVariables(c,o);try{if(await this.client.executeMutation(i,u),this.metrics.recordSuccess(r),!this.verbose&&((t+1)%Math.max(1,Math.floor(l/10))===0||t===l-1)){let s=((t+1)/l*100).toFixed(1);console.log(`\u{1F4CA} Progress: ${t+1}/${l} (${s}%) \u2713`)}}catch(s){this.metrics.recordFailure(r),this.verbose||console.error(`\u2717 Failed to create entity for row ${t+1}:`,c,s)}}}async processRowsConcurrently(n,i,o,r,l){let t=l.concurrency;console.log(`Processing ${n.length} rows with concurrency: ${t}`);let c=this.chunkArray(n,t),u=0,s=n.length;for(let f=0;f<c.length;f++){let a=c[f],h=a.map(async x=>{let b=this.mapCsvRowToVariables(x,o);try{let g=await this.client.executeMutation(i,b);return this.metrics.recordSuccess(r),{success:!0,result:g,row:x}}catch(g){return this.metrics.recordFailure(r),{success:!1,error:g,row:x}}}),d=await Promise.allSettled(h);u+=a.length;let m=0,v=0;if(d.forEach(x=>{if(x.status==="fulfilled"){let{success:b,error:g,row:sn}=x.value;b?m++:(v++,this.verbose||console.error("\u2717 Failed to create entity for row:",sn,g))}else v++,this.verbose||console.error("\u2717 Promise rejected:",x.reason)}),!this.verbose){let x=(u/s*100).toFixed(1);console.log(`\u{1F4CA} Progress: ${u}/${s} (${x}%) - Chunk ${f+1}: ${m} \u2713, ${v} \u2717`)}}}chunkArray(n,i){let o=[];for(let r=0;r<n.length;r+=i)o.push(n.slice(r,r+i));return o}mapCsvRowToVariables(n,i){let o={};for(let[r,l]of Object.entries(i))n[l]!==void 0&&(o[r]=n[l]);return o}getMetrics(){return this.metrics}};import on from"fs";import Nr from"path";function Ie(e){return typeof e>"u"||e===null}function dn(e){return typeof e=="object"&&e!==null}function gn(e){return Array.isArray(e)?e:Ie(e)?[]:[e]}function mn(e,n){var i,o,r,l;if(n)for(l=Object.keys(n),i=0,o=l.length;i<o;i+=1)r=l[i],e[r]=n[r];return e}function xn(e,n){var i="",o;for(o=0;o<n;o+=1)i+=e;return i}function vn(e){return e===0&&Number.NEGATIVE_INFINITY===1/e}var yn=Ie,An=dn,Cn=gn,wn=xn,bn=vn,En=mn,A={isNothing:yn,isObject:An,toArray:Cn,repeat:wn,isNegativeZero:bn,extend:En};function ke(e,n){var i="",o=e.reason||"(unknown reason)";return e.mark?(e.mark.name&&(i+='in "'+e.mark.name+'" '),i+="("+(e.mark.line+1)+":"+(e.mark.column+1)+")",!n&&e.mark.snippet&&(i+=`
14
+
15
+ `+e.mark.snippet),o+" "+i):o}function q(e,n){Error.call(this),this.name="YAMLException",this.reason=e,this.mark=n,this.message=ke(this,!1),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack||""}q.prototype=Object.create(Error.prototype);q.prototype.constructor=q;q.prototype.toString=function(n){return this.name+": "+ke(this,n)};var E=q;function ee(e,n,i,o,r){var l="",t="",c=Math.floor(r/2)-1;return o-n>c&&(l=" ... ",n=o-c+l.length),i-o>c&&(t=" ...",i=o+c-t.length),{str:l+e.slice(n,i).replace(/\t/g,"\u2192")+t,pos:o-n+l.length}}function ne(e,n){return A.repeat(" ",n-e.length)+e}function Sn(e,n){if(n=Object.create(n||null),!e.buffer)return null;n.maxLength||(n.maxLength=79),typeof n.indent!="number"&&(n.indent=1),typeof n.linesBefore!="number"&&(n.linesBefore=3),typeof n.linesAfter!="number"&&(n.linesAfter=2);for(var i=/\r?\n|\r|\0/g,o=[0],r=[],l,t=-1;l=i.exec(e.buffer);)r.push(l.index),o.push(l.index+l[0].length),e.position<=l.index&&t<0&&(t=o.length-2);t<0&&(t=o.length-1);var c="",u,s,f=Math.min(e.line+n.linesAfter,r.length).toString().length,a=n.maxLength-(n.indent+f+3);for(u=1;u<=n.linesBefore&&!(t-u<0);u++)s=ee(e.buffer,o[t-u],r[t-u],e.position-(o[t]-o[t-u]),a),c=A.repeat(" ",n.indent)+ne((e.line-u+1).toString(),f)+" | "+s.str+`
16
+ `+c;for(s=ee(e.buffer,o[t],r[t],e.position,a),c+=A.repeat(" ",n.indent)+ne((e.line+1).toString(),f)+" | "+s.str+`
17
+ `,c+=A.repeat("-",n.indent+f+3+s.pos)+`^
18
+ `,u=1;u<=n.linesAfter&&!(t+u>=r.length);u++)s=ee(e.buffer,o[t+u],r[t+u],e.position-(o[t]-o[t+u]),a),c+=A.repeat(" ",n.indent)+ne((e.line+u+1).toString(),f)+" | "+s.str+`
19
+ `;return c.replace(/\n$/,"")}var _n=Sn,Fn=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],Tn=["scalar","sequence","mapping"];function On(e){var n={};return e!==null&&Object.keys(e).forEach(function(i){e[i].forEach(function(o){n[String(o)]=i})}),n}function Ln(e,n){if(n=n||{},Object.keys(n).forEach(function(i){if(Fn.indexOf(i)===-1)throw new E('Unknown option "'+i+'" is met in definition of "'+e+'" YAML type.')}),this.options=n,this.tag=e,this.kind=n.kind||null,this.resolve=n.resolve||function(){return!0},this.construct=n.construct||function(i){return i},this.instanceOf=n.instanceOf||null,this.predicate=n.predicate||null,this.represent=n.represent||null,this.representName=n.representName||null,this.defaultStyle=n.defaultStyle||null,this.multi=n.multi||!1,this.styleAliases=On(n.styleAliases||null),Tn.indexOf(this.kind)===-1)throw new E('Unknown kind "'+this.kind+'" is specified for "'+e+'" YAML type.')}var C=Ln;function me(e,n){var i=[];return e[n].forEach(function(o){var r=i.length;i.forEach(function(l,t){l.tag===o.tag&&l.kind===o.kind&&l.multi===o.multi&&(r=t)}),i[r]=o}),i}function In(){var e={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}},n,i;function o(r){r.multi?(e.multi[r.kind].push(r),e.multi.fallback.push(r)):e[r.kind][r.tag]=e.fallback[r.tag]=r}for(n=0,i=arguments.length;n<i;n+=1)arguments[n].forEach(o);return e}function re(e){return this.extend(e)}re.prototype.extend=function(n){var i=[],o=[];if(n instanceof C)o.push(n);else if(Array.isArray(n))o=o.concat(n);else if(n&&(Array.isArray(n.implicit)||Array.isArray(n.explicit)))n.implicit&&(i=i.concat(n.implicit)),n.explicit&&(o=o.concat(n.explicit));else throw new E("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");i.forEach(function(l){if(!(l instanceof C))throw new E("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(l.loadKind&&l.loadKind!=="scalar")throw new E("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");if(l.multi)throw new E("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.")}),o.forEach(function(l){if(!(l instanceof C))throw new E("Specified list of YAML types (or a single Type object) contains a non-Type object.")});var r=Object.create(re.prototype);return r.implicit=(this.implicit||[]).concat(i),r.explicit=(this.explicit||[]).concat(o),r.compiledImplicit=me(r,"implicit"),r.compiledExplicit=me(r,"explicit"),r.compiledTypeMap=In(r.compiledImplicit,r.compiledExplicit),r};var kn=re,Pn=new C("tag:yaml.org,2002:str",{kind:"scalar",construct:function(e){return e!==null?e:""}}),Rn=new C("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(e){return e!==null?e:[]}}),Mn=new C("tag:yaml.org,2002:map",{kind:"mapping",construct:function(e){return e!==null?e:{}}}),Dn=new kn({explicit:[Pn,Rn,Mn]});function Nn(e){if(e===null)return!0;var n=e.length;return n===1&&e==="~"||n===4&&(e==="null"||e==="Null"||e==="NULL")}function jn(){return null}function qn(e){return e===null}var Yn=new C("tag:yaml.org,2002:null",{kind:"scalar",resolve:Nn,construct:jn,predicate:qn,represent:{canonical:function(){return"~"},lowercase:function(){return"null"},uppercase:function(){return"NULL"},camelcase:function(){return"Null"},empty:function(){return""}},defaultStyle:"lowercase"});function $n(e){if(e===null)return!1;var n=e.length;return n===4&&(e==="true"||e==="True"||e==="TRUE")||n===5&&(e==="false"||e==="False"||e==="FALSE")}function Bn(e){return e==="true"||e==="True"||e==="TRUE"}function Hn(e){return Object.prototype.toString.call(e)==="[object Boolean]"}var Un=new C("tag:yaml.org,2002:bool",{kind:"scalar",resolve:$n,construct:Bn,predicate:Hn,represent:{lowercase:function(e){return e?"true":"false"},uppercase:function(e){return e?"TRUE":"FALSE"},camelcase:function(e){return e?"True":"False"}},defaultStyle:"lowercase"});function Gn(e){return 48<=e&&e<=57||65<=e&&e<=70||97<=e&&e<=102}function Wn(e){return 48<=e&&e<=55}function Kn(e){return 48<=e&&e<=57}function Qn(e){if(e===null)return!1;var n=e.length,i=0,o=!1,r;if(!n)return!1;if(r=e[i],(r==="-"||r==="+")&&(r=e[++i]),r==="0"){if(i+1===n)return!0;if(r=e[++i],r==="b"){for(i++;i<n;i++)if(r=e[i],r!=="_"){if(r!=="0"&&r!=="1")return!1;o=!0}return o&&r!=="_"}if(r==="x"){for(i++;i<n;i++)if(r=e[i],r!=="_"){if(!Gn(e.charCodeAt(i)))return!1;o=!0}return o&&r!=="_"}if(r==="o"){for(i++;i<n;i++)if(r=e[i],r!=="_"){if(!Wn(e.charCodeAt(i)))return!1;o=!0}return o&&r!=="_"}}if(r==="_")return!1;for(;i<n;i++)if(r=e[i],r!=="_"){if(!Kn(e.charCodeAt(i)))return!1;o=!0}return!(!o||r==="_")}function Vn(e){var n=e,i=1,o;if(n.indexOf("_")!==-1&&(n=n.replace(/_/g,"")),o=n[0],(o==="-"||o==="+")&&(o==="-"&&(i=-1),n=n.slice(1),o=n[0]),n==="0")return 0;if(o==="0"){if(n[1]==="b")return i*parseInt(n.slice(2),2);if(n[1]==="x")return i*parseInt(n.slice(2),16);if(n[1]==="o")return i*parseInt(n.slice(2),8)}return i*parseInt(n,10)}function Xn(e){return Object.prototype.toString.call(e)==="[object Number]"&&e%1===0&&!A.isNegativeZero(e)}var zn=new C("tag:yaml.org,2002:int",{kind:"scalar",resolve:Qn,construct:Vn,predicate:Xn,represent:{binary:function(e){return e>=0?"0b"+e.toString(2):"-0b"+e.toString(2).slice(1)},octal:function(e){return e>=0?"0o"+e.toString(8):"-0o"+e.toString(8).slice(1)},decimal:function(e){return e.toString(10)},hexadecimal:function(e){return e>=0?"0x"+e.toString(16).toUpperCase():"-0x"+e.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),Zn=new RegExp("^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function Jn(e){return!(e===null||!Zn.test(e)||e[e.length-1]==="_")}function ei(e){var n,i;return n=e.replace(/_/g,"").toLowerCase(),i=n[0]==="-"?-1:1,"+-".indexOf(n[0])>=0&&(n=n.slice(1)),n===".inf"?i===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:n===".nan"?NaN:i*parseFloat(n,10)}var ni=/^[-+]?[0-9]+e/;function ii(e,n){var i;if(isNaN(e))switch(n){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===e)switch(n){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===e)switch(n){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(A.isNegativeZero(e))return"-0.0";return i=e.toString(10),ni.test(i)?i.replace("e",".e"):i}function ri(e){return Object.prototype.toString.call(e)==="[object Number]"&&(e%1!==0||A.isNegativeZero(e))}var oi=new C("tag:yaml.org,2002:float",{kind:"scalar",resolve:Jn,construct:ei,predicate:ri,represent:ii,defaultStyle:"lowercase"}),ti=Dn.extend({implicit:[Yn,Un,zn,oi]}),li=ti,Pe=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),Re=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");function ci(e){return e===null?!1:Pe.exec(e)!==null||Re.exec(e)!==null}function ui(e){var n,i,o,r,l,t,c,u=0,s=null,f,a,h;if(n=Pe.exec(e),n===null&&(n=Re.exec(e)),n===null)throw new Error("Date resolve error");if(i=+n[1],o=+n[2]-1,r=+n[3],!n[4])return new Date(Date.UTC(i,o,r));if(l=+n[4],t=+n[5],c=+n[6],n[7]){for(u=n[7].slice(0,3);u.length<3;)u+="0";u=+u}return n[9]&&(f=+n[10],a=+(n[11]||0),s=(f*60+a)*6e4,n[9]==="-"&&(s=-s)),h=new Date(Date.UTC(i,o,r,l,t,c,u)),s&&h.setTime(h.getTime()-s),h}function si(e){return e.toISOString()}var ai=new C("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:ci,construct:ui,instanceOf:Date,represent:si});function fi(e){return e==="<<"||e===null}var pi=new C("tag:yaml.org,2002:merge",{kind:"scalar",resolve:fi}),ue=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
20
+ \r`;function hi(e){if(e===null)return!1;var n,i,o=0,r=e.length,l=ue;for(i=0;i<r;i++)if(n=l.indexOf(e.charAt(i)),!(n>64)){if(n<0)return!1;o+=6}return o%8===0}function di(e){var n,i,o=e.replace(/[\r\n=]/g,""),r=o.length,l=ue,t=0,c=[];for(n=0;n<r;n++)n%4===0&&n&&(c.push(t>>16&255),c.push(t>>8&255),c.push(t&255)),t=t<<6|l.indexOf(o.charAt(n));return i=r%4*6,i===0?(c.push(t>>16&255),c.push(t>>8&255),c.push(t&255)):i===18?(c.push(t>>10&255),c.push(t>>2&255)):i===12&&c.push(t>>4&255),new Uint8Array(c)}function gi(e){var n="",i=0,o,r,l=e.length,t=ue;for(o=0;o<l;o++)o%3===0&&o&&(n+=t[i>>18&63],n+=t[i>>12&63],n+=t[i>>6&63],n+=t[i&63]),i=(i<<8)+e[o];return r=l%3,r===0?(n+=t[i>>18&63],n+=t[i>>12&63],n+=t[i>>6&63],n+=t[i&63]):r===2?(n+=t[i>>10&63],n+=t[i>>4&63],n+=t[i<<2&63],n+=t[64]):r===1&&(n+=t[i>>2&63],n+=t[i<<4&63],n+=t[64],n+=t[64]),n}function mi(e){return Object.prototype.toString.call(e)==="[object Uint8Array]"}var xi=new C("tag:yaml.org,2002:binary",{kind:"scalar",resolve:hi,construct:di,predicate:mi,represent:gi}),vi=Object.prototype.hasOwnProperty,yi=Object.prototype.toString;function Ai(e){if(e===null)return!0;var n=[],i,o,r,l,t,c=e;for(i=0,o=c.length;i<o;i+=1){if(r=c[i],t=!1,yi.call(r)!=="[object Object]")return!1;for(l in r)if(vi.call(r,l))if(!t)t=!0;else return!1;if(!t)return!1;if(n.indexOf(l)===-1)n.push(l);else return!1}return!0}function Ci(e){return e!==null?e:[]}var wi=new C("tag:yaml.org,2002:omap",{kind:"sequence",resolve:Ai,construct:Ci}),bi=Object.prototype.toString;function Ei(e){if(e===null)return!0;var n,i,o,r,l,t=e;for(l=new Array(t.length),n=0,i=t.length;n<i;n+=1){if(o=t[n],bi.call(o)!=="[object Object]"||(r=Object.keys(o),r.length!==1))return!1;l[n]=[r[0],o[r[0]]]}return!0}function Si(e){if(e===null)return[];var n,i,o,r,l,t=e;for(l=new Array(t.length),n=0,i=t.length;n<i;n+=1)o=t[n],r=Object.keys(o),l[n]=[r[0],o[r[0]]];return l}var _i=new C("tag:yaml.org,2002:pairs",{kind:"sequence",resolve:Ei,construct:Si}),Fi=Object.prototype.hasOwnProperty;function Ti(e){if(e===null)return!0;var n,i=e;for(n in i)if(Fi.call(i,n)&&i[n]!==null)return!1;return!0}function Oi(e){return e!==null?e:{}}var Li=new C("tag:yaml.org,2002:set",{kind:"mapping",resolve:Ti,construct:Oi}),Me=li.extend({implicit:[ai,pi],explicit:[xi,wi,_i,Li]}),L=Object.prototype.hasOwnProperty,G=1,De=2,Ne=3,W=4,ie=1,Ii=2,xe=3,ki=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,Pi=/[\x85\u2028\u2029]/,Ri=/[,\[\]\{\}]/,je=/^(?:!|!!|![a-z\-]+!)$/i,qe=/^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;function ve(e){return Object.prototype.toString.call(e)}function _(e){return e===10||e===13}function k(e){return e===9||e===32}function S(e){return e===9||e===32||e===10||e===13}function M(e){return e===44||e===91||e===93||e===123||e===125}function Mi(e){var n;return 48<=e&&e<=57?e-48:(n=e|32,97<=n&&n<=102?n-97+10:-1)}function Di(e){return e===120?2:e===117?4:e===85?8:0}function Ni(e){return 48<=e&&e<=57?e-48:-1}function ye(e){return e===48?"\0":e===97?"\x07":e===98?"\b":e===116||e===9?" ":e===110?`
21
+ `:e===118?"\v":e===102?"\f":e===114?"\r":e===101?"\x1B":e===32?" ":e===34?'"':e===47?"/":e===92?"\\":e===78?"\x85":e===95?"\xA0":e===76?"\u2028":e===80?"\u2029":""}function ji(e){return e<=65535?String.fromCharCode(e):String.fromCharCode((e-65536>>10)+55296,(e-65536&1023)+56320)}var Ye=new Array(256),$e=new Array(256);for(I=0;I<256;I++)Ye[I]=ye(I)?1:0,$e[I]=ye(I);var I;function qi(e,n){this.input=e,this.filename=n.filename||null,this.schema=n.schema||Me,this.onWarning=n.onWarning||null,this.legacy=n.legacy||!1,this.json=n.json||!1,this.listener=n.listener||null,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=e.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.firstTabInLine=-1,this.documents=[]}function Be(e,n){var i={name:e.filename,buffer:e.input.slice(0,-1),position:e.position,line:e.line,column:e.position-e.lineStart};return i.snippet=_n(i),new E(n,i)}function p(e,n){throw Be(e,n)}function K(e,n){e.onWarning&&e.onWarning.call(null,Be(e,n))}var Ae={YAML:function(n,i,o){var r,l,t;n.version!==null&&p(n,"duplication of %YAML directive"),o.length!==1&&p(n,"YAML directive accepts exactly one argument"),r=/^([0-9]+)\.([0-9]+)$/.exec(o[0]),r===null&&p(n,"ill-formed argument of the YAML directive"),l=parseInt(r[1],10),t=parseInt(r[2],10),l!==1&&p(n,"unacceptable YAML version of the document"),n.version=o[0],n.checkLineBreaks=t<2,t!==1&&t!==2&&K(n,"unsupported YAML version of the document")},TAG:function(n,i,o){var r,l;o.length!==2&&p(n,"TAG directive accepts exactly two arguments"),r=o[0],l=o[1],je.test(r)||p(n,"ill-formed tag handle (first argument) of the TAG directive"),L.call(n.tagMap,r)&&p(n,'there is a previously declared suffix for "'+r+'" tag handle'),qe.test(l)||p(n,"ill-formed tag prefix (second argument) of the TAG directive");try{l=decodeURIComponent(l)}catch{p(n,"tag prefix is malformed: "+l)}n.tagMap[r]=l}};function O(e,n,i,o){var r,l,t,c;if(n<i){if(c=e.input.slice(n,i),o)for(r=0,l=c.length;r<l;r+=1)t=c.charCodeAt(r),t===9||32<=t&&t<=1114111||p(e,"expected valid JSON character");else ki.test(c)&&p(e,"the stream contains non-printable characters");e.result+=c}}function Ce(e,n,i,o){var r,l,t,c;for(A.isObject(i)||p(e,"cannot merge mappings; the provided source object is unacceptable"),r=Object.keys(i),t=0,c=r.length;t<c;t+=1)l=r[t],L.call(n,l)||(n[l]=i[l],o[l]=!0)}function D(e,n,i,o,r,l,t,c,u){var s,f;if(Array.isArray(r))for(r=Array.prototype.slice.call(r),s=0,f=r.length;s<f;s+=1)Array.isArray(r[s])&&p(e,"nested arrays are not supported inside keys"),typeof r=="object"&&ve(r[s])==="[object Object]"&&(r[s]="[object Object]");if(typeof r=="object"&&ve(r)==="[object Object]"&&(r="[object Object]"),r=String(r),n===null&&(n={}),o==="tag:yaml.org,2002:merge")if(Array.isArray(l))for(s=0,f=l.length;s<f;s+=1)Ce(e,n,l[s],i);else Ce(e,n,l,i);else!e.json&&!L.call(i,r)&&L.call(n,r)&&(e.line=t||e.line,e.lineStart=c||e.lineStart,e.position=u||e.position,p(e,"duplicated mapping key")),r==="__proto__"?Object.defineProperty(n,r,{configurable:!0,enumerable:!0,writable:!0,value:l}):n[r]=l,delete i[r];return n}function se(e){var n;n=e.input.charCodeAt(e.position),n===10?e.position++:n===13?(e.position++,e.input.charCodeAt(e.position)===10&&e.position++):p(e,"a line break is expected"),e.line+=1,e.lineStart=e.position,e.firstTabInLine=-1}function y(e,n,i){for(var o=0,r=e.input.charCodeAt(e.position);r!==0;){for(;k(r);)r===9&&e.firstTabInLine===-1&&(e.firstTabInLine=e.position),r=e.input.charCodeAt(++e.position);if(n&&r===35)do r=e.input.charCodeAt(++e.position);while(r!==10&&r!==13&&r!==0);if(_(r))for(se(e),r=e.input.charCodeAt(e.position),o++,e.lineIndent=0;r===32;)e.lineIndent++,r=e.input.charCodeAt(++e.position);else break}return i!==-1&&o!==0&&e.lineIndent<i&&K(e,"deficient indentation"),o}function X(e){var n=e.position,i;return i=e.input.charCodeAt(n),!!((i===45||i===46)&&i===e.input.charCodeAt(n+1)&&i===e.input.charCodeAt(n+2)&&(n+=3,i=e.input.charCodeAt(n),i===0||S(i)))}function ae(e,n){n===1?e.result+=" ":n>1&&(e.result+=A.repeat(`
22
+ `,n-1))}function Yi(e,n,i){var o,r,l,t,c,u,s,f,a=e.kind,h=e.result,d;if(d=e.input.charCodeAt(e.position),S(d)||M(d)||d===35||d===38||d===42||d===33||d===124||d===62||d===39||d===34||d===37||d===64||d===96||(d===63||d===45)&&(r=e.input.charCodeAt(e.position+1),S(r)||i&&M(r)))return!1;for(e.kind="scalar",e.result="",l=t=e.position,c=!1;d!==0;){if(d===58){if(r=e.input.charCodeAt(e.position+1),S(r)||i&&M(r))break}else if(d===35){if(o=e.input.charCodeAt(e.position-1),S(o))break}else{if(e.position===e.lineStart&&X(e)||i&&M(d))break;if(_(d))if(u=e.line,s=e.lineStart,f=e.lineIndent,y(e,!1,-1),e.lineIndent>=n){c=!0,d=e.input.charCodeAt(e.position);continue}else{e.position=t,e.line=u,e.lineStart=s,e.lineIndent=f;break}}c&&(O(e,l,t,!1),ae(e,e.line-u),l=t=e.position,c=!1),k(d)||(t=e.position+1),d=e.input.charCodeAt(++e.position)}return O(e,l,t,!1),e.result?!0:(e.kind=a,e.result=h,!1)}function $i(e,n){var i,o,r;if(i=e.input.charCodeAt(e.position),i!==39)return!1;for(e.kind="scalar",e.result="",e.position++,o=r=e.position;(i=e.input.charCodeAt(e.position))!==0;)if(i===39)if(O(e,o,e.position,!0),i=e.input.charCodeAt(++e.position),i===39)o=e.position,e.position++,r=e.position;else return!0;else _(i)?(O(e,o,r,!0),ae(e,y(e,!1,n)),o=r=e.position):e.position===e.lineStart&&X(e)?p(e,"unexpected end of the document within a single quoted scalar"):(e.position++,r=e.position);p(e,"unexpected end of the stream within a single quoted scalar")}function Bi(e,n){var i,o,r,l,t,c;if(c=e.input.charCodeAt(e.position),c!==34)return!1;for(e.kind="scalar",e.result="",e.position++,i=o=e.position;(c=e.input.charCodeAt(e.position))!==0;){if(c===34)return O(e,i,e.position,!0),e.position++,!0;if(c===92){if(O(e,i,e.position,!0),c=e.input.charCodeAt(++e.position),_(c))y(e,!1,n);else if(c<256&&Ye[c])e.result+=$e[c],e.position++;else if((t=Di(c))>0){for(r=t,l=0;r>0;r--)c=e.input.charCodeAt(++e.position),(t=Mi(c))>=0?l=(l<<4)+t:p(e,"expected hexadecimal character");e.result+=ji(l),e.position++}else p(e,"unknown escape sequence");i=o=e.position}else _(c)?(O(e,i,o,!0),ae(e,y(e,!1,n)),i=o=e.position):e.position===e.lineStart&&X(e)?p(e,"unexpected end of the document within a double quoted scalar"):(e.position++,o=e.position)}p(e,"unexpected end of the stream within a double quoted scalar")}function Hi(e,n){var i=!0,o,r,l,t=e.tag,c,u=e.anchor,s,f,a,h,d,m=Object.create(null),v,x,b,g;if(g=e.input.charCodeAt(e.position),g===91)f=93,d=!1,c=[];else if(g===123)f=125,d=!0,c={};else return!1;for(e.anchor!==null&&(e.anchorMap[e.anchor]=c),g=e.input.charCodeAt(++e.position);g!==0;){if(y(e,!0,n),g=e.input.charCodeAt(e.position),g===f)return e.position++,e.tag=t,e.anchor=u,e.kind=d?"mapping":"sequence",e.result=c,!0;i?g===44&&p(e,"expected the node content, but found ','"):p(e,"missed comma between flow collection entries"),x=v=b=null,a=h=!1,g===63&&(s=e.input.charCodeAt(e.position+1),S(s)&&(a=h=!0,e.position++,y(e,!0,n))),o=e.line,r=e.lineStart,l=e.position,N(e,n,G,!1,!0),x=e.tag,v=e.result,y(e,!0,n),g=e.input.charCodeAt(e.position),(h||e.line===o)&&g===58&&(a=!0,g=e.input.charCodeAt(++e.position),y(e,!0,n),N(e,n,G,!1,!0),b=e.result),d?D(e,c,m,x,v,b,o,r,l):a?c.push(D(e,null,m,x,v,b,o,r,l)):c.push(v),y(e,!0,n),g=e.input.charCodeAt(e.position),g===44?(i=!0,g=e.input.charCodeAt(++e.position)):i=!1}p(e,"unexpected end of the stream within a flow collection")}function Ui(e,n){var i,o,r=ie,l=!1,t=!1,c=n,u=0,s=!1,f,a;if(a=e.input.charCodeAt(e.position),a===124)o=!1;else if(a===62)o=!0;else return!1;for(e.kind="scalar",e.result="";a!==0;)if(a=e.input.charCodeAt(++e.position),a===43||a===45)ie===r?r=a===43?xe:Ii:p(e,"repeat of a chomping mode identifier");else if((f=Ni(a))>=0)f===0?p(e,"bad explicit indentation width of a block scalar; it cannot be less than one"):t?p(e,"repeat of an indentation width identifier"):(c=n+f-1,t=!0);else break;if(k(a)){do a=e.input.charCodeAt(++e.position);while(k(a));if(a===35)do a=e.input.charCodeAt(++e.position);while(!_(a)&&a!==0)}for(;a!==0;){for(se(e),e.lineIndent=0,a=e.input.charCodeAt(e.position);(!t||e.lineIndent<c)&&a===32;)e.lineIndent++,a=e.input.charCodeAt(++e.position);if(!t&&e.lineIndent>c&&(c=e.lineIndent),_(a)){u++;continue}if(e.lineIndent<c){r===xe?e.result+=A.repeat(`
23
+ `,l?1+u:u):r===ie&&l&&(e.result+=`
24
+ `);break}for(o?k(a)?(s=!0,e.result+=A.repeat(`
25
+ `,l?1+u:u)):s?(s=!1,e.result+=A.repeat(`
26
+ `,u+1)):u===0?l&&(e.result+=" "):e.result+=A.repeat(`
27
+ `,u):e.result+=A.repeat(`
28
+ `,l?1+u:u),l=!0,t=!0,u=0,i=e.position;!_(a)&&a!==0;)a=e.input.charCodeAt(++e.position);O(e,i,e.position,!1)}return!0}function we(e,n){var i,o=e.tag,r=e.anchor,l=[],t,c=!1,u;if(e.firstTabInLine!==-1)return!1;for(e.anchor!==null&&(e.anchorMap[e.anchor]=l),u=e.input.charCodeAt(e.position);u!==0&&(e.firstTabInLine!==-1&&(e.position=e.firstTabInLine,p(e,"tab characters must not be used in indentation")),!(u!==45||(t=e.input.charCodeAt(e.position+1),!S(t))));){if(c=!0,e.position++,y(e,!0,-1)&&e.lineIndent<=n){l.push(null),u=e.input.charCodeAt(e.position);continue}if(i=e.line,N(e,n,Ne,!1,!0),l.push(e.result),y(e,!0,-1),u=e.input.charCodeAt(e.position),(e.line===i||e.lineIndent>n)&&u!==0)p(e,"bad indentation of a sequence entry");else if(e.lineIndent<n)break}return c?(e.tag=o,e.anchor=r,e.kind="sequence",e.result=l,!0):!1}function Gi(e,n,i){var o,r,l,t,c,u,s=e.tag,f=e.anchor,a={},h=Object.create(null),d=null,m=null,v=null,x=!1,b=!1,g;if(e.firstTabInLine!==-1)return!1;for(e.anchor!==null&&(e.anchorMap[e.anchor]=a),g=e.input.charCodeAt(e.position);g!==0;){if(!x&&e.firstTabInLine!==-1&&(e.position=e.firstTabInLine,p(e,"tab characters must not be used in indentation")),o=e.input.charCodeAt(e.position+1),l=e.line,(g===63||g===58)&&S(o))g===63?(x&&(D(e,a,h,d,m,null,t,c,u),d=m=v=null),b=!0,x=!0,r=!0):x?(x=!1,r=!0):p(e,"incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line"),e.position+=1,g=o;else{if(t=e.line,c=e.lineStart,u=e.position,!N(e,i,De,!1,!0))break;if(e.line===l){for(g=e.input.charCodeAt(e.position);k(g);)g=e.input.charCodeAt(++e.position);if(g===58)g=e.input.charCodeAt(++e.position),S(g)||p(e,"a whitespace character is expected after the key-value separator within a block mapping"),x&&(D(e,a,h,d,m,null,t,c,u),d=m=v=null),b=!0,x=!1,r=!1,d=e.tag,m=e.result;else if(b)p(e,"can not read an implicit mapping pair; a colon is missed");else return e.tag=s,e.anchor=f,!0}else if(b)p(e,"can not read a block mapping entry; a multiline key may not be an implicit key");else return e.tag=s,e.anchor=f,!0}if((e.line===l||e.lineIndent>n)&&(x&&(t=e.line,c=e.lineStart,u=e.position),N(e,n,W,!0,r)&&(x?m=e.result:v=e.result),x||(D(e,a,h,d,m,v,t,c,u),d=m=v=null),y(e,!0,-1),g=e.input.charCodeAt(e.position)),(e.line===l||e.lineIndent>n)&&g!==0)p(e,"bad indentation of a mapping entry");else if(e.lineIndent<n)break}return x&&D(e,a,h,d,m,null,t,c,u),b&&(e.tag=s,e.anchor=f,e.kind="mapping",e.result=a),b}function Wi(e){var n,i=!1,o=!1,r,l,t;if(t=e.input.charCodeAt(e.position),t!==33)return!1;if(e.tag!==null&&p(e,"duplication of a tag property"),t=e.input.charCodeAt(++e.position),t===60?(i=!0,t=e.input.charCodeAt(++e.position)):t===33?(o=!0,r="!!",t=e.input.charCodeAt(++e.position)):r="!",n=e.position,i){do t=e.input.charCodeAt(++e.position);while(t!==0&&t!==62);e.position<e.length?(l=e.input.slice(n,e.position),t=e.input.charCodeAt(++e.position)):p(e,"unexpected end of the stream within a verbatim tag")}else{for(;t!==0&&!S(t);)t===33&&(o?p(e,"tag suffix cannot contain exclamation marks"):(r=e.input.slice(n-1,e.position+1),je.test(r)||p(e,"named tag handle cannot contain such characters"),o=!0,n=e.position+1)),t=e.input.charCodeAt(++e.position);l=e.input.slice(n,e.position),Ri.test(l)&&p(e,"tag suffix cannot contain flow indicator characters")}l&&!qe.test(l)&&p(e,"tag name cannot contain such characters: "+l);try{l=decodeURIComponent(l)}catch{p(e,"tag name is malformed: "+l)}return i?e.tag=l:L.call(e.tagMap,r)?e.tag=e.tagMap[r]+l:r==="!"?e.tag="!"+l:r==="!!"?e.tag="tag:yaml.org,2002:"+l:p(e,'undeclared tag handle "'+r+'"'),!0}function Ki(e){var n,i;if(i=e.input.charCodeAt(e.position),i!==38)return!1;for(e.anchor!==null&&p(e,"duplication of an anchor property"),i=e.input.charCodeAt(++e.position),n=e.position;i!==0&&!S(i)&&!M(i);)i=e.input.charCodeAt(++e.position);return e.position===n&&p(e,"name of an anchor node must contain at least one character"),e.anchor=e.input.slice(n,e.position),!0}function Qi(e){var n,i,o;if(o=e.input.charCodeAt(e.position),o!==42)return!1;for(o=e.input.charCodeAt(++e.position),n=e.position;o!==0&&!S(o)&&!M(o);)o=e.input.charCodeAt(++e.position);return e.position===n&&p(e,"name of an alias node must contain at least one character"),i=e.input.slice(n,e.position),L.call(e.anchorMap,i)||p(e,'unidentified alias "'+i+'"'),e.result=e.anchorMap[i],y(e,!0,-1),!0}function N(e,n,i,o,r){var l,t,c,u=1,s=!1,f=!1,a,h,d,m,v,x;if(e.listener!==null&&e.listener("open",e),e.tag=null,e.anchor=null,e.kind=null,e.result=null,l=t=c=W===i||Ne===i,o&&y(e,!0,-1)&&(s=!0,e.lineIndent>n?u=1:e.lineIndent===n?u=0:e.lineIndent<n&&(u=-1)),u===1)for(;Wi(e)||Ki(e);)y(e,!0,-1)?(s=!0,c=l,e.lineIndent>n?u=1:e.lineIndent===n?u=0:e.lineIndent<n&&(u=-1)):c=!1;if(c&&(c=s||r),(u===1||W===i)&&(G===i||De===i?v=n:v=n+1,x=e.position-e.lineStart,u===1?c&&(we(e,x)||Gi(e,x,v))||Hi(e,v)?f=!0:(t&&Ui(e,v)||$i(e,v)||Bi(e,v)?f=!0:Qi(e)?(f=!0,(e.tag!==null||e.anchor!==null)&&p(e,"alias node should not have any properties")):Yi(e,v,G===i)&&(f=!0,e.tag===null&&(e.tag="?")),e.anchor!==null&&(e.anchorMap[e.anchor]=e.result)):u===0&&(f=c&&we(e,x))),e.tag===null)e.anchor!==null&&(e.anchorMap[e.anchor]=e.result);else if(e.tag==="?"){for(e.result!==null&&e.kind!=="scalar"&&p(e,'unacceptable node kind for !<?> tag; it should be "scalar", not "'+e.kind+'"'),a=0,h=e.implicitTypes.length;a<h;a+=1)if(m=e.implicitTypes[a],m.resolve(e.result)){e.result=m.construct(e.result),e.tag=m.tag,e.anchor!==null&&(e.anchorMap[e.anchor]=e.result);break}}else if(e.tag!=="!"){if(L.call(e.typeMap[e.kind||"fallback"],e.tag))m=e.typeMap[e.kind||"fallback"][e.tag];else for(m=null,d=e.typeMap.multi[e.kind||"fallback"],a=0,h=d.length;a<h;a+=1)if(e.tag.slice(0,d[a].tag.length)===d[a].tag){m=d[a];break}m||p(e,"unknown tag !<"+e.tag+">"),e.result!==null&&m.kind!==e.kind&&p(e,"unacceptable node kind for !<"+e.tag+'> tag; it should be "'+m.kind+'", not "'+e.kind+'"'),m.resolve(e.result,e.tag)?(e.result=m.construct(e.result,e.tag),e.anchor!==null&&(e.anchorMap[e.anchor]=e.result)):p(e,"cannot resolve a node with !<"+e.tag+"> explicit tag")}return e.listener!==null&&e.listener("close",e),e.tag!==null||e.anchor!==null||f}function Vi(e){var n=e.position,i,o,r,l=!1,t;for(e.version=null,e.checkLineBreaks=e.legacy,e.tagMap=Object.create(null),e.anchorMap=Object.create(null);(t=e.input.charCodeAt(e.position))!==0&&(y(e,!0,-1),t=e.input.charCodeAt(e.position),!(e.lineIndent>0||t!==37));){for(l=!0,t=e.input.charCodeAt(++e.position),i=e.position;t!==0&&!S(t);)t=e.input.charCodeAt(++e.position);for(o=e.input.slice(i,e.position),r=[],o.length<1&&p(e,"directive name must not be less than one character in length");t!==0;){for(;k(t);)t=e.input.charCodeAt(++e.position);if(t===35){do t=e.input.charCodeAt(++e.position);while(t!==0&&!_(t));break}if(_(t))break;for(i=e.position;t!==0&&!S(t);)t=e.input.charCodeAt(++e.position);r.push(e.input.slice(i,e.position))}t!==0&&se(e),L.call(Ae,o)?Ae[o](e,o,r):K(e,'unknown document directive "'+o+'"')}if(y(e,!0,-1),e.lineIndent===0&&e.input.charCodeAt(e.position)===45&&e.input.charCodeAt(e.position+1)===45&&e.input.charCodeAt(e.position+2)===45?(e.position+=3,y(e,!0,-1)):l&&p(e,"directives end mark is expected"),N(e,e.lineIndent-1,W,!1,!0),y(e,!0,-1),e.checkLineBreaks&&Pi.test(e.input.slice(n,e.position))&&K(e,"non-ASCII line breaks are interpreted as content"),e.documents.push(e.result),e.position===e.lineStart&&X(e)){e.input.charCodeAt(e.position)===46&&(e.position+=3,y(e,!0,-1));return}if(e.position<e.length-1)p(e,"end of the stream or a document separator is expected");else return}function He(e,n){e=String(e),n=n||{},e.length!==0&&(e.charCodeAt(e.length-1)!==10&&e.charCodeAt(e.length-1)!==13&&(e+=`
29
+ `),e.charCodeAt(0)===65279&&(e=e.slice(1)));var i=new qi(e,n),o=e.indexOf("\0");for(o!==-1&&(i.position=o,p(i,"null byte is not allowed in input")),i.input+="\0";i.input.charCodeAt(i.position)===32;)i.lineIndent+=1,i.position+=1;for(;i.position<i.length-1;)Vi(i);return i.documents}function Xi(e,n,i){n!==null&&typeof n=="object"&&typeof i>"u"&&(i=n,n=null);var o=He(e,i);if(typeof n!="function")return o;for(var r=0,l=o.length;r<l;r+=1)n(o[r])}function zi(e,n){var i=He(e,n);if(i.length!==0){if(i.length===1)return i[0];throw new E("expected a single document in the stream, but found more")}}var Zi=Xi,Ji=zi,Ue={loadAll:Zi,load:Ji},Ge=Object.prototype.toString,We=Object.prototype.hasOwnProperty,fe=65279,er=9,Y=10,nr=13,ir=32,rr=33,or=34,oe=35,tr=37,lr=38,cr=39,ur=42,Ke=44,sr=45,Q=58,ar=61,fr=62,pr=63,hr=64,Qe=91,Ve=93,dr=96,Xe=123,gr=124,ze=125,w={};w[0]="\\0";w[7]="\\a";w[8]="\\b";w[9]="\\t";w[10]="\\n";w[11]="\\v";w[12]="\\f";w[13]="\\r";w[27]="\\e";w[34]='\\"';w[92]="\\\\";w[133]="\\N";w[160]="\\_";w[8232]="\\L";w[8233]="\\P";var mr=["y","Y","yes","Yes","YES","on","On","ON","n","N","no","No","NO","off","Off","OFF"],xr=/^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;function vr(e,n){var i,o,r,l,t,c,u;if(n===null)return{};for(i={},o=Object.keys(n),r=0,l=o.length;r<l;r+=1)t=o[r],c=String(n[t]),t.slice(0,2)==="!!"&&(t="tag:yaml.org,2002:"+t.slice(2)),u=e.compiledTypeMap.fallback[t],u&&We.call(u.styleAliases,c)&&(c=u.styleAliases[c]),i[t]=c;return i}function yr(e){var n,i,o;if(n=e.toString(16).toUpperCase(),e<=255)i="x",o=2;else if(e<=65535)i="u",o=4;else if(e<=4294967295)i="U",o=8;else throw new E("code point within a string may not be greater than 0xFFFFFFFF");return"\\"+i+A.repeat("0",o-n.length)+n}var Ar=1,$=2;function Cr(e){this.schema=e.schema||Me,this.indent=Math.max(1,e.indent||2),this.noArrayIndent=e.noArrayIndent||!1,this.skipInvalid=e.skipInvalid||!1,this.flowLevel=A.isNothing(e.flowLevel)?-1:e.flowLevel,this.styleMap=vr(this.schema,e.styles||null),this.sortKeys=e.sortKeys||!1,this.lineWidth=e.lineWidth||80,this.noRefs=e.noRefs||!1,this.noCompatMode=e.noCompatMode||!1,this.condenseFlow=e.condenseFlow||!1,this.quotingType=e.quotingType==='"'?$:Ar,this.forceQuotes=e.forceQuotes||!1,this.replacer=typeof e.replacer=="function"?e.replacer:null,this.implicitTypes=this.schema.compiledImplicit,this.explicitTypes=this.schema.compiledExplicit,this.tag=null,this.result="",this.duplicates=[],this.usedDuplicates=null}function be(e,n){for(var i=A.repeat(" ",n),o=0,r=-1,l="",t,c=e.length;o<c;)r=e.indexOf(`
30
+ `,o),r===-1?(t=e.slice(o),o=c):(t=e.slice(o,r+1),o=r+1),t.length&&t!==`
31
+ `&&(l+=i),l+=t;return l}function te(e,n){return`
32
+ `+A.repeat(" ",e.indent*n)}function wr(e,n){var i,o,r;for(i=0,o=e.implicitTypes.length;i<o;i+=1)if(r=e.implicitTypes[i],r.resolve(n))return!0;return!1}function V(e){return e===ir||e===er}function B(e){return 32<=e&&e<=126||161<=e&&e<=55295&&e!==8232&&e!==8233||57344<=e&&e<=65533&&e!==fe||65536<=e&&e<=1114111}function Ee(e){return B(e)&&e!==fe&&e!==nr&&e!==Y}function Se(e,n,i){var o=Ee(e),r=o&&!V(e);return(i?o:o&&e!==Ke&&e!==Qe&&e!==Ve&&e!==Xe&&e!==ze)&&e!==oe&&!(n===Q&&!r)||Ee(n)&&!V(n)&&e===oe||n===Q&&r}function br(e){return B(e)&&e!==fe&&!V(e)&&e!==sr&&e!==pr&&e!==Q&&e!==Ke&&e!==Qe&&e!==Ve&&e!==Xe&&e!==ze&&e!==oe&&e!==lr&&e!==ur&&e!==rr&&e!==gr&&e!==ar&&e!==fr&&e!==cr&&e!==or&&e!==tr&&e!==hr&&e!==dr}function Er(e){return!V(e)&&e!==Q}function j(e,n){var i=e.charCodeAt(n),o;return i>=55296&&i<=56319&&n+1<e.length&&(o=e.charCodeAt(n+1),o>=56320&&o<=57343)?(i-55296)*1024+o-56320+65536:i}function Ze(e){var n=/^\n* /;return n.test(e)}var Je=1,le=2,en=3,nn=4,R=5;function Sr(e,n,i,o,r,l,t,c){var u,s=0,f=null,a=!1,h=!1,d=o!==-1,m=-1,v=br(j(e,0))&&Er(j(e,e.length-1));if(n||t)for(u=0;u<e.length;s>=65536?u+=2:u++){if(s=j(e,u),!B(s))return R;v=v&&Se(s,f,c),f=s}else{for(u=0;u<e.length;s>=65536?u+=2:u++){if(s=j(e,u),s===Y)a=!0,d&&(h=h||u-m-1>o&&e[m+1]!==" ",m=u);else if(!B(s))return R;v=v&&Se(s,f,c),f=s}h=h||d&&u-m-1>o&&e[m+1]!==" "}return!a&&!h?v&&!t&&!r(e)?Je:l===$?R:le:i>9&&Ze(e)?R:t?l===$?R:le:h?nn:en}function _r(e,n,i,o,r){e.dump=function(){if(n.length===0)return e.quotingType===$?'""':"''";if(!e.noCompatMode&&(mr.indexOf(n)!==-1||xr.test(n)))return e.quotingType===$?'"'+n+'"':"'"+n+"'";var l=e.indent*Math.max(1,i),t=e.lineWidth===-1?-1:Math.max(Math.min(e.lineWidth,40),e.lineWidth-l),c=o||e.flowLevel>-1&&i>=e.flowLevel;function u(s){return wr(e,s)}switch(Sr(n,c,e.indent,t,u,e.quotingType,e.forceQuotes&&!o,r)){case Je:return n;case le:return"'"+n.replace(/'/g,"''")+"'";case en:return"|"+_e(n,e.indent)+Fe(be(n,l));case nn:return">"+_e(n,e.indent)+Fe(be(Fr(n,t),l));case R:return'"'+Tr(n)+'"';default:throw new E("impossible error: invalid scalar style")}}()}function _e(e,n){var i=Ze(e)?String(n):"",o=e[e.length-1]===`
33
+ `,r=o&&(e[e.length-2]===`
34
+ `||e===`
35
+ `),l=r?"+":o?"":"-";return i+l+`
36
+ `}function Fe(e){return e[e.length-1]===`
37
+ `?e.slice(0,-1):e}function Fr(e,n){for(var i=/(\n+)([^\n]*)/g,o=function(){var s=e.indexOf(`
38
+ `);return s=s!==-1?s:e.length,i.lastIndex=s,Te(e.slice(0,s),n)}(),r=e[0]===`
39
+ `||e[0]===" ",l,t;t=i.exec(e);){var c=t[1],u=t[2];l=u[0]===" ",o+=c+(!r&&!l&&u!==""?`
40
+ `:"")+Te(u,n),r=l}return o}function Te(e,n){if(e===""||e[0]===" ")return e;for(var i=/ [^ ]/g,o,r=0,l,t=0,c=0,u="";o=i.exec(e);)c=o.index,c-r>n&&(l=t>r?t:c,u+=`
41
+ `+e.slice(r,l),r=l+1),t=c;return u+=`
42
+ `,e.length-r>n&&t>r?u+=e.slice(r,t)+`
43
+ `+e.slice(t+1):u+=e.slice(r),u.slice(1)}function Tr(e){for(var n="",i=0,o,r=0;r<e.length;i>=65536?r+=2:r++)i=j(e,r),o=w[i],!o&&B(i)?(n+=e[r],i>=65536&&(n+=e[r+1])):n+=o||yr(i);return n}function Or(e,n,i){var o="",r=e.tag,l,t,c;for(l=0,t=i.length;l<t;l+=1)c=i[l],e.replacer&&(c=e.replacer.call(i,String(l),c)),(F(e,n,c,!1,!1)||typeof c>"u"&&F(e,n,null,!1,!1))&&(o!==""&&(o+=","+(e.condenseFlow?"":" ")),o+=e.dump);e.tag=r,e.dump="["+o+"]"}function Oe(e,n,i,o){var r="",l=e.tag,t,c,u;for(t=0,c=i.length;t<c;t+=1)u=i[t],e.replacer&&(u=e.replacer.call(i,String(t),u)),(F(e,n+1,u,!0,!0,!1,!0)||typeof u>"u"&&F(e,n+1,null,!0,!0,!1,!0))&&((!o||r!=="")&&(r+=te(e,n)),e.dump&&Y===e.dump.charCodeAt(0)?r+="-":r+="- ",r+=e.dump);e.tag=l,e.dump=r||"[]"}function Lr(e,n,i){var o="",r=e.tag,l=Object.keys(i),t,c,u,s,f;for(t=0,c=l.length;t<c;t+=1)f="",o!==""&&(f+=", "),e.condenseFlow&&(f+='"'),u=l[t],s=i[u],e.replacer&&(s=e.replacer.call(i,u,s)),F(e,n,u,!1,!1)&&(e.dump.length>1024&&(f+="? "),f+=e.dump+(e.condenseFlow?'"':"")+":"+(e.condenseFlow?"":" "),F(e,n,s,!1,!1)&&(f+=e.dump,o+=f));e.tag=r,e.dump="{"+o+"}"}function Ir(e,n,i,o){var r="",l=e.tag,t=Object.keys(i),c,u,s,f,a,h;if(e.sortKeys===!0)t.sort();else if(typeof e.sortKeys=="function")t.sort(e.sortKeys);else if(e.sortKeys)throw new E("sortKeys must be a boolean or a function");for(c=0,u=t.length;c<u;c+=1)h="",(!o||r!=="")&&(h+=te(e,n)),s=t[c],f=i[s],e.replacer&&(f=e.replacer.call(i,s,f)),F(e,n+1,s,!0,!0,!0)&&(a=e.tag!==null&&e.tag!=="?"||e.dump&&e.dump.length>1024,a&&(e.dump&&Y===e.dump.charCodeAt(0)?h+="?":h+="? "),h+=e.dump,a&&(h+=te(e,n)),F(e,n+1,f,!0,a)&&(e.dump&&Y===e.dump.charCodeAt(0)?h+=":":h+=": ",h+=e.dump,r+=h));e.tag=l,e.dump=r||"{}"}function Le(e,n,i){var o,r,l,t,c,u;for(r=i?e.explicitTypes:e.implicitTypes,l=0,t=r.length;l<t;l+=1)if(c=r[l],(c.instanceOf||c.predicate)&&(!c.instanceOf||typeof n=="object"&&n instanceof c.instanceOf)&&(!c.predicate||c.predicate(n))){if(i?c.multi&&c.representName?e.tag=c.representName(n):e.tag=c.tag:e.tag="?",c.represent){if(u=e.styleMap[c.tag]||c.defaultStyle,Ge.call(c.represent)==="[object Function]")o=c.represent(n,u);else if(We.call(c.represent,u))o=c.represent[u](n,u);else throw new E("!<"+c.tag+'> tag resolver accepts not "'+u+'" style');e.dump=o}return!0}return!1}function F(e,n,i,o,r,l,t){e.tag=null,e.dump=i,Le(e,i,!1)||Le(e,i,!0);var c=Ge.call(e.dump),u=o,s;o&&(o=e.flowLevel<0||e.flowLevel>n);var f=c==="[object Object]"||c==="[object Array]",a,h;if(f&&(a=e.duplicates.indexOf(i),h=a!==-1),(e.tag!==null&&e.tag!=="?"||h||e.indent!==2&&n>0)&&(r=!1),h&&e.usedDuplicates[a])e.dump="*ref_"+a;else{if(f&&h&&!e.usedDuplicates[a]&&(e.usedDuplicates[a]=!0),c==="[object Object]")o&&Object.keys(e.dump).length!==0?(Ir(e,n,e.dump,r),h&&(e.dump="&ref_"+a+e.dump)):(Lr(e,n,e.dump),h&&(e.dump="&ref_"+a+" "+e.dump));else if(c==="[object Array]")o&&e.dump.length!==0?(e.noArrayIndent&&!t&&n>0?Oe(e,n-1,e.dump,r):Oe(e,n,e.dump,r),h&&(e.dump="&ref_"+a+e.dump)):(Or(e,n,e.dump),h&&(e.dump="&ref_"+a+" "+e.dump));else if(c==="[object String]")e.tag!=="?"&&_r(e,e.dump,n,l,u);else{if(c==="[object Undefined]")return!1;if(e.skipInvalid)return!1;throw new E("unacceptable kind of an object to dump "+c)}e.tag!==null&&e.tag!=="?"&&(s=encodeURI(e.tag[0]==="!"?e.tag.slice(1):e.tag).replace(/!/g,"%21"),e.tag[0]==="!"?s="!"+s:s.slice(0,18)==="tag:yaml.org,2002:"?s="!!"+s.slice(18):s="!<"+s+">",e.dump=s+" "+e.dump)}return!0}function kr(e,n){var i=[],o=[],r,l;for(ce(e,i,o),r=0,l=o.length;r<l;r+=1)n.duplicates.push(i[o[r]]);n.usedDuplicates=new Array(l)}function ce(e,n,i){var o,r,l;if(e!==null&&typeof e=="object")if(r=n.indexOf(e),r!==-1)i.indexOf(r)===-1&&i.push(r);else if(n.push(e),Array.isArray(e))for(r=0,l=e.length;r<l;r+=1)ce(e[r],n,i);else for(o=Object.keys(e),r=0,l=o.length;r<l;r+=1)ce(e[o[r]],n,i)}function Pr(e,n){n=n||{};var i=new Cr(n);i.noRefs||kr(e,i);var o=e;return i.replacer&&(o=i.replacer.call({"":o},"",o)),F(i,0,o,!0,!0)?i.dump+`
44
+ `:""}var Rr=Pr,Mr={dump:Rr};function pe(e,n){return function(){throw new Error("Function yaml."+e+" is removed in js-yaml 4. Use yaml."+n+" instead, which is now safe by default.")}}var rn=Ue.load,io=Ue.loadAll,ro=Mr.dump;var oo=pe("safeLoad","load"),to=pe("safeLoadAll","loadAll"),lo=pe("safeDump","dump");var ln={concurrency:1,enableEntityParallelization:!1,preserveRowOrder:!0,preserveEntityOrder:!0},tn={parallelProcessing:ln,entityConfig:{},entityDependencies:{}};function cn(e){let n=Nr.join(e,"config.yaml");try{if(!on.existsSync(n))return console.log("No config.yaml found, using default sequential processing"),tn;let i=on.readFileSync(n,"utf8"),o=rn(i);return jr(o)}catch(i){return console.warn(`Warning: Failed to parse config.yaml: ${i}. Using defaults.`),tn}}function jr(e){return{parallelProcessing:{...ln,...e.parallelProcessing||{}},entityConfig:e.entityConfig||{},entityDependencies:e.entityDependencies||{}}}function z(e,n){let i=n.entityConfig[e]||{},o={...n.parallelProcessing,...i};return o.preserveRowOrder&&o.concurrency>1&&(console.warn(`Entity '${e}': preserveRowOrder=true forces concurrency=1 (was ${o.concurrency})`),o.concurrency=1),o}var Z=class{constructor(n,i={}){this.entities=n,this.dependencies=i}resolveExecutionOrder(){let n=[],i=new Set,o=new Set,r=0;for(;i.size<this.entities.length;){let l=[];for(let t of this.entities){if(i.has(t)||o.has(t))continue;(this.dependencies[t]||[]).every(s=>i.has(s))&&(l.push(t),o.add(t))}if(l.length===0){let t=this.entities.filter(c=>!i.has(c));throw new Error(`Circular dependency detected or missing dependencies for entities: ${t.join(", ")}`)}n.push({entities:l,wave:r++}),l.forEach(t=>{i.add(t),o.delete(t)})}return n}validateDependencies(){let n=[],i=new Set(this.entities);for(let[o,r]of Object.entries(this.dependencies)){if(!i.has(o)){n.push(`Entity '${o}' has dependencies but is not in the entity list`);continue}for(let l of r)i.has(l)||n.push(`Entity '${o}' depends on '${l}' which does not exist`)}return n}getDependents(n){return Object.entries(this.dependencies).filter(([i,o])=>o.includes(n)).map(([i,o])=>i)}getDependencies(n){return this.dependencies[n]||[]}};import{basename as he}from"path";var de=new Yr;de.name("gql-ingest").description("A CLI tool for ingesting data from CSV files into a GraphQL API").version(un().version);de.requiredOption("-e, --endpoint <url>","GraphQL endpoint URL").requiredOption("-c, --config <path>","Path to configuration directory (containing data/, graphql/, mappings/ subdirectories)").option("-h, --headers <headers>","JSON string of headers to include in requests").option("-v, --verbose","Show detailed request results and responses").action(async e=>{try{console.log("Starting seed data generation...");let n=e.headers?JSON.parse(e.headers):{},i=new P,o=new H(e.endpoint,n,i,e.verbose),r=cn(e.config),l=new U(o,process.cwd(),i,e.verbose),t=l.discoverMappings(e.config);if(t.length===0){console.warn(`No mapping files found in ${e.config}/mappings`);return}let c=t.map(f=>he(f,".json")),u=new Z(c,r.entityDependencies),s=u.validateDependencies();s.length>0&&(console.error("Dependency validation errors:"),s.forEach(f=>console.error(` - ${f}`)),process.exit(1)),r.parallelProcessing.enableEntityParallelization?await Br(t,u,l,r):await $r(t,l,r),i.finishProcessing(),console.log(i.generateSummary())}catch(n){console.error("Error:",n),process.exit(1)}});async function $r(e,n,i){for(let o of e)try{let r=he(o,".json"),l=z(r,i);await n.processEntity(o,l)}catch(r){console.warn(`Warning: Could not process ${o}:`,r)}}async function Br(e,n,i,o){let r=n.resolveExecutionOrder(),l=new Map(e.map(t=>[he(t,".json"),t]));console.log(`Processing ${r.length} dependency waves...`);for(let t of r)if(console.log(`Wave ${t.wave+1}: Processing entities [${t.entities.join(", ")}]`),o.parallelProcessing.preserveEntityOrder)for(let c of t.entities){let u=l.get(c);if(u)try{let s=z(c,o);await i.processEntity(u,s)}catch(s){console.warn(`Warning: Could not process ${u}:`,s)}}else{let c=t.entities.map(async u=>{let s=l.get(u);if(s)try{let f=z(u,o);await i.processEntity(s,f)}catch(f){console.warn(`Warning: Could not process ${s}:`,f)}});await Promise.allSettled(c)}}de.parse();
45
+ /*! Bundled license information:
46
+
47
+ js-yaml/dist/js-yaml.mjs:
48
+ (*! js-yaml 4.1.0 https://github.com/nodeca/js-yaml @license MIT *)
49
+ */
@@ -0,0 +1,22 @@
1
+ export interface ParallelProcessingConfig {
2
+ concurrency: number;
3
+ enableEntityParallelization: boolean;
4
+ preserveRowOrder: boolean;
5
+ preserveEntityOrder: boolean;
6
+ }
7
+ export interface EntityConfig {
8
+ concurrency?: number;
9
+ preserveRowOrder?: boolean;
10
+ }
11
+ export interface ProcessingConfig {
12
+ parallelProcessing: ParallelProcessingConfig;
13
+ entityConfig: Record<string, EntityConfig>;
14
+ entityDependencies: Record<string, string[]>;
15
+ }
16
+ export interface FullConfig extends ProcessingConfig {
17
+ }
18
+ export declare const DEFAULT_PARALLEL_CONFIG: ParallelProcessingConfig;
19
+ export declare const DEFAULT_CONFIG: ProcessingConfig;
20
+ export declare function loadConfig(configDir: string): ProcessingConfig;
21
+ export declare function getEntityConfig(entityName: string, globalConfig: ProcessingConfig): ParallelProcessingConfig;
22
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,wBAAwB;IACvC,WAAW,EAAE,MAAM,CAAC;IACpB,2BAA2B,EAAE,OAAO,CAAC;IACrC,gBAAgB,EAAE,OAAO,CAAC;IAC1B,mBAAmB,EAAE,OAAO,CAAC;CAC9B;AAED,MAAM,WAAW,YAAY;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED,MAAM,WAAW,gBAAgB;IAC/B,kBAAkB,EAAE,wBAAwB,CAAC;IAC7C,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IAC3C,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;CAC9C;AAED,MAAM,WAAW,UAAW,SAAQ,gBAAgB;CAEnD;AAED,eAAO,MAAM,uBAAuB,EAAE,wBAKrC,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,gBAI5B,CAAC;AAEF,wBAAgB,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,gBAAgB,CAmB9D;AAaD,wBAAgB,eAAe,CAC7B,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,gBAAgB,GAC7B,wBAAwB,CAiB1B"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=config.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.test.d.ts","sourceRoot":"","sources":["../src/config.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,17 @@
1
+ export interface DependencyGraph {
2
+ [entityName: string]: string[];
3
+ }
4
+ export interface ExecutionWave {
5
+ entities: string[];
6
+ wave: number;
7
+ }
8
+ export declare class DependencyResolver {
9
+ private dependencies;
10
+ private entities;
11
+ constructor(entities: string[], dependencies?: DependencyGraph);
12
+ resolveExecutionOrder(): ExecutionWave[];
13
+ validateDependencies(): string[];
14
+ getDependents(entityName: string): string[];
15
+ getDependencies(entityName: string): string[];
16
+ }
17
+ //# sourceMappingURL=dependency-resolver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dependency-resolver.d.ts","sourceRoot":"","sources":["../src/dependency-resolver.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;IAC9B,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CAChC;AAED,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,YAAY,CAAkB;IACtC,OAAO,CAAC,QAAQ,CAAW;gBAEf,QAAQ,EAAE,MAAM,EAAE,EAAE,YAAY,GAAE,eAAoB;IAKlE,qBAAqB,IAAI,aAAa,EAAE;IA8CxC,oBAAoB,IAAI,MAAM,EAAE;IAwBhC,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE;IAM3C,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE;CAG9C"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=dependency-resolver.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dependency-resolver.test.d.ts","sourceRoot":"","sources":["../src/dependency-resolver.test.ts"],"names":[],"mappings":""}
@@ -1,6 +1,9 @@
1
+ import { MetricsCollector } from './metrics';
1
2
  export declare class GraphQLClientWrapper {
2
3
  private client;
3
- constructor(endpoint: string, headers?: Record<string, string>);
4
+ private metrics?;
5
+ private verbose;
6
+ constructor(endpoint: string, headers?: Record<string, string>, metrics?: MetricsCollector, verbose?: boolean);
4
7
  executeMutation(mutation: string, variables: Record<string, any>): Promise<any>;
5
8
  setHeaders(headers: Record<string, string>): void;
6
9
  }
@@ -1 +1 @@
1
- {"version":3,"file":"graphql-client.d.ts","sourceRoot":"","sources":["../src/graphql-client.ts"],"names":[],"mappings":"AAEA,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,MAAM,CAAgB;gBAElB,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAMxD,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC;IAUrF,UAAU,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;CAG3C"}
1
+ {"version":3,"file":"graphql-client.d.ts","sourceRoot":"","sources":["../src/graphql-client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAE7C,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,MAAM,CAAgB;IAC9B,OAAO,CAAC,OAAO,CAAC,CAAmB;IACnC,OAAO,CAAC,OAAO,CAAU;gBAEb,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,CAAC,EAAE,gBAAgB,EAAE,OAAO,GAAE,OAAe;IAQ9G,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC;IA+BrF,UAAU,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;CAG3C"}
package/dist/mapper.d.ts CHANGED
@@ -1,4 +1,6 @@
1
- import { GraphQLClientWrapper } from './graphql-client';
1
+ import { GraphQLClientWrapper } from "./graphql-client";
2
+ import { MetricsCollector } from "./metrics";
3
+ import { ParallelProcessingConfig } from "./config";
2
4
  export interface MappingConfig {
3
5
  csvFile: string;
4
6
  graphqlFile: string;
@@ -7,9 +9,15 @@ export interface MappingConfig {
7
9
  export declare class DataMapper {
8
10
  private client;
9
11
  private basePath;
10
- constructor(client: GraphQLClientWrapper, basePath?: string);
12
+ private metrics;
13
+ private verbose;
14
+ constructor(client: GraphQLClientWrapper, basePath?: string, metrics?: MetricsCollector, verbose?: boolean);
11
15
  discoverMappings(configDir: string): string[];
12
- processEntity(configPath: string): Promise<void>;
16
+ processEntity(configPath: string, parallelConfig?: ParallelProcessingConfig): Promise<void>;
17
+ private processRowsSequentially;
18
+ private processRowsConcurrently;
19
+ private chunkArray;
13
20
  private mapCsvRowToVariables;
21
+ getMetrics(): MetricsCollector;
14
22
  }
15
23
  //# sourceMappingURL=mapper.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mapper.d.ts","sourceRoot":"","sources":["../src/mapper.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAExD,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACjC;AAED,qBAAa,UAAU;IACrB,OAAO,CAAC,MAAM,CAAuB;IACrC,OAAO,CAAC,QAAQ,CAAS;gBAEb,MAAM,EAAE,oBAAoB,EAAE,QAAQ,GAAE,MAAsB;IAK1E,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE;IAiBvC,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IA+BtD,OAAO,CAAC,oBAAoB;CAW7B"}
1
+ {"version":3,"file":"mapper.d.ts","sourceRoot":"","sources":["../src/mapper.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAC;AAEpD,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACjC;AAED,qBAAa,UAAU;IACrB,OAAO,CAAC,MAAM,CAAuB;IACrC,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,OAAO,CAAmB;IAClC,OAAO,CAAC,OAAO,CAAU;gBAGvB,MAAM,EAAE,oBAAoB,EAC5B,QAAQ,GAAE,MAAsB,EAChC,OAAO,CAAC,EAAE,gBAAgB,EAC1B,OAAO,GAAE,OAAe;IAQ1B,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE;IAiBvC,aAAa,CACjB,UAAU,EAAE,MAAM,EAClB,cAAc,CAAC,EAAE,wBAAwB,GACxC,OAAO,CAAC,IAAI,CAAC;YA4CF,uBAAuB;YA8BvB,uBAAuB;IAkErC,OAAO,CAAC,UAAU;IAQlB,OAAO,CAAC,oBAAoB;IAe5B,UAAU,IAAI,gBAAgB;CAG/B"}
@@ -0,0 +1,33 @@
1
+ export interface EntityMetrics {
2
+ entityName: string;
3
+ successCount: number;
4
+ failureCount: number;
5
+ startTime: number;
6
+ endTime?: number;
7
+ }
8
+ export interface ProcessingMetrics {
9
+ totalEntities: number;
10
+ totalSuccesses: number;
11
+ totalFailures: number;
12
+ entityMetrics: Map<string, EntityMetrics>;
13
+ requestDurations: number[];
14
+ startTime: number;
15
+ endTime?: number;
16
+ }
17
+ export declare class MetricsCollector {
18
+ private metrics;
19
+ constructor();
20
+ startEntityProcessing(entityName: string): void;
21
+ recordSuccess(entityName: string): void;
22
+ recordFailure(entityName: string): void;
23
+ finishEntityProcessing(entityName: string): void;
24
+ finishProcessing(): ProcessingMetrics;
25
+ getEntityMetrics(entityName: string): EntityMetrics | undefined;
26
+ getTotalProcessed(): number;
27
+ getSuccessRate(): number;
28
+ recordRequestDuration(duration: number): void;
29
+ getAverageRequestDuration(): number;
30
+ getDurationMs(): number;
31
+ generateSummary(): string;
32
+ }
33
+ //# sourceMappingURL=metrics.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"metrics.d.ts","sourceRoot":"","sources":["../src/metrics.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa;IAC5B,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,iBAAiB;IAChC,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IAC1C,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,OAAO,CAAoB;;IAanC,qBAAqB,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAW/C,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IASvC,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IASvC,sBAAsB,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAOhD,gBAAgB,IAAI,iBAAiB;IAKrC,gBAAgB,CAAC,UAAU,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS;IAI/D,iBAAiB,IAAI,MAAM;IAI3B,cAAc,IAAI,MAAM;IAKxB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAI7C,yBAAyB,IAAI,MAAM;IAMnC,aAAa,IAAI,MAAM;IAKvB,eAAe,IAAI,MAAM;CA6B1B"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=metrics.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"metrics.test.d.ts","sourceRoot":"","sources":["../src/metrics.test.ts"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "@jackchuka/gql-ingest",
3
- "version": "1.0.2",
3
+ "version": "1.1.0",
4
4
  "description": "A CLI tool for ingesting data from CSV files into a GraphQL API",
5
+ "type": "module",
5
6
  "main": "dist/cli.js",
6
7
  "bin": {
7
8
  "gql-ingest": "bin/cli.js"
@@ -31,10 +32,12 @@
31
32
  "dependencies": {
32
33
  "commander": "^14.0.0",
33
34
  "csv-parser": "^3.0.0",
34
- "graphql-request": "^7.2.0"
35
+ "graphql-request": "^7.2.0",
36
+ "js-yaml": "^4.1.0"
35
37
  },
36
38
  "devDependencies": {
37
39
  "@types/jest": "^30.0.0",
40
+ "@types/js-yaml": "^4.0.9",
38
41
  "@types/node": "^24.0.4",
39
42
  "esbuild": "^0.25.5",
40
43
  "jest": "^30.0.3",
package/src/cli.ts CHANGED
@@ -1,6 +1,10 @@
1
1
  import { Command } from "commander";
2
2
  import { GraphQLClientWrapper } from "./graphql-client";
3
3
  import { DataMapper } from "./mapper";
4
+ import { MetricsCollector } from "./metrics";
5
+ import { loadConfig, getEntityConfig } from "./config";
6
+ import { DependencyResolver } from "./dependency-resolver";
7
+ import { basename } from "path";
4
8
 
5
9
  const program = new Command();
6
10
 
@@ -21,6 +25,7 @@ program
21
25
  "-h, --headers <headers>",
22
26
  "JSON string of headers to include in requests"
23
27
  )
28
+ .option("-v, --verbose", "Show detailed request results and responses")
24
29
  .action(async (options) => {
25
30
  try {
26
31
  console.log("Starting seed data generation...");
@@ -28,11 +33,27 @@ program
28
33
  // Parse headers if provided
29
34
  const headers = options.headers ? JSON.parse(options.headers) : {};
30
35
 
36
+ // Initialize metrics collector
37
+ const metrics = new MetricsCollector();
38
+
31
39
  // Initialize GraphQL client
32
- const client = new GraphQLClientWrapper(options.endpoint, headers);
40
+ const client = new GraphQLClientWrapper(
41
+ options.endpoint,
42
+ headers,
43
+ metrics,
44
+ options.verbose
45
+ );
46
+
47
+ // Load configuration
48
+ const config = loadConfig(options.config);
33
49
 
34
50
  // Initialize data mapper
35
- const mapper = new DataMapper(client);
51
+ const mapper = new DataMapper(
52
+ client,
53
+ process.cwd(),
54
+ metrics,
55
+ options.verbose
56
+ );
36
57
 
37
58
  // Discover all mapping files dynamically
38
59
  const mappingPaths = mapper.discoverMappings(options.config);
@@ -42,19 +63,102 @@ program
42
63
  return;
43
64
  }
44
65
 
45
- for (const configPath of mappingPaths) {
46
- try {
47
- await mapper.processEntity(configPath);
48
- } catch (error) {
49
- console.warn(`Warning: Could not process ${configPath}:`, error);
50
- }
66
+ // Extract entity names from mapping paths
67
+ const entityNames = mappingPaths.map((path) => basename(path, ".json"));
68
+
69
+ // Setup dependency resolver
70
+ const resolver = new DependencyResolver(
71
+ entityNames,
72
+ config.entityDependencies
73
+ );
74
+
75
+ // Validate dependencies
76
+ const validationErrors = resolver.validateDependencies();
77
+ if (validationErrors.length > 0) {
78
+ console.error("Dependency validation errors:");
79
+ validationErrors.forEach((error) => console.error(` - ${error}`));
80
+ process.exit(1);
51
81
  }
52
82
 
53
- console.log("Seed data generation completed!");
83
+ // Process entities in dependency-aware waves
84
+ if (config.parallelProcessing.enableEntityParallelization) {
85
+ await processEntitiesInWaves(mappingPaths, resolver, mapper, config);
86
+ } else {
87
+ await processEntitiesSequentially(mappingPaths, mapper, config);
88
+ }
89
+
90
+ metrics.finishProcessing();
91
+ console.log(metrics.generateSummary());
54
92
  } catch (error) {
55
93
  console.error("Error:", error);
56
94
  process.exit(1);
57
95
  }
58
96
  });
59
97
 
98
+ async function processEntitiesSequentially(
99
+ mappingPaths: string[],
100
+ mapper: DataMapper,
101
+ config: ReturnType<typeof loadConfig>
102
+ ): Promise<void> {
103
+ for (const configPath of mappingPaths) {
104
+ try {
105
+ const entityName = basename(configPath, ".json");
106
+ const entityConfig = getEntityConfig(entityName, config);
107
+ await mapper.processEntity(configPath, entityConfig);
108
+ } catch (error) {
109
+ console.warn(`Warning: Could not process ${configPath}:`, error);
110
+ }
111
+ }
112
+ }
113
+
114
+ async function processEntitiesInWaves(
115
+ mappingPaths: string[],
116
+ resolver: DependencyResolver,
117
+ mapper: DataMapper,
118
+ config: ReturnType<typeof loadConfig>
119
+ ): Promise<void> {
120
+ const waves = resolver.resolveExecutionOrder();
121
+ const pathMap = new Map(
122
+ mappingPaths.map((path) => [basename(path, ".json"), path])
123
+ );
124
+
125
+ console.log(`Processing ${waves.length} dependency waves...`);
126
+
127
+ for (const wave of waves) {
128
+ console.log(
129
+ `Wave ${wave.wave + 1}: Processing entities [${wave.entities.join(", ")}]`
130
+ );
131
+
132
+ if (config.parallelProcessing.preserveEntityOrder) {
133
+ // Process entities in this wave sequentially
134
+ for (const entityName of wave.entities) {
135
+ const configPath = pathMap.get(entityName);
136
+ if (configPath) {
137
+ try {
138
+ const entityConfig = getEntityConfig(entityName, config);
139
+ await mapper.processEntity(configPath, entityConfig);
140
+ } catch (error) {
141
+ console.warn(`Warning: Could not process ${configPath}:`, error);
142
+ }
143
+ }
144
+ }
145
+ } else {
146
+ // Process entities in this wave concurrently
147
+ const entityPromises = wave.entities.map(async (entityName) => {
148
+ const configPath = pathMap.get(entityName);
149
+ if (configPath) {
150
+ try {
151
+ const entityConfig = getEntityConfig(entityName, config);
152
+ await mapper.processEntity(configPath, entityConfig);
153
+ } catch (error) {
154
+ console.warn(`Warning: Could not process ${configPath}:`, error);
155
+ }
156
+ }
157
+ });
158
+
159
+ await Promise.allSettled(entityPromises);
160
+ }
161
+ }
162
+ }
163
+
60
164
  program.parse();