@walkeros/server-destination-gcp 0.0.7 → 0.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/README.md CHANGED
@@ -1,30 +1,19 @@
1
1
  <p align="left">
2
2
  <a href="https://elbwalker.com">
3
- <img title="elbwalker" src='https://www.elbwalker.com/img/elbwalker_logo.png' width="256px"/>
3
+ <img title="elbwalker" src="https://www.elbwalker.com/img/elbwalker_logo.png" width="256px"/>
4
4
  </a>
5
5
  </p>
6
6
 
7
- # Google Cloud Platform (GCP) Destination for walkerOS
7
+ # GCP (BigQuery) Destination for walkerOS
8
8
 
9
- This package provides a Google Cloud Platform (GCP) destination for walkerOS. It
10
- allows you to send events to Google BigQuery.
9
+ [Source Code](https://github.com/elbwalker/walkerOS/tree/main/packages/server/destinations/gcp)
10
+ &bull;
11
+ [NPM Package](https://www.npmjs.com/package/@walkeros/server-destination-gcp)
11
12
 
12
- [View documentation](https://www.elbwalker.com/docs/destinations/server/gcp/)
13
-
14
- ## Role in walkerOS Ecosystem
15
-
16
- walkerOS follows a **source → collector → destination** architecture:
17
-
18
- - **Sources**: Capture events from various environments (browser DOM, dataLayer,
19
- server requests)
20
- - **Collector**: Processes, validates, and routes events with consent awareness
21
- - **Destinations**: Send processed events to analytics platforms (GA4, Meta,
22
- custom APIs)
23
-
24
- This GCP destination receives processed events from the walkerOS collector and
25
- streams them to Google BigQuery, enabling real-time data warehousing and
26
- analytics with Google Cloud's powerful data processing and machine learning
27
- capabilities.
13
+ walkerOS follows a **source → collector → destination** architecture. This GCP
14
+ destination receives processed events from the walkerOS collector and streams
15
+ them to Google BigQuery, enabling real-time data warehousing and analytics with
16
+ Google Cloud's powerful data processing and machine learning capabilities.
28
17
 
29
18
  ## Installation
30
19
 
@@ -34,14 +23,14 @@ npm install @walkeros/server-destination-gcp
34
23
 
35
24
  ## Usage
36
25
 
37
- Here's a basic example of how to use the GCP destination:
26
+ Here's a basic example of how to use the GCP BigQuery destination:
38
27
 
39
28
  ```typescript
40
29
  import { elb } from '@walkeros/collector';
41
30
  import { destinationBigQuery } from '@walkeros/server-destination-gcp';
42
31
 
43
32
  elb('walker destination', destinationBigQuery, {
44
- custom: {
33
+ settings: {
45
34
  projectId: 'YOUR_PROJECT_ID',
46
35
  datasetId: 'YOUR_DATASET_ID',
47
36
  tableId: 'YOUR_TABLE_ID',
@@ -49,6 +38,17 @@ elb('walker destination', destinationBigQuery, {
49
38
  });
50
39
  ```
51
40
 
41
+ ## Configuration
42
+
43
+ | Name | Type | Description | Required | Example |
44
+ | ----------- | ----------------- | ------------------------------------------------ | -------- | ------------------------------------------ |
45
+ | `client` | `BigQuery` | Google Cloud BigQuery client instance | Yes | `new BigQuery({ projectId, keyFilename })` |
46
+ | `projectId` | `string` | Google Cloud Project ID | Yes | `'my-gcp-project'` |
47
+ | `datasetId` | `string` | BigQuery dataset ID where events will be stored | Yes | `'walker_events'` |
48
+ | `tableId` | `string` | BigQuery table ID for event storage | Yes | `'events'` |
49
+ | `location` | `string` | Geographic location for the BigQuery dataset | No | `'US'` |
50
+ | `bigquery` | `BigQueryOptions` | Additional BigQuery client configuration options | No | `{ keyFilename: "path/to/key.json" }` |
51
+
52
52
  ## Contribute
53
53
 
54
54
  Feel free to contribute by submitting an
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var e,t,r,n=Object.defineProperty,o=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,s=Object.prototype.hasOwnProperty,a={};((e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})})(a,{DestinationBigQuery:()=>y,destinationBigQuery:()=>f}),module.exports=(e=a,((e,t,r,a)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let c of i(t))s.call(e,c)||c===r||n(e,c,{get:()=>t[c],enumerable:!(a=o(t,c))||a.enumerable});return e})(n({},"__esModule",{value:!0}),e));var c=Object.getOwnPropertyNames,l=(t={"package.json"(e,t){t.exports={name:"@walkeros/core",description:"Core types and platform-agnostic utilities for walkerOS",version:"0.0.7",main:"./dist/index.js",module:"./dist/index.mjs",types:"./dist/index.d.ts",license:"MIT",files:["dist/**"],scripts:{build:"tsup --silent",clean:"rm -rf .turbo && rm -rf node_modules && rm -rf dist",dev:"jest --watchAll --colors",lint:'tsc && eslint "**/*.ts*"',test:"jest",update:"npx npm-check-updates -u && npm update"},dependencies:{},devDependencies:{},repository:{url:"git+https://github.com/elbwalker/walkerOS.git",directory:"packages/core"},author:"elbwalker <hello@elbwalker.com>",homepage:"https://github.com/elbwalker/walkerOS#readme",bugs:{url:"https://github.com/elbwalker/walkerOS/issues"},keywords:["walker","walkerOS","analytics","tracking","data collection","measurement","data privacy","privacy friendly","web analytics","product analytics","core","types","utils"],funding:[{type:"GitHub Sponsors",url:"https://github.com/sponsors/elbwalker"}]}}},function(){return r||(0,t[c(t)[0]])((r={exports:{}}).exports,r),r.exports});function p(e){return Array.isArray(e)}function d(e){return"object"==typeof e&&null!==e&&!p(e)&&"[object Object]"===Object.prototype.toString.call(e)}var{version:u}=l();var g=require("@google-cloud/bigquery");function b(e={}){const t=e.settings||{},{projectId:r,bigquery:n}=t;let{client:o,location:i,datasetId:s,tableId:a}=t;r||function(e){throw new Error(String(e))}("Config settings projectId missing"),i=i||"EU",s=s||"walkeros",a=a||"events";const c=n||{};c.projectId=r,o=o||new g.BigQuery(c);const l={...t,client:o,projectId:r,location:i,datasetId:s,tableId:a};return{...e,settings:l}}var m=e=>Object.entries(e).reduce((e,[t,r])=>(e[t]=d(r)||p(r)?JSON.stringify(r):r,e),{}),y={},f={type:"gcp-bigquery",config:{},init:async({config:e})=>b(e),push:async(e,{config:t,mapping:r,data:n,collector:o,wrap:i})=>await async function(e,{config:t,mapping:r,data:n,collector:o,wrap:i}){const{client:s,datasetId:a,tableId:c}=t.settings;let l;if(d(n))l=n;else{const t=new Date;l={...e,timestamp:e.timestamp?new Date(e.timestamp):t,createdAt:t}}const p=[m(l)];await s.dataset(a).table(c).insert(p)}(e,{config:t,mapping:r,data:n,collector:o,wrap:i})};//# sourceMappingURL=index.js.map
1
+ "use strict";var e,t,r,n=Object.defineProperty,o=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,s=Object.prototype.hasOwnProperty,a={};((e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})})(a,{DestinationBigQuery:()=>y,destinationBigQuery:()=>f}),module.exports=(e=a,((e,t,r,a)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let c of i(t))s.call(e,c)||c===r||n(e,c,{get:()=>t[c],enumerable:!(a=o(t,c))||a.enumerable});return e})(n({},"__esModule",{value:!0}),e));var c=Object.getOwnPropertyNames,l=(t={"package.json"(e,t){t.exports={name:"@walkeros/core",description:"Core types and platform-agnostic utilities for walkerOS",version:"0.1.0",main:"./dist/index.js",module:"./dist/index.mjs",types:"./dist/index.d.ts",license:"MIT",files:["dist/**"],scripts:{build:"tsup --silent",clean:"rm -rf .turbo && rm -rf node_modules && rm -rf dist",dev:"jest --watchAll --colors",lint:'tsc && eslint "**/*.ts*"',test:"jest",update:"npx npm-check-updates -u && npm update"},dependencies:{},devDependencies:{},repository:{url:"git+https://github.com/elbwalker/walkerOS.git",directory:"packages/core"},author:"elbwalker <hello@elbwalker.com>",homepage:"https://github.com/elbwalker/walkerOS#readme",bugs:{url:"https://github.com/elbwalker/walkerOS/issues"},keywords:["walker","walkerOS","analytics","tracking","data collection","measurement","data privacy","privacy friendly","web analytics","product analytics","core","types","utils"],funding:[{type:"GitHub Sponsors",url:"https://github.com/sponsors/elbwalker"}]}}},function(){return r||(0,t[c(t)[0]])((r={exports:{}}).exports,r),r.exports});function p(e){return Array.isArray(e)}function d(e){return"object"==typeof e&&null!==e&&!p(e)&&"[object Object]"===Object.prototype.toString.call(e)}var{version:u}=l();var g=require("@google-cloud/bigquery");function b(e={}){const t=e.settings||{},{projectId:r,bigquery:n}=t;let{client:o,location:i,datasetId:s,tableId:a}=t;r||function(e){throw new Error(String(e))}("Config settings projectId missing"),i=i||"EU",s=s||"walkeros",a=a||"events";const c=n||{};c.projectId=r,o=o||new g.BigQuery(c);const l={...t,client:o,projectId:r,location:i,datasetId:s,tableId:a};return{...e,settings:l}}var m=e=>Object.entries(e).reduce((e,[t,r])=>(e[t]=d(r)||p(r)?JSON.stringify(r):r,e),{}),y={},f={type:"gcp-bigquery",config:{},init:async({config:e})=>b(e),push:async(e,{config:t,mapping:r,data:n,collector:o,env:i})=>await async function(e,{config:t,mapping:r,data:n,collector:o,env:i}){const{client:s,datasetId:a,tableId:c}=t.settings;let l;if(d(n))l=n;else{const t=new Date;l={...e,timestamp:e.timestamp?new Date(e.timestamp):t,createdAt:t}}const p=[m(l)];await s.dataset(a).table(c).insert(p)}(e,{config:t,mapping:r,data:n,collector:o,env:i})};//# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/bigquery/config.ts","../src/bigquery/push.ts","../src/bigquery/types/index.ts","../src/bigquery/index.ts"],"sourcesContent":["// Google BigQuery\nexport { destinationBigQuery } from './bigquery';\nexport * as DestinationBigQuery from './bigquery/types';\n","import type { Config, PartialConfig, Settings } from './types';\nimport type { BigQueryOptions } from '@google-cloud/bigquery';\nimport { throwError } from '@walkeros/core';\nimport { BigQuery } from '@google-cloud/bigquery';\n\nexport function getConfig(partialConfig: PartialConfig = {}): Config {\n const settings = partialConfig.settings || ({} as Settings);\n const { projectId, bigquery } = settings;\n let { client, location, datasetId, tableId } = settings;\n\n if (!projectId) throwError('Config settings projectId missing');\n\n location = location || 'EU';\n datasetId = datasetId || 'walkeros';\n tableId = tableId || 'events';\n\n const options: BigQueryOptions = bigquery || {};\n options.projectId = projectId;\n\n client = client || new BigQuery(options);\n\n const settingsConfig: Settings = {\n ...settings,\n client,\n projectId,\n location,\n datasetId,\n tableId,\n };\n\n return { ...partialConfig, settings: settingsConfig };\n}\n","import type { WalkerOS } from '@walkeros/core';\nimport type { PushFn } from './types';\nimport { isObject, isArray } from '@walkeros/core';\n\nexport const push: PushFn = async function (\n event,\n { config, mapping: _mapping, data, collector, wrap },\n) {\n const { client, datasetId, tableId } = config.settings!;\n\n let row: WalkerOS.AnyObject | undefined;\n\n if (isObject(data)) {\n row = data;\n } else {\n const now = new Date();\n row = {\n ...event,\n timestamp: event.timestamp ? new Date(event.timestamp) : now,\n createdAt: now,\n };\n }\n\n const rows = [mapEvent(row)];\n\n await client.dataset(datasetId).table(tableId).insert(rows);\n\n return;\n};\n\nexport const mapEvent = (event: WalkerOS.AnyObject) => {\n return Object.entries(event).reduce<WalkerOS.AnyObject>(\n (acc, [key, value]) => {\n acc[key] =\n isObject(value) || isArray(value) ? JSON.stringify(value) : value;\n return acc;\n },\n {},\n );\n};\n","import type { DestinationServer } from '@walkeros/server-core';\nimport type { Mapping as WalkerOSMapping, Elb } from '@walkeros/core';\nimport type { BigQuery, BigQueryOptions } from '@google-cloud/bigquery';\n\ndeclare global {\n // Augment the global WalkerOS namespace with destination-specific types\n namespace WalkerOS {\n interface Elb extends Elb.RegisterDestination<Destination, Config> {}\n }\n}\n\nexport interface Destination\n extends DestinationServer.Destination<Settings, Mapping> {\n init: DestinationServer.InitFn<Settings, Mapping>;\n}\n\nexport type Config = {\n settings: Settings;\n} & DestinationServer.Config<Settings, Mapping>;\n\nexport interface Settings {\n client: BigQuery;\n projectId: string;\n datasetId: string;\n tableId: string;\n location?: string;\n bigquery?: BigQueryOptions;\n}\n\nexport interface Mapping {\n // Custom destination event mapping properties\n}\n\nexport type InitFn = DestinationServer.InitFn<Settings, Mapping>;\nexport type PushFn = DestinationServer.PushFn<Settings, Mapping>;\n\nexport type PartialConfig = DestinationServer.PartialConfig<Settings, Mapping>;\n\nexport type PushEvents = DestinationServer.PushEvents<Mapping>;\n\nexport type Rule = WalkerOSMapping.Rule<Mapping>;\nexport type Rules = WalkerOSMapping.Rules<Rule>;\n","import type { Destination } from './types';\nimport { getConfig } from './config';\nimport { push } from './push';\n\n// Types\nexport * as DestinationBigQuery from './types';\n\nexport const destinationBigQuery: Destination = {\n type: 'gcp-bigquery',\n\n config: {},\n\n async init({ config: partialConfig }) {\n const config = getConfig(partialConfig);\n\n return config;\n },\n\n async push(event, { config, mapping, data, collector, wrap }) {\n return await push(event, { config, mapping, data, collector, wrap });\n },\n};\n\nexport default destinationBigQuery;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;A;;;;;;;;;;;;;;;;;;;;;;ACGA,sBAAyB;AAElB,SAAS,UAAU,gBAA+B,CAAC,GAAW;AACnE,QAAM,WAAW,cAAc,YAAa,CAAC;AAC7C,QAAM,EAAE,WAAW,SAAS,IAAI;AAChC,MAAI,EAAE,QAAQ,UAAU,WAAW,QAAQ,IAAI;AAE/C,MAAI,CAAC,UAAW,IAAW,mCAAmC;AAE9D,aAAW,YAAY;AACvB,cAAY,aAAa;AACzB,YAAU,WAAW;AAErB,QAAM,UAA2B,YAAY,CAAC;AAC9C,UAAQ,YAAY;AAEpB,WAAS,UAAU,IAAI,yBAAS,OAAO;AAEvC,QAAM,iBAA2B;AAAA,IAC/B,GAAG;AAAA,IACH;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAEA,SAAO,EAAE,GAAG,eAAe,UAAU,eAAe;AACtD;;;AC3BO,IAAM,OAAe,eAC1B,OACA,EAAE,QAAQ,SAAS,UAAU,MAAM,WAAW,KAAK,GACnD;AACA,QAAM,EAAE,QAAQ,WAAW,QAAQ,IAAI,OAAO;AAE9C,MAAI;AAEJ,MAAI,EAAS,IAAI,GAAG;AAClB,UAAM;AAAA,EACR,OAAO;AACL,UAAM,MAAM,oBAAI,KAAK;AACrB,UAAM;AAAA,MACJ,GAAG;AAAA,MACH,WAAW,MAAM,YAAY,IAAI,KAAK,MAAM,SAAS,IAAI;AAAA,MACzD,WAAW;AAAA,IACb;AAAA,EACF;AAEA,QAAM,OAAO,CAAC,SAAS,GAAG,CAAC;AAE3B,QAAM,OAAO,QAAQ,SAAS,EAAE,MAAM,OAAO,EAAE,OAAO,IAAI;AAE1D;AACF;AAEO,IAAM,WAAW,CAAC,UAA8B;AACrD,SAAO,OAAO,QAAQ,KAAK,EAAE;AAAA,IAC3B,CAAC,KAAK,CAAC,KAAK,KAAK,MAAM;AACrB,UAAI,GAAG,IACL,EAAS,KAAK,KAAK,EAAQ,KAAK,IAAI,KAAK,UAAU,KAAK,IAAI;AAC9D,aAAO;AAAA,IACT;AAAA,IACA,CAAC;AAAA,EACH;AACF;;;ACvCA;;;ACOO,IAAM,sBAAmC;AAAA,EAC9C,MAAM;AAAA,EAEN,QAAQ,CAAC;AAAA,EAET,MAAM,KAAK,EAAE,QAAQ,cAAc,GAAG;AACpC,UAAM,SAAS,UAAU,aAAa;AAEtC,WAAO;AAAA,EACT;AAAA,EAEA,MAAM,KAAK,OAAO,EAAE,QAAQ,SAAS,MAAM,WAAW,KAAK,GAAG;AAC5D,WAAO,MAAM,KAAK,OAAO,EAAE,QAAQ,SAAS,MAAM,WAAW,KAAK,CAAC;AAAA,EACrE;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts","../src/bigquery/config.ts","../src/bigquery/push.ts","../src/bigquery/types/index.ts","../src/bigquery/index.ts"],"sourcesContent":["// Google BigQuery\nexport { destinationBigQuery } from './bigquery';\nexport * as DestinationBigQuery from './bigquery/types';\n","import type { Config, PartialConfig, Settings } from './types';\nimport type { BigQueryOptions } from '@google-cloud/bigquery';\nimport { throwError } from '@walkeros/core';\nimport { BigQuery } from '@google-cloud/bigquery';\n\nexport function getConfig(partialConfig: PartialConfig = {}): Config {\n const settings = partialConfig.settings || ({} as Settings);\n const { projectId, bigquery } = settings;\n let { client, location, datasetId, tableId } = settings;\n\n if (!projectId) throwError('Config settings projectId missing');\n\n location = location || 'EU';\n datasetId = datasetId || 'walkeros';\n tableId = tableId || 'events';\n\n const options: BigQueryOptions = bigquery || {};\n options.projectId = projectId;\n\n client = client || new BigQuery(options);\n\n const settingsConfig: Settings = {\n ...settings,\n client,\n projectId,\n location,\n datasetId,\n tableId,\n };\n\n return { ...partialConfig, settings: settingsConfig };\n}\n","import type { WalkerOS } from '@walkeros/core';\nimport type { PushFn } from './types';\nimport { isObject, isArray } from '@walkeros/core';\n\nexport const push: PushFn = async function (\n event,\n { config, mapping: _mapping, data, collector, env },\n) {\n const { client, datasetId, tableId } = config.settings!;\n\n let row: WalkerOS.AnyObject | undefined;\n\n if (isObject(data)) {\n row = data;\n } else {\n const now = new Date();\n row = {\n ...event,\n timestamp: event.timestamp ? new Date(event.timestamp) : now,\n createdAt: now,\n };\n }\n\n const rows = [mapEvent(row)];\n\n await client.dataset(datasetId).table(tableId).insert(rows);\n\n return;\n};\n\nexport const mapEvent = (event: WalkerOS.AnyObject) => {\n return Object.entries(event).reduce<WalkerOS.AnyObject>(\n (acc, [key, value]) => {\n acc[key] =\n isObject(value) || isArray(value) ? JSON.stringify(value) : value;\n return acc;\n },\n {},\n );\n};\n","import type { DestinationServer } from '@walkeros/server-core';\nimport type { Mapping as WalkerOSMapping, Elb } from '@walkeros/core';\nimport type { BigQuery, BigQueryOptions } from '@google-cloud/bigquery';\n\ndeclare global {\n // Augment the global WalkerOS namespace with destination-specific types\n namespace WalkerOS {\n interface Elb extends Elb.RegisterDestination<Destination, Config> {}\n }\n}\n\nexport interface Destination\n extends DestinationServer.Destination<Settings, Mapping> {\n init: DestinationServer.InitFn<Settings, Mapping>;\n}\n\nexport type Config = {\n settings: Settings;\n} & DestinationServer.Config<Settings, Mapping>;\n\nexport interface Settings {\n client: BigQuery;\n projectId: string;\n datasetId: string;\n tableId: string;\n location?: string;\n bigquery?: BigQueryOptions;\n}\n\nexport interface Mapping {\n // Custom destination event mapping properties\n}\n\nexport type InitFn = DestinationServer.InitFn<Settings, Mapping>;\nexport type PushFn = DestinationServer.PushFn<Settings, Mapping>;\n\nexport type PartialConfig = DestinationServer.PartialConfig<Settings, Mapping>;\n\nexport type PushEvents = DestinationServer.PushEvents<Mapping>;\n\nexport type Rule = WalkerOSMapping.Rule<Mapping>;\nexport type Rules = WalkerOSMapping.Rules<Rule>;\n","import type { Destination } from './types';\nimport { getConfig } from './config';\nimport { push } from './push';\n\n// Types\nexport * as DestinationBigQuery from './types';\n\nexport const destinationBigQuery: Destination = {\n type: 'gcp-bigquery',\n\n config: {},\n\n async init({ config: partialConfig }) {\n const config = getConfig(partialConfig);\n\n return config;\n },\n\n async push(event, { config, mapping, data, collector, env }) {\n return await push(event, { config, mapping, data, collector, env });\n },\n};\n\nexport default destinationBigQuery;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;A;;;;;;;;;;;;;;;;;;;;;;ACGA,sBAAyB;AAElB,SAAS,UAAU,gBAA+B,CAAC,GAAW;AACnE,QAAM,WAAW,cAAc,YAAa,CAAC;AAC7C,QAAM,EAAE,WAAW,SAAS,IAAI;AAChC,MAAI,EAAE,QAAQ,UAAU,WAAW,QAAQ,IAAI;AAE/C,MAAI,CAAC,UAAW,IAAW,mCAAmC;AAE9D,aAAW,YAAY;AACvB,cAAY,aAAa;AACzB,YAAU,WAAW;AAErB,QAAM,UAA2B,YAAY,CAAC;AAC9C,UAAQ,YAAY;AAEpB,WAAS,UAAU,IAAI,yBAAS,OAAO;AAEvC,QAAM,iBAA2B;AAAA,IAC/B,GAAG;AAAA,IACH;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAEA,SAAO,EAAE,GAAG,eAAe,UAAU,eAAe;AACtD;;;AC3BO,IAAM,OAAe,eAC1B,OACA,EAAE,QAAQ,SAAS,UAAU,MAAM,WAAW,IAAI,GAClD;AACA,QAAM,EAAE,QAAQ,WAAW,QAAQ,IAAI,OAAO;AAE9C,MAAI;AAEJ,MAAI,EAAS,IAAI,GAAG;AAClB,UAAM;AAAA,EACR,OAAO;AACL,UAAM,MAAM,oBAAI,KAAK;AACrB,UAAM;AAAA,MACJ,GAAG;AAAA,MACH,WAAW,MAAM,YAAY,IAAI,KAAK,MAAM,SAAS,IAAI;AAAA,MACzD,WAAW;AAAA,IACb;AAAA,EACF;AAEA,QAAM,OAAO,CAAC,SAAS,GAAG,CAAC;AAE3B,QAAM,OAAO,QAAQ,SAAS,EAAE,MAAM,OAAO,EAAE,OAAO,IAAI;AAE1D;AACF;AAEO,IAAM,WAAW,CAAC,UAA8B;AACrD,SAAO,OAAO,QAAQ,KAAK,EAAE;AAAA,IAC3B,CAAC,KAAK,CAAC,KAAK,KAAK,MAAM;AACrB,UAAI,GAAG,IACL,EAAS,KAAK,KAAK,EAAQ,KAAK,IAAI,KAAK,UAAU,KAAK,IAAI;AAC9D,aAAO;AAAA,IACT;AAAA,IACA,CAAC;AAAA,EACH;AACF;;;ACvCA;;;ACOO,IAAM,sBAAmC;AAAA,EAC9C,MAAM;AAAA,EAEN,QAAQ,CAAC;AAAA,EAET,MAAM,KAAK,EAAE,QAAQ,cAAc,GAAG;AACpC,UAAM,SAAS,UAAU,aAAa;AAEtC,WAAO;AAAA,EACT;AAAA,EAEA,MAAM,KAAK,OAAO,EAAE,QAAQ,SAAS,MAAM,WAAW,IAAI,GAAG;AAC3D,WAAO,MAAM,KAAK,OAAO,EAAE,QAAQ,SAAS,MAAM,WAAW,IAAI,CAAC;AAAA,EACpE;AACF;","names":[]}
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- var t,e,r=Object.getOwnPropertyNames,s=(t={"package.json"(t,e){e.exports={name:"@walkeros/core",description:"Core types and platform-agnostic utilities for walkerOS",version:"0.0.7",main:"./dist/index.js",module:"./dist/index.mjs",types:"./dist/index.d.ts",license:"MIT",files:["dist/**"],scripts:{build:"tsup --silent",clean:"rm -rf .turbo && rm -rf node_modules && rm -rf dist",dev:"jest --watchAll --colors",lint:'tsc && eslint "**/*.ts*"',test:"jest",update:"npx npm-check-updates -u && npm update"},dependencies:{},devDependencies:{},repository:{url:"git+https://github.com/elbwalker/walkerOS.git",directory:"packages/core"},author:"elbwalker <hello@elbwalker.com>",homepage:"https://github.com/elbwalker/walkerOS#readme",bugs:{url:"https://github.com/elbwalker/walkerOS/issues"},keywords:["walker","walkerOS","analytics","tracking","data collection","measurement","data privacy","privacy friendly","web analytics","product analytics","core","types","utils"],funding:[{type:"GitHub Sponsors",url:"https://github.com/sponsors/elbwalker"}]}}},function(){return e||(0,t[r(t)[0]])((e={exports:{}}).exports,e),e.exports});function i(t){return Array.isArray(t)}function n(t){return"object"==typeof t&&null!==t&&!i(t)&&"[object Object]"===Object.prototype.toString.call(t)}var{version:a}=s();import{BigQuery as o}from"@google-cloud/bigquery";function c(t={}){const e=t.settings||{},{projectId:r,bigquery:s}=e;let{client:i,location:n,datasetId:a,tableId:c}=e;r||function(t){throw new Error(String(t))}("Config settings projectId missing"),n=n||"EU",a=a||"walkeros",c=c||"events";const l=s||{};l.projectId=r,i=i||new o(l);const p={...e,client:i,projectId:r,location:n,datasetId:a,tableId:c};return{...t,settings:p}}var l=t=>Object.entries(t).reduce((t,[e,r])=>(t[e]=n(r)||i(r)?JSON.stringify(r):r,t),{}),p={},d={type:"gcp-bigquery",config:{},init:async({config:t})=>c(t),push:async(t,{config:e,mapping:r,data:s,collector:i,wrap:a})=>await async function(t,{config:e,mapping:r,data:s,collector:i,wrap:a}){const{client:o,datasetId:c,tableId:p}=e.settings;let d;if(n(s))d=s;else{const e=new Date;d={...t,timestamp:t.timestamp?new Date(t.timestamp):e,createdAt:e}}const u=[l(d)];await o.dataset(c).table(p).insert(u)}(t,{config:e,mapping:r,data:s,collector:i,wrap:a})};export{p as DestinationBigQuery,d as destinationBigQuery};//# sourceMappingURL=index.mjs.map
1
+ var e,t,n=Object.getOwnPropertyNames,r=(e={"package.json"(e,t){t.exports={name:"@walkeros/core",description:"Core types and platform-agnostic utilities for walkerOS",version:"0.1.0",main:"./dist/index.js",module:"./dist/index.mjs",types:"./dist/index.d.ts",license:"MIT",files:["dist/**"],scripts:{build:"tsup --silent",clean:"rm -rf .turbo && rm -rf node_modules && rm -rf dist",dev:"jest --watchAll --colors",lint:'tsc && eslint "**/*.ts*"',test:"jest",update:"npx npm-check-updates -u && npm update"},dependencies:{},devDependencies:{},repository:{url:"git+https://github.com/elbwalker/walkerOS.git",directory:"packages/core"},author:"elbwalker <hello@elbwalker.com>",homepage:"https://github.com/elbwalker/walkerOS#readme",bugs:{url:"https://github.com/elbwalker/walkerOS/issues"},keywords:["walker","walkerOS","analytics","tracking","data collection","measurement","data privacy","privacy friendly","web analytics","product analytics","core","types","utils"],funding:[{type:"GitHub Sponsors",url:"https://github.com/sponsors/elbwalker"}]}}},function(){return t||(0,e[n(e)[0]])((t={exports:{}}).exports,t),t.exports});function s(e){return Array.isArray(e)}function i(e){return"object"==typeof e&&null!==e&&!s(e)&&"[object Object]"===Object.prototype.toString.call(e)}var{version:a}=r();import{BigQuery as o}from"@google-cloud/bigquery";function c(e={}){const t=e.settings||{},{projectId:n,bigquery:r}=t;let{client:s,location:i,datasetId:a,tableId:c}=t;n||function(e){throw new Error(String(e))}("Config settings projectId missing"),i=i||"EU",a=a||"walkeros",c=c||"events";const l=r||{};l.projectId=n,s=s||new o(l);const p={...t,client:s,projectId:n,location:i,datasetId:a,tableId:c};return{...e,settings:p}}var l=e=>Object.entries(e).reduce((e,[t,n])=>(e[t]=i(n)||s(n)?JSON.stringify(n):n,e),{}),p={},d={type:"gcp-bigquery",config:{},init:async({config:e})=>c(e),push:async(e,{config:t,mapping:n,data:r,collector:s,env:a})=>await async function(e,{config:t,mapping:n,data:r,collector:s,env:a}){const{client:o,datasetId:c,tableId:p}=t.settings;let d;if(i(r))d=r;else{const t=new Date;d={...e,timestamp:e.timestamp?new Date(e.timestamp):t,createdAt:t}}const u=[l(d)];await o.dataset(c).table(p).insert(u)}(e,{config:t,mapping:n,data:r,collector:s,env:a})};export{p as DestinationBigQuery,d as destinationBigQuery};//# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/bigquery/config.ts","../src/bigquery/push.ts","../src/bigquery/types/index.ts","../src/bigquery/index.ts"],"sourcesContent":["import type { Config, PartialConfig, Settings } from './types';\nimport type { BigQueryOptions } from '@google-cloud/bigquery';\nimport { throwError } from '@walkeros/core';\nimport { BigQuery } from '@google-cloud/bigquery';\n\nexport function getConfig(partialConfig: PartialConfig = {}): Config {\n const settings = partialConfig.settings || ({} as Settings);\n const { projectId, bigquery } = settings;\n let { client, location, datasetId, tableId } = settings;\n\n if (!projectId) throwError('Config settings projectId missing');\n\n location = location || 'EU';\n datasetId = datasetId || 'walkeros';\n tableId = tableId || 'events';\n\n const options: BigQueryOptions = bigquery || {};\n options.projectId = projectId;\n\n client = client || new BigQuery(options);\n\n const settingsConfig: Settings = {\n ...settings,\n client,\n projectId,\n location,\n datasetId,\n tableId,\n };\n\n return { ...partialConfig, settings: settingsConfig };\n}\n","import type { WalkerOS } from '@walkeros/core';\nimport type { PushFn } from './types';\nimport { isObject, isArray } from '@walkeros/core';\n\nexport const push: PushFn = async function (\n event,\n { config, mapping: _mapping, data, collector, wrap },\n) {\n const { client, datasetId, tableId } = config.settings!;\n\n let row: WalkerOS.AnyObject | undefined;\n\n if (isObject(data)) {\n row = data;\n } else {\n const now = new Date();\n row = {\n ...event,\n timestamp: event.timestamp ? new Date(event.timestamp) : now,\n createdAt: now,\n };\n }\n\n const rows = [mapEvent(row)];\n\n await client.dataset(datasetId).table(tableId).insert(rows);\n\n return;\n};\n\nexport const mapEvent = (event: WalkerOS.AnyObject) => {\n return Object.entries(event).reduce<WalkerOS.AnyObject>(\n (acc, [key, value]) => {\n acc[key] =\n isObject(value) || isArray(value) ? JSON.stringify(value) : value;\n return acc;\n },\n {},\n );\n};\n","import type { DestinationServer } from '@walkeros/server-core';\nimport type { Mapping as WalkerOSMapping, Elb } from '@walkeros/core';\nimport type { BigQuery, BigQueryOptions } from '@google-cloud/bigquery';\n\ndeclare global {\n // Augment the global WalkerOS namespace with destination-specific types\n namespace WalkerOS {\n interface Elb extends Elb.RegisterDestination<Destination, Config> {}\n }\n}\n\nexport interface Destination\n extends DestinationServer.Destination<Settings, Mapping> {\n init: DestinationServer.InitFn<Settings, Mapping>;\n}\n\nexport type Config = {\n settings: Settings;\n} & DestinationServer.Config<Settings, Mapping>;\n\nexport interface Settings {\n client: BigQuery;\n projectId: string;\n datasetId: string;\n tableId: string;\n location?: string;\n bigquery?: BigQueryOptions;\n}\n\nexport interface Mapping {\n // Custom destination event mapping properties\n}\n\nexport type InitFn = DestinationServer.InitFn<Settings, Mapping>;\nexport type PushFn = DestinationServer.PushFn<Settings, Mapping>;\n\nexport type PartialConfig = DestinationServer.PartialConfig<Settings, Mapping>;\n\nexport type PushEvents = DestinationServer.PushEvents<Mapping>;\n\nexport type Rule = WalkerOSMapping.Rule<Mapping>;\nexport type Rules = WalkerOSMapping.Rules<Rule>;\n","import type { Destination } from './types';\nimport { getConfig } from './config';\nimport { push } from './push';\n\n// Types\nexport * as DestinationBigQuery from './types';\n\nexport const destinationBigQuery: Destination = {\n type: 'gcp-bigquery',\n\n config: {},\n\n async init({ config: partialConfig }) {\n const config = getConfig(partialConfig);\n\n return config;\n },\n\n async push(event, { config, mapping, data, collector, wrap }) {\n return await push(event, { config, mapping, data, collector, wrap });\n },\n};\n\nexport default destinationBigQuery;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAGA,SAAS,gBAAgB;AAElB,SAAS,UAAU,gBAA+B,CAAC,GAAW;AACnE,QAAM,WAAW,cAAc,YAAa,CAAC;AAC7C,QAAM,EAAE,WAAW,SAAS,IAAI;AAChC,MAAI,EAAE,QAAQ,UAAU,WAAW,QAAQ,IAAI;AAE/C,MAAI,CAAC,UAAW,IAAW,mCAAmC;AAE9D,aAAW,YAAY;AACvB,cAAY,aAAa;AACzB,YAAU,WAAW;AAErB,QAAM,UAA2B,YAAY,CAAC;AAC9C,UAAQ,YAAY;AAEpB,WAAS,UAAU,IAAI,SAAS,OAAO;AAEvC,QAAM,iBAA2B;AAAA,IAC/B,GAAG;AAAA,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/config.ts","../src/bigquery/push.ts","../src/bigquery/types/index.ts","../src/bigquery/index.ts"],"sourcesContent":["import type { Config, PartialConfig, Settings } from './types';\nimport type { BigQueryOptions } from '@google-cloud/bigquery';\nimport { throwError } from '@walkeros/core';\nimport { BigQuery } from '@google-cloud/bigquery';\n\nexport function getConfig(partialConfig: PartialConfig = {}): Config {\n const settings = partialConfig.settings || ({} as Settings);\n const { projectId, bigquery } = settings;\n let { client, location, datasetId, tableId } = settings;\n\n if (!projectId) throwError('Config settings projectId missing');\n\n location = location || 'EU';\n datasetId = datasetId || 'walkeros';\n tableId = tableId || 'events';\n\n const options: BigQueryOptions = bigquery || {};\n options.projectId = projectId;\n\n client = client || new BigQuery(options);\n\n const settingsConfig: Settings = {\n ...settings,\n client,\n projectId,\n location,\n datasetId,\n tableId,\n };\n\n return { ...partialConfig, settings: settingsConfig };\n}\n","import type { WalkerOS } from '@walkeros/core';\nimport type { PushFn } from './types';\nimport { isObject, isArray } from '@walkeros/core';\n\nexport const push: PushFn = async function (\n event,\n { config, mapping: _mapping, data, collector, env },\n) {\n const { client, datasetId, tableId } = config.settings!;\n\n let row: WalkerOS.AnyObject | undefined;\n\n if (isObject(data)) {\n row = data;\n } else {\n const now = new Date();\n row = {\n ...event,\n timestamp: event.timestamp ? new Date(event.timestamp) : now,\n createdAt: now,\n };\n }\n\n const rows = [mapEvent(row)];\n\n await client.dataset(datasetId).table(tableId).insert(rows);\n\n return;\n};\n\nexport const mapEvent = (event: WalkerOS.AnyObject) => {\n return Object.entries(event).reduce<WalkerOS.AnyObject>(\n (acc, [key, value]) => {\n acc[key] =\n isObject(value) || isArray(value) ? JSON.stringify(value) : value;\n return acc;\n },\n {},\n );\n};\n","import type { DestinationServer } from '@walkeros/server-core';\nimport type { Mapping as WalkerOSMapping, Elb } from '@walkeros/core';\nimport type { BigQuery, BigQueryOptions } from '@google-cloud/bigquery';\n\ndeclare global {\n // Augment the global WalkerOS namespace with destination-specific types\n namespace WalkerOS {\n interface Elb extends Elb.RegisterDestination<Destination, Config> {}\n }\n}\n\nexport interface Destination\n extends DestinationServer.Destination<Settings, Mapping> {\n init: DestinationServer.InitFn<Settings, Mapping>;\n}\n\nexport type Config = {\n settings: Settings;\n} & DestinationServer.Config<Settings, Mapping>;\n\nexport interface Settings {\n client: BigQuery;\n projectId: string;\n datasetId: string;\n tableId: string;\n location?: string;\n bigquery?: BigQueryOptions;\n}\n\nexport interface Mapping {\n // Custom destination event mapping properties\n}\n\nexport type InitFn = DestinationServer.InitFn<Settings, Mapping>;\nexport type PushFn = DestinationServer.PushFn<Settings, Mapping>;\n\nexport type PartialConfig = DestinationServer.PartialConfig<Settings, Mapping>;\n\nexport type PushEvents = DestinationServer.PushEvents<Mapping>;\n\nexport type Rule = WalkerOSMapping.Rule<Mapping>;\nexport type Rules = WalkerOSMapping.Rules<Rule>;\n","import type { Destination } from './types';\nimport { getConfig } from './config';\nimport { push } from './push';\n\n// Types\nexport * as DestinationBigQuery from './types';\n\nexport const destinationBigQuery: Destination = {\n type: 'gcp-bigquery',\n\n config: {},\n\n async init({ config: partialConfig }) {\n const config = getConfig(partialConfig);\n\n return config;\n },\n\n async push(event, { config, mapping, data, collector, env }) {\n return await push(event, { config, mapping, data, collector, env });\n },\n};\n\nexport default destinationBigQuery;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAGA,SAAS,gBAAgB;AAElB,SAAS,UAAU,gBAA+B,CAAC,GAAW;AACnE,QAAM,WAAW,cAAc,YAAa,CAAC;AAC7C,QAAM,EAAE,WAAW,SAAS,IAAI;AAChC,MAAI,EAAE,QAAQ,UAAU,WAAW,QAAQ,IAAI;AAE/C,MAAI,CAAC,UAAW,IAAW,mCAAmC;AAE9D,aAAW,YAAY;AACvB,cAAY,aAAa;AACzB,YAAU,WAAW;AAErB,QAAM,UAA2B,YAAY,CAAC;AAC9C,UAAQ,YAAY;AAEpB,WAAS,UAAU,IAAI,SAAS,OAAO;AAEvC,QAAM,iBAA2B;AAAA,IAC/B,GA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-1,7 +1,7 @@
1
1
  {
2
2
  "name": "@walkeros/server-destination-gcp",
3
3
  "description": "Google Cloud Platform server destination for walkerOS (BigQuery)",
4
- "version": "0.0.7",
4
+ "version": "0.1.0",
5
5
  "license": "MIT",
6
6
  "main": "./dist/index.js",
7
7
  "module": "./dist/index.mjs",
@@ -19,7 +19,7 @@
19
19
  },
20
20
  "dependencies": {
21
21
  "@google-cloud/bigquery": "^7.8.0",
22
- "@walkeros/server-core": "0.0.7"
22
+ "@walkeros/server-core": "0.1.0"
23
23
  },
24
24
  "devDependencies": {},
25
25
  "repository": {