@tetrascience-npm/tetrascience-react-ui 0.4.0-beta.8.1 → 0.4.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.
Files changed (61) hide show
  1. package/README.md +58 -4
  2. package/dist/athena.d.ts +167 -0
  3. package/dist/databricks.d.ts +129 -0
  4. package/dist/exceptions-DN25pCDi.cjs +2 -0
  5. package/dist/exceptions-DN25pCDi.cjs.map +1 -0
  6. package/dist/exceptions-jCQ6h5C8.js +33 -0
  7. package/dist/exceptions-jCQ6h5C8.js.map +1 -0
  8. package/dist/index.cjs +2021 -0
  9. package/dist/index.cjs.map +1 -0
  10. package/dist/index.css +1 -1
  11. package/dist/index.d.ts +2165 -1733
  12. package/dist/index.js +9461 -2
  13. package/dist/index.js.map +1 -0
  14. package/dist/logo.png +0 -0
  15. package/dist/providers/athena.cjs +2 -0
  16. package/dist/providers/athena.cjs.map +1 -0
  17. package/dist/providers/athena.d.ts +7 -77
  18. package/dist/providers/athena.js +160 -0
  19. package/dist/providers/athena.js.map +1 -0
  20. package/dist/providers/databricks.cjs +2 -0
  21. package/dist/providers/databricks.cjs.map +1 -0
  22. package/dist/providers/databricks.d.ts +7 -41
  23. package/dist/providers/databricks.js +85 -0
  24. package/dist/providers/databricks.js.map +1 -0
  25. package/dist/providers/snowflake.cjs +2 -0
  26. package/dist/providers/snowflake.cjs.map +1 -0
  27. package/dist/providers/snowflake.d.ts +7 -38
  28. package/dist/providers/snowflake.js +122 -0
  29. package/dist/providers/snowflake.js.map +1 -0
  30. package/dist/server.cjs +2 -0
  31. package/dist/server.cjs.map +1 -0
  32. package/dist/server.d.ts +537 -522
  33. package/dist/server.js +266 -0
  34. package/dist/server.js.map +1 -0
  35. package/dist/{providers/types-Ck4uFaGp.d.ts → snowflake.d.ts} +125 -82
  36. package/dist/vite.svg +1 -0
  37. package/package.json +32 -52
  38. package/dist/cjs/index.js +0 -2001
  39. package/dist/cjs/index.js.map +0 -1
  40. package/dist/cjs/providers/athena.js +0 -2
  41. package/dist/cjs/providers/athena.js.map +0 -1
  42. package/dist/cjs/providers/databricks.js +0 -2
  43. package/dist/cjs/providers/databricks.js.map +0 -1
  44. package/dist/cjs/providers/exceptions-CYktpdqW.js +0 -2
  45. package/dist/cjs/providers/exceptions-CYktpdqW.js.map +0 -1
  46. package/dist/cjs/providers/snowflake.js +0 -2
  47. package/dist/cjs/providers/snowflake.js.map +0 -1
  48. package/dist/cjs/server.js +0 -2
  49. package/dist/cjs/server.js.map +0 -1
  50. package/dist/esm/index.js +0 -2001
  51. package/dist/esm/index.js.map +0 -1
  52. package/dist/esm/providers/athena.js +0 -2
  53. package/dist/esm/providers/athena.js.map +0 -1
  54. package/dist/esm/providers/databricks.js +0 -2
  55. package/dist/esm/providers/databricks.js.map +0 -1
  56. package/dist/esm/providers/exceptions-C3uFWZB2.js +0 -2
  57. package/dist/esm/providers/exceptions-C3uFWZB2.js.map +0 -1
  58. package/dist/esm/providers/snowflake.js +0 -2
  59. package/dist/esm/providers/snowflake.js.map +0 -1
  60. package/dist/esm/server.js +0 -2
  61. package/dist/esm/server.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sources":["../../node_modules/react-syntax-highlighter/dist/esm/styles/prism/nord.js"],"sourcesContent":["export default {\n \"code[class*=\\\"language-\\\"]\": {\n \"color\": \"#f8f8f2\",\n \"background\": \"none\",\n \"fontFamily\": \"\\\"Fira Code\\\", Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace\",\n \"textAlign\": \"left\",\n \"whiteSpace\": \"pre\",\n \"wordSpacing\": \"normal\",\n \"wordBreak\": \"normal\",\n \"wordWrap\": \"normal\",\n \"lineHeight\": \"1.5\",\n \"MozTabSize\": \"4\",\n \"OTabSize\": \"4\",\n \"tabSize\": \"4\",\n \"WebkitHyphens\": \"none\",\n \"MozHyphens\": \"none\",\n \"msHyphens\": \"none\",\n \"hyphens\": \"none\"\n },\n \"pre[class*=\\\"language-\\\"]\": {\n \"color\": \"#f8f8f2\",\n \"background\": \"#2E3440\",\n \"fontFamily\": \"\\\"Fira Code\\\", Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace\",\n \"textAlign\": \"left\",\n \"whiteSpace\": \"pre\",\n \"wordSpacing\": \"normal\",\n \"wordBreak\": \"normal\",\n \"wordWrap\": \"normal\",\n \"lineHeight\": \"1.5\",\n \"MozTabSize\": \"4\",\n \"OTabSize\": \"4\",\n \"tabSize\": \"4\",\n \"WebkitHyphens\": \"none\",\n \"MozHyphens\": \"none\",\n \"msHyphens\": \"none\",\n \"hyphens\": \"none\",\n \"padding\": \"1em\",\n \"margin\": \".5em 0\",\n \"overflow\": \"auto\",\n \"borderRadius\": \"0.3em\"\n },\n \":not(pre) > code[class*=\\\"language-\\\"]\": {\n \"background\": \"#2E3440\",\n \"padding\": \".1em\",\n \"borderRadius\": \".3em\",\n \"whiteSpace\": \"normal\"\n },\n \"comment\": {\n \"color\": \"#636f88\"\n },\n \"prolog\": {\n \"color\": \"#636f88\"\n },\n \"doctype\": {\n \"color\": \"#636f88\"\n },\n \"cdata\": {\n \"color\": \"#636f88\"\n },\n \"punctuation\": {\n \"color\": \"#81A1C1\"\n },\n \".namespace\": {\n \"Opacity\": \".7\"\n },\n \"property\": {\n \"color\": \"#81A1C1\"\n },\n \"tag\": {\n \"color\": \"#81A1C1\"\n },\n \"constant\": {\n \"color\": \"#81A1C1\"\n },\n \"symbol\": {\n \"color\": \"#81A1C1\"\n },\n \"deleted\": {\n \"color\": \"#81A1C1\"\n },\n \"number\": {\n \"color\": \"#B48EAD\"\n },\n \"boolean\": {\n \"color\": \"#81A1C1\"\n },\n \"selector\": {\n \"color\": \"#A3BE8C\"\n },\n \"attr-name\": {\n \"color\": \"#A3BE8C\"\n },\n \"string\": {\n \"color\": \"#A3BE8C\"\n },\n \"char\": {\n \"color\": \"#A3BE8C\"\n },\n \"builtin\": {\n \"color\": \"#A3BE8C\"\n },\n \"inserted\": {\n \"color\": \"#A3BE8C\"\n },\n \"operator\": {\n \"color\": \"#81A1C1\"\n },\n \"entity\": {\n \"color\": \"#81A1C1\",\n \"cursor\": \"help\"\n },\n \"url\": {\n \"color\": \"#81A1C1\"\n },\n \".language-css .token.string\": {\n \"color\": \"#81A1C1\"\n },\n \".style .token.string\": {\n \"color\": \"#81A1C1\"\n },\n \"variable\": {\n \"color\": \"#81A1C1\"\n },\n \"atrule\": {\n \"color\": \"#88C0D0\"\n },\n \"attr-value\": {\n \"color\": \"#88C0D0\"\n },\n \"function\": {\n \"color\": \"#88C0D0\"\n },\n \"class-name\": {\n \"color\": \"#88C0D0\"\n },\n \"keyword\": {\n \"color\": \"#81A1C1\"\n },\n \"regex\": {\n \"color\": \"#EBCB8B\"\n },\n \"important\": {\n \"color\": \"#EBCB8B\",\n \"fontWeight\": \"bold\"\n },\n \"bold\": {\n \"fontWeight\": \"bold\"\n },\n \"italic\": {\n \"fontStyle\": \"italic\"\n }\n};"],"names":["nord","color","background","fontFamily","textAlign","whiteSpace","wordSpacing","wordBreak","wordWrap","lineHeight","MozTabSize","OTabSize","tabSize","WebkitHyphens","MozHyphens","msHyphens","hyphens","padding","margin","overflow","borderRadius","comment","prolog","doctype","cdata","punctuation","Opacity","property","tag","constant","symbol","deleted","number","boolean","selector","string","char","builtin","inserted","operator","entity","cursor","url","variable","atrule","function","keyword","regex","important","fontWeight","bold","italic","fontStyle"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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!0,value:void 0}),Object.defineProperty(this,"sdk",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"workgroup",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"database",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"outputLocation",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.client=e,this.sdk=t,this.workgroup=r,this.database=o,this.outputLocation=n}async query(t,r={}){if(t.length>262144)throw new Error("Query length exceeds the maximum allowed limit.");const o=new this.sdk.StartQueryExecutionCommand({QueryString:t,WorkGroup:this.workgroup,QueryExecutionContext:{Database:this.database},ResultConfiguration:this.outputLocation?{OutputLocation:this.outputLocation}:void 0}),n=(await this.client.send(o)).QueryExecutionId;if(!n)throw new e.QueryError("Failed to start query execution");return await this.waitForQueryCompletion(n,t),this.fetchAllResults(n)}async waitForQueryCompletion(t,r){const o=3e5,n=Date.now();for(;Date.now()-n<o;){const o=new this.sdk.GetQueryExecutionCommand({QueryExecutionId:t}),n=await this.client.send(o),i=n.QueryExecution?.Status?.State;if(i===this.sdk.QueryExecutionState.SUCCEEDED)return;if(i===this.sdk.QueryExecutionState.FAILED||i===this.sdk.QueryExecutionState.CANCELLED){const t=n.QueryExecution?.Status?.StateChangeReason??"Unknown error";if(t.includes("TABLE_NOT_FOUND")){const r=t.split(":").pop()?.trim()??"";throw new e.MissingTableError("Athena is unable to find the table. If the table is created by a tetraflow, make sure that the tetraflow has run successfully. "+r+".")}throw new e.QueryError(`Query failed: ${r}. Reason: ${t}`)}await new Promise(e=>setTimeout(e,1e3))}throw new e.QueryError("Query timed out after 300 seconds")}async fetchAllResults(e){const t=[];let r,o=[],n=!0;do{const i=new this.sdk.GetQueryResultsCommand({QueryExecutionId:e,NextToken:r}),a=await this.client.send(i);n&&a.ResultSet?.ResultSetMetadata?.ColumnInfo&&(o=a.ResultSet.ResultSetMetadata.ColumnInfo.map((e,t)=>{const r=e.Name;return r&&""!==r.trim()?r:`column_${t}`}));const s=a.ResultSet?.Rows??[],u=n?s.slice(1):s;for(const e of u){const r={};e.Data?.forEach((e,t)=>{const n=o[t]??`column_${t}`;r[n]=e.VarCharValue??null}),t.push(r)}r=a.NextToken,n=!1}while(r);return t}async close(){this.client.destroy()}}exports.InvalidProviderConfigurationError=e.InvalidProviderConfigurationError,exports.MissingTableError=e.MissingTableError,exports.ProviderConnectionError=e.ProviderConnectionError,exports.ProviderError=e.ProviderError,exports.QueryError=e.QueryError,exports.AthenaProvider=t,exports.getTdpAthenaProvider=async function(){const r=await async function(){try{return await import("@aws-sdk/client-athena")}catch{throw new e.InvalidProviderConfigurationError("The '@aws-sdk/client-athena' package is required to use the Athena provider. Please install it: npm install @aws-sdk/client-athena")}}(),o=process.env.ORG_SLUG??"",n=o.replace(/-/g,"_"),i=process.env.ATHENA_S3_OUTPUT_LOCATION,a=process.env.AWS_REGION,s=`${n}__tss__default`,u=o,c=new r.AthenaClient({region:a});try{return await c.send(new r.GetWorkGroupCommand({WorkGroup:u})),new t(c,r,u,s)}catch{if(!i)throw new Error("ATHENA_S3_OUTPUT_LOCATION environment variable is required when using the 'primary' workgroup. Either set this variable or ensure the org-specific workgroup exists.");return new t(c,r,"primary",s,`s3://${i}/${n}/`)}};
2
- //# sourceMappingURL=athena.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"athena.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- "use strict";var e=require("./exceptions-CYktpdqW.js");class r{constructor(e,r){Object.defineProperty(this,"client",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"session",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.client=e,this.session=r}async query(e,r={}){const t=await this.session.executeStatement(e);try{return await t.fetchAll()}finally{await t.close()}}async close(){await this.session.close(),await this.client.close()}}exports.InvalidProviderConfigurationError=e.InvalidProviderConfigurationError,exports.MissingTableError=e.MissingTableError,exports.ProviderConnectionError=e.ProviderConnectionError,exports.ProviderError=e.ProviderError,exports.QueryError=e.QueryError,exports.DatabricksProvider=r,exports.buildDatabricksProvider=async function(t){const{DBSQLClient:i}=await async function(){try{return await import("@databricks/sql")}catch{throw new e.InvalidProviderConfigurationError("The '@databricks/sql' package is required to use the Databricks provider. Please install it: npm install @databricks/sql")}}(),o=["server_hostname","http_path","client_id","client_secret","catalog"];for(const r of o)if(!t.fields[r])throw new e.InvalidProviderConfigurationError(`Missing field '${r}' in the provider '${t.name}' to connect to Databricks.`);const s=t.fields.server_hostname,a=t.fields.http_path,n=t.fields.client_id,c=t.fields.client_secret,l=t.fields.catalog,d=t.fields.schema??`${(process.env.ORG_SLUG??"").replace(/-/g,"_")}__tss__default`,u=new i;await u.connect({host:s,path:a,authType:"databricks-oauth",oauthClientId:n,oauthClientSecret:c});const h=await u.openSession({initialCatalog:l,initialSchema:d});return new r(u,h)};
2
- //# sourceMappingURL=databricks.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"databricks.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- "use strict";class r extends Error{constructor(r){super(r),this.name="ProviderError"}}exports.InvalidProviderConfigurationError=class extends r{constructor(r){super(r),this.name="InvalidProviderConfigurationError"}},exports.MissingTableError=class extends r{constructor(r){super(r),this.name="MissingTableError"}},exports.ProviderConnectionError=class extends r{constructor(r){super(r),this.name="ProviderConnectionError"}},exports.ProviderError=r,exports.QueryError=class extends r{constructor(r){super(r),this.name="QueryError"}};
2
- //# sourceMappingURL=exceptions-CYktpdqW.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"exceptions-CYktpdqW.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- "use strict";var e=require("./exceptions-CYktpdqW.js");class r{constructor(e){Object.defineProperty(this,"connection",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.connection=e}async query(r,o={}){const n=(Array.isArray(o),o);return new Promise((o,s)=>{this.connection.execute({sqlText:r,binds:n,complete:(r,n,t)=>{r?s(new e.QueryError(`Snowflake provider failed to query the database. Reason: ${r.message}`)):o(t??[])}})})}async close(){return new Promise((e,r)=>{this.connection.destroy(o=>{o?r(o):e()})})}}exports.InvalidProviderConfigurationError=e.InvalidProviderConfigurationError,exports.MissingTableError=e.MissingTableError,exports.ProviderConnectionError=e.ProviderConnectionError,exports.ProviderError=e.ProviderError,exports.QueryError=e.QueryError,exports.SnowflakeProvider=r,exports.buildSnowflakeProvider=async function(o){const n=await async function(){try{const e=await import("snowflake-sdk");return e.default||e}catch{throw new e.InvalidProviderConfigurationError("The 'snowflake-sdk' package is required to use the Snowflake provider. Please install it: npm install snowflake-sdk")}}(),s=["user","password","account","warehouse","database","schema","role"];for(const r of s)if(!o.fields[r])throw new e.InvalidProviderConfigurationError(`Missing field '${r}' in the provider '${o.name}' to connect to Snowflake using password based authentication.`);const t={account:o.fields.account,username:o.fields.user,password:o.fields.password,warehouse:o.fields.warehouse,database:o.fields.database,schema:o.fields.schema,role:o.fields.role};return new Promise((o,s)=>{n.createConnection(t).connect((n,t)=>{n?s(new e.ProviderConnectionError(`Unable to connect to Snowflake. Reason: ${n.message}`)):t.execute({sqlText:"ALTER SESSION SET TIMEZONE = 'UTC'",complete:e=>{e&&console.warn(`Warning: Failed to set timezone to UTC: ${e.message}`),o(new r(t))}})})})};
2
- //# sourceMappingURL=snowflake.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"snowflake.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- "use strict";var e=require("@tetrascience-npm/ts-connectors-sdk");class t{constructor(e={}){Object.defineProperty(this,"baseUrlOverride",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"connectorId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"orgSlug",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"tokenCache",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"tokenRefreshThresholdMs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"tdpClient",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.baseUrlOverride=e.baseUrl,this.connectorId=process.env.CONNECTOR_ID,this.orgSlug=process.env.ORG_SLUG,this.tokenCache=new Map,this.tokenRefreshThresholdMs=e.tokenRefreshThresholdMs||3e5,this.tdpClient=null}getBaseUrl(){const e=this.baseUrlOverride||process.env.TDP_ENDPOINT;if(!e)throw new Error("TDP base URL not configured. Set TDP_ENDPOINT environment variable or pass baseUrl in config.");return e}decodeJwtPayload(e){try{const t=e.split(".");if(3!==t.length)return console.warn("Invalid JWT token format"),null;const r=t[1].replace(/-/g,"+").replace(/_/g,"/"),n=r.padEnd(r.length+(4-r.length%4)%4,"=");return JSON.parse(Buffer.from(n,"base64").toString("utf-8"))}catch(e){return console.warn("Error decoding JWT token:",e),null}}isPayloadExpiringSoon(e){if(!e.exp)return console.warn("JWT token has no expiration claim"),!0;return 1e3*e.exp<=Date.now()+this.tokenRefreshThresholdMs}getValidUserJwt(e){const t=this.tokenCache.get(e);return t&&!this.isPayloadExpiringSoon(t.payload)?t.token:(t&&this.tokenCache.delete(e),null)}async getTdpClient(){if(null!==this.tdpClient)return this.tdpClient;if(!this.connectorId||!this.orgSlug)throw new Error("Missing required configuration: CONNECTOR_ID or ORG_SLUG");const t=this.getBaseUrl();try{const r=new e.TDPClient({tdpEndpoint:t,connectorId:this.connectorId,orgSlug:this.orgSlug,artifactType:"data-app"});return await r.init(),this.tdpClient=r,this.tdpClient}catch(e){throw console.error("Failed to initialize TDP client:",e),e}}async getJwtFromTokenRefInternal(e){const t=await this.getTdpClient();try{const r=await t.getValues([e]);if(r&&r.length>0&&r[0]?.jwt){const t=r[0].jwt,n=this.decodeJwtPayload(t);return n&&this.tokenCache.set(e,{token:t,payload:n}),t}console.error(`No JWT found for key '${e}' in connector store`)}catch(e){console.error("Error retrieving JWT token:",e)}return null}async getJwtFromTokenRef(e){if(!e||!this.orgSlug)return console.warn("Missing required parameters for JWT token retrieval"),null;const t=this.getValidUserJwt(e);return t||this.getJwtFromTokenRefInternal(e)}async getUserToken(e){const t=e["ts-auth-token"]||process.env.TS_AUTH_TOKEN;if(t)return t;const r=e["ts-token-ref"];if(r&&this.connectorId){const e=await this.getJwtFromTokenRef(r);if(e)return e;console.warn("Failed to resolve ts-token-ref to JWT token")}else r&&console.error("Connector ID not configured");return console.warn("No valid authentication token found"),null}async getTokenFromExpressRequest(e){return this.getUserToken(e.cookies||{})}clearCache(){this.tokenCache.clear()}}const r=new t;class n extends Error{constructor(e){super(e),this.name="ProviderError"}}class o extends n{constructor(e){super(e),this.name="MissingTableError"}}class i extends n{constructor(e){super(e),this.name="QueryError"}}class s extends n{constructor(e){super(e),this.name="ProviderConnectionError"}}class a extends n{constructor(e){super(e),this.name="InvalidProviderConfigurationError"}}function c(e,t){if("object"!=typeof e||null===e)throw new a(`Invalid provider configuration at index ${t}: expected an object`);const r=e;if("string"!=typeof r.name)throw new a(`Invalid provider configuration at index ${t}: 'name' must be a string`);if("string"!=typeof r.type)throw new a(`Invalid provider configuration at index ${t}: 'type' must be a string`);if("object"!=typeof r.fields||null===r.fields)throw new a(`Invalid provider configuration at index ${t}: 'fields' must be an object`);return{name:r.name,type:r.type,iconUrl:"string"==typeof r.iconUrl?r.iconUrl:void 0,fields:r.fields}}class l{constructor(e){Object.defineProperty(this,"connection",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.connection=e}async query(e,t={}){const r=(Array.isArray(t),t);return new Promise((t,n)=>{this.connection.execute({sqlText:e,binds:r,complete:(e,r,o)=>{e?n(new i(`Snowflake provider failed to query the database. Reason: ${e.message}`)):t(o??[])}})})}async close(){return new Promise((e,t)=>{this.connection.destroy(r=>{r?t(r):e()})})}}async function u(e){const t=await async function(){try{const e=await import("snowflake-sdk");return e.default||e}catch{throw new a("The 'snowflake-sdk' package is required to use the Snowflake provider. Please install it: npm install snowflake-sdk")}}(),r=["user","password","account","warehouse","database","schema","role"];for(const t of r)if(!e.fields[t])throw new a(`Missing field '${t}' in the provider '${e.name}' to connect to Snowflake using password based authentication.`);const n={account:e.fields.account,username:e.fields.user,password:e.fields.password,warehouse:e.fields.warehouse,database:e.fields.database,schema:e.fields.schema,role:e.fields.role};return new Promise((e,r)=>{t.createConnection(n).connect((t,n)=>{t?r(new s(`Unable to connect to Snowflake. Reason: ${t.message}`)):n.execute({sqlText:"ALTER SESSION SET TIMEZONE = 'UTC'",complete:t=>{t&&console.warn(`Warning: Failed to set timezone to UTC: ${t.message}`),e(new l(n))}})})})}class d{constructor(e,t){Object.defineProperty(this,"client",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"session",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.client=e,this.session=t}async query(e,t={}){const r=await this.session.executeStatement(e);try{return await r.fetchAll()}finally{await r.close()}}async close(){await this.session.close(),await this.client.close()}}async function h(e){const{DBSQLClient:t}=await async function(){try{return await import("@databricks/sql")}catch{throw new a("The '@databricks/sql' package is required to use the Databricks provider. Please install it: npm install @databricks/sql")}}(),r=["server_hostname","http_path","client_id","client_secret","catalog"];for(const t of r)if(!e.fields[t])throw new a(`Missing field '${t}' in the provider '${e.name}' to connect to Databricks.`);const n=e.fields.server_hostname,o=e.fields.http_path,i=e.fields.client_id,s=e.fields.client_secret,c=e.fields.catalog,l=e.fields.schema??`${(process.env.ORG_SLUG??"").replace(/-/g,"_")}__tss__default`,u=new t;await u.connect({host:n,path:o,authType:"databricks-oauth",oauthClientId:i,oauthClientSecret:s});const h=await u.openSession({initialCatalog:c,initialSchema:l});return new d(u,h)}class f{constructor(e,t,r,n,o){Object.defineProperty(this,"client",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"sdk",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"workgroup",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"database",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"outputLocation",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.client=e,this.sdk=t,this.workgroup=r,this.database=n,this.outputLocation=o}async query(e,t={}){if(e.length>262144)throw new Error("Query length exceeds the maximum allowed limit.");const r=new this.sdk.StartQueryExecutionCommand({QueryString:e,WorkGroup:this.workgroup,QueryExecutionContext:{Database:this.database},ResultConfiguration:this.outputLocation?{OutputLocation:this.outputLocation}:void 0}),n=(await this.client.send(r)).QueryExecutionId;if(!n)throw new i("Failed to start query execution");return await this.waitForQueryCompletion(n,e),this.fetchAllResults(n)}async waitForQueryCompletion(e,t){const r=3e5,n=Date.now();for(;Date.now()-n<r;){const r=new this.sdk.GetQueryExecutionCommand({QueryExecutionId:e}),n=await this.client.send(r),s=n.QueryExecution?.Status?.State;if(s===this.sdk.QueryExecutionState.SUCCEEDED)return;if(s===this.sdk.QueryExecutionState.FAILED||s===this.sdk.QueryExecutionState.CANCELLED){const e=n.QueryExecution?.Status?.StateChangeReason??"Unknown error";if(e.includes("TABLE_NOT_FOUND")){const t=e.split(":").pop()?.trim()??"";throw new o("Athena is unable to find the table. If the table is created by a tetraflow, make sure that the tetraflow has run successfully. "+t+".")}throw new i(`Query failed: ${t}. Reason: ${e}`)}await new Promise(e=>setTimeout(e,1e3))}throw new i("Query timed out after 300 seconds")}async fetchAllResults(e){const t=[];let r,n=[],o=!0;do{const i=new this.sdk.GetQueryResultsCommand({QueryExecutionId:e,NextToken:r}),s=await this.client.send(i);o&&s.ResultSet?.ResultSetMetadata?.ColumnInfo&&(n=s.ResultSet.ResultSetMetadata.ColumnInfo.map((e,t)=>{const r=e.Name;return r&&""!==r.trim()?r:`column_${t}`}));const a=s.ResultSet?.Rows??[],c=o?a.slice(1):a;for(const e of c){const r={};e.Data?.forEach((e,t)=>{const o=n[t]??`column_${t}`;r[o]=e.VarCharValue??null}),t.push(r)}r=s.NextToken,o=!1}while(r);return t}async close(){this.client.destroy()}}async function p(){const e=await async function(){try{return await import("@aws-sdk/client-athena")}catch{throw new a("The '@aws-sdk/client-athena' package is required to use the Athena provider. Please install it: npm install @aws-sdk/client-athena")}}(),t=process.env.ORG_SLUG??"",r=t.replace(/-/g,"_"),n=process.env.ATHENA_S3_OUTPUT_LOCATION,o=process.env.AWS_REGION,i=`${r}__tss__default`,s=t,c=new e.AthenaClient({region:o});try{return await c.send(new e.GetWorkGroupCommand({WorkGroup:s})),new f(c,e,s,i)}catch{if(!n)throw new Error("ATHENA_S3_OUTPUT_LOCATION environment variable is required when using the 'primary' workgroup. Either set this variable or ensure the org-specific workgroup exists.");return new f(c,e,"primary",i,`s3://${n}/${r}/`)}}exports.AthenaProvider=f,exports.DatabricksProvider=d,exports.InvalidProviderConfigurationError=a,exports.JwtTokenManager=t,exports.MissingTableError=o,exports.ProviderConnectionError=s,exports.ProviderError=n,exports.QueryError=i,exports.SnowflakeProvider=l,exports.buildDatabricksProvider=h,exports.buildProvider=async function(e){switch(e.type){case"snowflake":return u(e);case"databricks":return h(e);case"athena":return p();default:throw new a(`Unsupported provider type: ${e.type}`)}},exports.buildSnowflakeProvider=u,exports.getProviderConfigurations=async function(e,t={}){const r=t.providerConfigOverride||process.env.DATA_APP_PROVIDER_CONFIG;if(r)return function(e){try{const t=JSON.parse(e);if(!Array.isArray(t))throw new a("Invalid provider configuration: expected an array of provider configurations");return t.map(c)}catch(e){if(e instanceof a)throw e;throw new a(`Invalid provider configuration JSON in DATA_APP_PROVIDER_CONFIG: ${e instanceof Error?e.message:String(e)}`)}}(r);if(!e.isInitialized)throw new Error("TDPClient is not initialized. Call await client.init() before using getProviderConfigurations.");const n=t.connectorId||process.env.CONNECTOR_ID;if(!n)return console.warn("Environment variable CONNECTOR_ID is not set. Unable to fetch providers."),[];const o=e.config.orgSlug,i=(await e.api.dataApps.getOrganizationBySlug(o)).id,s=await e.api.dataApps.getContainerDataApp(n),l=[];for(const t of s.providers){const r=await e.api.dataApps.getProviderById(t.id,i),n={};for(const e of r.secrets){const t=e.name,r=process.env[e.envName];n[t]=r}const o={name:r.name,type:r.type,iconUrl:r.iconUrl,fields:n};l.push(o)}return l},exports.getTdpAthenaProvider=p,exports.jwtManager=r;
2
- //# sourceMappingURL=server.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"server.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}