@walkeros/server-destination-gcp 4.0.0 → 4.0.1-next-1778068549946

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
@@ -76,43 +76,95 @@ const { elb } = await startFlow({
76
76
  | ----------- | ----------------- | ------------------------------------------------ | -------- | ------------------------------------------ |
77
77
  | `client` | `BigQuery` | Google Cloud BigQuery client instance | Yes | `new BigQuery({ projectId, keyFilename })` |
78
78
  | `projectId` | `string` | Google Cloud Project ID | Yes | `'my-gcp-project'` |
79
- | `datasetId` | `string` | BigQuery dataset ID where events will be stored | Yes | `'walker_events'` |
80
- | `tableId` | `string` | BigQuery table ID for event storage | Yes | `'events'` |
81
- | `location` | `string` | Geographic location for the BigQuery dataset | No | `'US'` |
79
+ | `datasetId` | `string` | BigQuery dataset ID where events will be stored | No | `'walkerOS'` (default) |
80
+ | `tableId` | `string` | BigQuery table ID for event storage | No | `'events'` (default) |
81
+ | `location` | `string` | Geographic location for the BigQuery dataset | No | `'EU'` (default) |
82
82
  | `bigquery` | `BigQueryOptions` | Additional BigQuery client configuration options | No | `{ keyFilename: "path/to/key.json" }` |
83
83
 
84
- ## Table Schema
84
+ ## Setup (one-time provisioning)
85
85
 
86
- By default, the destination sends the full walkerOS event. Create the table
87
- with:
88
-
89
- ```sql
90
- CREATE TABLE IF NOT EXISTS `YOUR_PROJECT.walkeros.events` (
91
- timestamp TIMESTAMP,
92
- createdAt TIMESTAMP,
93
- name STRING,
94
- id STRING,
95
- entity STRING,
96
- action STRING,
97
- trigger STRING,
98
- `group` STRING,
99
- timing FLOAT64,
100
- count INT64,
101
- data STRING,
102
- context STRING,
103
- globals STRING,
104
- custom STRING,
105
- user STRING,
106
- nested STRING,
107
- consent STRING,
108
- version STRING,
109
- source STRING
110
- );
86
+ ```bash
87
+ walkeros setup destination.bigquery
111
88
  ```
112
89
 
113
- Object and array fields (`data`, `context`, `globals`, etc.) are JSON
114
- stringified. For custom schemas using the `data` mapping config, see the
115
- [full documentation](https://www.walkeros.io/docs/destinations/server/gcp).
90
+ Output: `setup: ok destination.bigquery` plus a JSON line with
91
+ `{ datasetCreated, tableCreated }`. Idempotent, safe to re-run.
92
+
93
+ IAM the operator service account needs:
94
+
95
+ - `bigquery.datasets.create`
96
+ - `bigquery.tables.create`
97
+ - `bigquery.datasets.get` (for drift detection)
98
+ - `bigquery.tables.get`
99
+
100
+ `config.setup`:
101
+
102
+ - `false` (default): no provisioning. Operator must run setup once explicitly.
103
+ - `true`: provision with defaults, `walkerOS` dataset, `events` table, `EU`
104
+ location, `PHYSICAL` storage billing, day partitioning on `timestamp`,
105
+ clustering on `(name, entity, action)`.
106
+ - `{ ...overrides }`: object form to override any default. See the `Setup`
107
+ interface in `src/bigquery/types/index.ts`.
108
+
109
+ If an existing table's partitioning, clustering, or schema differs from the
110
+ declared configuration, setup logs `WARN setup.drift {...}` and continues. No
111
+ auto-mutation.
112
+
113
+ ## Storage Write API (data plane)
114
+
115
+ The destination uses BigQuery's Storage Write API for data ingestion.
116
+
117
+ Note: the upstream `@google-cloud/bigquery-storage` package self-marks as
118
+ `EXPERIMENTAL` (subject to change). Pinned at `^5.1.0`.
119
+
120
+ ## Batching
121
+
122
+ `pushBatch` is implemented. Set the collector's `batch: <ms>` mapping setting to
123
+ enable batching:
124
+
125
+ ```jsonc
126
+ {
127
+ "destinations": {
128
+ "bigquery": {
129
+ "package": "@walkeros/server-destination-gcp",
130
+ "config": {
131
+ "settings": { "projectId": "..." },
132
+ "setup": true,
133
+ "mapping": { "batch": 1000 },
134
+ },
135
+ },
136
+ },
137
+ }
138
+ ```
139
+
140
+ `batch: 1000` (1 second) is a reasonable default for analytics workloads. All
141
+ events buffered within the window flush as a single `appendRows` call.
142
+
143
+ ## Table Schema
144
+
145
+ The default 15-column schema (walkerOS Event v4 canonical order):
146
+
147
+ | Column | Type | Mode |
148
+ | ----------- | --------- | -------- |
149
+ | `name` | STRING | REQUIRED |
150
+ | `data` | JSON | NULLABLE |
151
+ | `context` | JSON | NULLABLE |
152
+ | `globals` | JSON | NULLABLE |
153
+ | `custom` | JSON | NULLABLE |
154
+ | `user` | JSON | NULLABLE |
155
+ | `nested` | JSON | NULLABLE |
156
+ | `consent` | JSON | NULLABLE |
157
+ | `id` | STRING | NULLABLE |
158
+ | `trigger` | STRING | NULLABLE |
159
+ | `entity` | STRING | NULLABLE |
160
+ | `action` | STRING | NULLABLE |
161
+ | `timestamp` | TIMESTAMP | NULLABLE |
162
+ | `timing` | INT64 | NULLABLE |
163
+ | `source` | JSON | NULLABLE |
164
+
165
+ For custom schemas, override `config.setup.schema`. See the
166
+ [full documentation](https://www.walkeros.io/docs/destinations/server/gcp) for
167
+ custom mapping examples.
116
168
 
117
169
  ## Type Definitions
118
170
 
package/dist/dev.d.mts CHANGED
@@ -1,4 +1,6 @@
1
1
  import * as _walkeros_core_dev from '@walkeros/core/dev';
2
+ import * as _google_cloud_bigquery_storage from '@google-cloud/bigquery-storage';
3
+ import { managedwriter } from '@google-cloud/bigquery-storage';
2
4
  import { DestinationServer } from '@walkeros/server-core';
3
5
  import { BigQuery } from '@google-cloud/bigquery';
4
6
  import { Flow, Hint } from '@walkeros/core';
@@ -14,6 +16,10 @@ declare namespace schemas {
14
16
 
15
17
  interface Env extends DestinationServer.Env {
16
18
  BigQuery?: typeof BigQuery;
19
+ WriterClient?: typeof managedwriter.WriterClient;
20
+ JSONWriter?: typeof managedwriter.JSONWriter;
21
+ adapt?: typeof _google_cloud_bigquery_storage.adapt;
22
+ managedwriterModule?: typeof managedwriter;
17
23
  }
18
24
 
19
25
  /**
package/dist/dev.d.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  import * as _walkeros_core_dev from '@walkeros/core/dev';
2
+ import * as _google_cloud_bigquery_storage from '@google-cloud/bigquery-storage';
3
+ import { managedwriter } from '@google-cloud/bigquery-storage';
2
4
  import { DestinationServer } from '@walkeros/server-core';
3
5
  import { BigQuery } from '@google-cloud/bigquery';
4
6
  import { Flow, Hint } from '@walkeros/core';
@@ -14,6 +16,10 @@ declare namespace schemas {
14
16
 
15
17
  interface Env extends DestinationServer.Env {
16
18
  BigQuery?: typeof BigQuery;
19
+ WriterClient?: typeof managedwriter.WriterClient;
20
+ JSONWriter?: typeof managedwriter.JSONWriter;
21
+ adapt?: typeof _google_cloud_bigquery_storage.adapt;
22
+ managedwriterModule?: typeof managedwriter;
17
23
  }
18
24
 
19
25
  /**