@walkeros/server-destination-gcp 0.5.0 → 0.5.1-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var e,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.prototype.hasOwnProperty,o={};((e,n)=>{for(var r in n)t(e,r,{get:n[r],enumerable:!0})})(o,{DestinationBigQuery:()=>p,destinationBigQuery:()=>b}),module.exports=(e=o,((e,o,a,s)=>{if(o&&"object"==typeof o||"function"==typeof o)for(let c of r(o))i.call(e,c)||c===a||t(e,c,{get:()=>o[c],enumerable:!(s=n(o,c))||s.enumerable});return e})(t({},"__esModule",{value:!0}),e));var a=require("@google-cloud/bigquery");var s=Object.defineProperty;((e,t)=>{for(var n in t)s(e,n,{get:t[n],enumerable:!0})})({},{Level:()=>g});var c,g=((c=g||{})[c.ERROR=0]="ERROR",c[c.INFO=1]="INFO",c[c.DEBUG=2]="DEBUG",c);function l(e){return Array.isArray(e)}function u(e){return"object"==typeof e&&null!==e&&!l(e)&&"[object Object]"===Object.prototype.toString.call(e)}var d=e=>Object.entries(e).reduce((e,[t,n])=>(e[t]=u(n)||l(n)?JSON.stringify(n):n,e),{}),p={},b={type:"gcp-bigquery",config:{},async init({config:e,env:t,logger:n}){const r=function(e={},t,n){const r=e.settings||{},{projectId:i,bigquery:o}=r;let{client:s,location:c,datasetId:g,tableId:l}=r;i||n.throw("Config settings projectId missing"),c=c||"EU",g=g||"walkeros",l=l||"events";const u=o||{};u.projectId=i;const d=(null==t?void 0:t.BigQuery)||a.BigQuery;s=s||new d(u);const p={...r,client:s,projectId:i,location:c,datasetId:g,tableId:l};return{...e,settings:p}}(e,t,n);return r},push:async(e,{config:t,mapping:n,data:r,collector:i,env:o,logger:a})=>await async function(e,{config:t,mapping:n,data:r,logger:i}){const{client:o,datasetId:a,tableId:s}=t.settings;if(!o)return i.throw("client is missing");if(!a)return i.throw("datasetId is missing");if(!s)return i.throw("tableId is missing");let c;if(u(r))c=r;else{const t=new Date;c={...e,timestamp:e.timestamp?new Date(e.timestamp):t,createdAt:t}}const g=[d(c)];i.debug("Calling BigQuery API",{dataset:a,table:s,rowCount:g.length}),await o.dataset(a).table(s).insert(g),i.debug("BigQuery API response",{ok:!0})}(e,{config:t,mapping:n,data:r,collector:i,env:o,logger:a})};//# sourceMappingURL=index.js.map
1
+ "use strict";var mod,__defProp=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropNames=Object.getOwnPropertyNames,__hasOwnProp=Object.prototype.hasOwnProperty,index_exports={};((target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})})(index_exports,{DestinationBigQuery:()=>types_exports,destinationBigQuery:()=>destinationBigQuery}),module.exports=(mod=index_exports,((to,from,except,desc)=>{if(from&&"object"==typeof from||"function"==typeof from)for(let key of __getOwnPropNames(from))__hasOwnProp.call(to,key)||key===except||__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to})(__defProp({},"__esModule",{value:!0}),mod));var import_bigquery=require("@google-cloud/bigquery");var e=Object.defineProperty;((t,n)=>{for(var r in n)e(t,r,{get:n[r],enumerable:!0})})({},{Level:()=>a});var e2,a=((e2=a||{})[e2.ERROR=0]="ERROR",e2[e2.INFO=1]="INFO",e2[e2.DEBUG=2]="DEBUG",e2);function A(e2){return Array.isArray(e2)}function _(e2){return"object"==typeof e2&&null!==e2&&!A(e2)&&"[object Object]"===Object.prototype.toString.call(e2)}var mapEvent=event=>Object.entries(event).reduce((acc,[key,value])=>(acc[key]=_(value)||A(value)?JSON.stringify(value):value,acc),{}),types_exports={},destinationBigQuery={type:"gcp-bigquery",config:{},async init({config:partialConfig,env:env,logger:logger}){const config=function(partialConfig={},env,logger){const settings=partialConfig.settings||{},{projectId:projectId,bigquery:bigquery}=settings;let{client:client,location:location,datasetId:datasetId,tableId:tableId}=settings;projectId||logger.throw("Config settings projectId missing"),location=location||"EU",datasetId=datasetId||"walkeros",tableId=tableId||"events";const options=bigquery||{};options.projectId=projectId;const BigQueryClass=(null==env?void 0:env.BigQuery)||import_bigquery.BigQuery;client=client||new BigQueryClass(options);const settingsConfig={...settings,client:client,projectId:projectId,location:location,datasetId:datasetId,tableId:tableId};return{...partialConfig,settings:settingsConfig}}(partialConfig,env,logger);return config},push:async(event,{config:config,mapping:mapping,data:data,collector:collector,env:env,logger:logger})=>await async function(event,{config:config,mapping:_mapping,data:data,logger:logger}){const{client:client,datasetId:datasetId,tableId:tableId}=config.settings;if(!client)return logger.throw("client is missing");if(!datasetId)return logger.throw("datasetId is missing");if(!tableId)return logger.throw("tableId is missing");let row;if(_(data))row=data;else{const now=new Date;row={...event,timestamp:event.timestamp?new Date(event.timestamp):now,createdAt:now}}const rows=[mapEvent(row)];logger.debug("Calling BigQuery API",{dataset:datasetId,table:tableId,rowCount:rows.length}),await client.dataset(datasetId).table(tableId).insert(rows),logger.debug("BigQuery API response",{ok:!0})}(event,{config:config,mapping:mapping,data:data,collector:collector,env:env,logger:logger})};//# sourceMappingURL=index.js.map
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{BigQuery as t}from"@google-cloud/bigquery";var e=Object.defineProperty;((t,n)=>{for(var i in n)e(t,i,{get:n[i],enumerable:!0})})({},{Level:()=>i});var n,i=((n=i||{})[n.ERROR=0]="ERROR",n[n.INFO=1]="INFO",n[n.DEBUG=2]="DEBUG",n);function r(t){return Array.isArray(t)}function o(t){return"object"==typeof t&&null!==t&&!r(t)&&"[object Object]"===Object.prototype.toString.call(t)}var a=t=>Object.entries(t).reduce((t,[e,n])=>(t[e]=o(n)||r(n)?JSON.stringify(n):n,t),{}),s={},c={type:"gcp-bigquery",config:{},async init({config:e,env:n,logger:i}){const r=function(e={},n,i){const r=e.settings||{},{projectId:o,bigquery:a}=r;let{client:s,location:c,datasetId:g,tableId:l}=r;o||i.throw("Config settings projectId missing"),c=c||"EU",g=g||"walkeros",l=l||"events";const d=a||{};d.projectId=o;const u=(null==n?void 0:n.BigQuery)||t;s=s||new u(d);const p={...r,client:s,projectId:o,location:c,datasetId:g,tableId:l};return{...e,settings:p}}(e,n,i);return r},push:async(t,{config:e,mapping:n,data:i,collector:r,env:s,logger:c})=>await async function(t,{config:e,mapping:n,data:i,logger:r}){const{client:s,datasetId:c,tableId:g}=e.settings;if(!s)return r.throw("client is missing");if(!c)return r.throw("datasetId is missing");if(!g)return r.throw("tableId is missing");let l;if(o(i))l=i;else{const e=new Date;l={...t,timestamp:t.timestamp?new Date(t.timestamp):e,createdAt:e}}const d=[a(l)];r.debug("Calling BigQuery API",{dataset:c,table:g,rowCount:d.length}),await s.dataset(c).table(g).insert(d),r.debug("BigQuery API response",{ok:!0})}(t,{config:e,mapping:n,data:i,collector:r,env:s,logger:c})};export{s as DestinationBigQuery,c as destinationBigQuery};//# sourceMappingURL=index.mjs.map
1
+ import{BigQuery}from"@google-cloud/bigquery";var e=Object.defineProperty;((t,n)=>{for(var r in n)e(t,r,{get:n[r],enumerable:!0})})({},{Level:()=>a});var e2,a=((e2=a||{})[e2.ERROR=0]="ERROR",e2[e2.INFO=1]="INFO",e2[e2.DEBUG=2]="DEBUG",e2);function A(e2){return Array.isArray(e2)}function _(e2){return"object"==typeof e2&&null!==e2&&!A(e2)&&"[object Object]"===Object.prototype.toString.call(e2)}var mapEvent=event=>Object.entries(event).reduce((acc,[key,value])=>(acc[key]=_(value)||A(value)?JSON.stringify(value):value,acc),{}),types_exports={},destinationBigQuery={type:"gcp-bigquery",config:{},async init({config:partialConfig,env:env,logger:logger}){const config=function(partialConfig={},env,logger){const settings=partialConfig.settings||{},{projectId:projectId,bigquery:bigquery}=settings;let{client:client,location:location,datasetId:datasetId,tableId:tableId}=settings;projectId||logger.throw("Config settings projectId missing"),location=location||"EU",datasetId=datasetId||"walkeros",tableId=tableId||"events";const options=bigquery||{};options.projectId=projectId;const BigQueryClass=(null==env?void 0:env.BigQuery)||BigQuery;client=client||new BigQueryClass(options);const settingsConfig={...settings,client:client,projectId:projectId,location:location,datasetId:datasetId,tableId:tableId};return{...partialConfig,settings:settingsConfig}}(partialConfig,env,logger);return config},push:async(event,{config:config,mapping:mapping,data:data,collector:collector,env:env,logger:logger})=>await async function(event,{config:config,mapping:_mapping,data:data,logger:logger}){const{client:client,datasetId:datasetId,tableId:tableId}=config.settings;if(!client)return logger.throw("client is missing");if(!datasetId)return logger.throw("datasetId is missing");if(!tableId)return logger.throw("tableId is missing");let row;if(_(data))row=data;else{const now=new Date;row={...event,timestamp:event.timestamp?new Date(event.timestamp):now,createdAt:now}}const rows=[mapEvent(row)];logger.debug("Calling BigQuery API",{dataset:datasetId,table:tableId,rowCount:rows.length}),await client.dataset(datasetId).table(tableId).insert(rows),logger.debug("BigQuery API response",{ok:!0})}(event,{config:config,mapping:mapping,data:data,collector:collector,env:env,logger:logger})};export{types_exports as DestinationBigQuery,destinationBigQuery};//# sourceMappingURL=index.mjs.map