@particle-academy/google-analytics-ui 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/CHANGELOG.md ADDED
@@ -0,0 +1,58 @@
1
+ # Changelog
2
+
3
+ All notable changes to `@particle-academy/google-analytics-ui`,
4
+ `@particle-academy/google-analytics-js`,
5
+ `particle-academy/google-analytics-php` and `fancy-google-analytics`.
6
+
7
+ The four packages share one version, because they are generated from one
8
+ `provider/` definition and a version that meant something different in each
9
+ would be a version nobody could reason about.
10
+
11
+ ## [0.1.0] — 2026-08-23
12
+
13
+ First release.
14
+
15
+ ### Added
16
+
17
+ - `report_run` — run a report against a GA4 property.
18
+ `POST /v1beta/{+property}:runReport`.
19
+ - A faker for it, so a flow can be built with no Google account.
20
+
21
+ ### `{+property}` — the plus is the whole point
22
+
23
+ RFC 6570 **reserved expansion**. The value is `properties/1234567890` and the
24
+ **slash must survive**: percent-encoded it becomes `properties%2F1234567890` and
25
+ Google answers 404.
26
+
27
+ That is the exact opposite of Google Sheets, where a sheet named `Q1/Q2` *must*
28
+ have its slash escaped or the request reaches a different document. The two
29
+ templates are **one character apart** and both fail silently when confused — so
30
+ each runtime now picks its encoder from the `+`: `encodeURI` rather than
31
+ `encodeURIComponent`, `quote(safe="/")` rather than `quote(safe="")`, and in PHP
32
+ the slash is put back after `rawurlencode`, since PHP has no reserved-expansion
33
+ encoder at all.
34
+
35
+ ### `metrics` is a list of NAMED OBJECTS
36
+
37
+ Google asks for `[{"name": "activeUsers"}]`, not `["activeUsers"]`; a bare list
38
+ of strings is refused as the wrong type. That is `encoding: "objects"` with an
39
+ `itemKey`, declared rather than guessed — a guess that fits one provider is
40
+ still a guess.
41
+
42
+ ### The only read-only action in the estate
43
+
44
+ `sideEffects: "none"`. Running the same report twice returns the same numbers
45
+ and changes nothing, so a durable run may replay it freely and there is no
46
+ idempotency question at all.
47
+
48
+ The scope is `analytics.readonly`, not `analytics`. The discovery document lists
49
+ both for this method, and granting write access to run a report would let an
50
+ automation modify property configuration it never needs to touch.
51
+
52
+ ### Metric values are STRINGS
53
+
54
+ Google sends `"412"`, not `412` — including for integer metrics. The faker says
55
+ so, because a fixture that emitted numbers would let an author write arithmetic
56
+ that works against the fake and concatenates against the real thing.
57
+
58
+ [0.1.0]: https://github.com/Fancy-Friends/google-analytics/releases/tag/v0.1.0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Particle Academy
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,51 @@
1
+ # Google Analytics
2
+
3
+ Google Analytics for [fancy-flow][flow] — as **four imported, versioned packages**, one
4
+ per runtime. Not vendored source: a copy cannot be upgraded, and third-party APIs
5
+ change.
6
+
7
+ [flow]: https://github.com/Particle-Academy/fancy-flow
8
+
9
+ | Runtime | Package | Install |
10
+ |---|---|---|
11
+ | Authoring surface (every host) | `@particle-academy/google-analytics-ui` | `npm install @particle-academy/google-analytics-ui` |
12
+ | Node | `@particle-academy/google-analytics-js` | `npm install @particle-academy/google-analytics-js` |
13
+ | PHP 8.4+ | `particle-academy/google-analytics-php` | `composer require particle-academy/google-analytics-php` |
14
+ | Python 3.11+ | `fancy-google-analytics` | `pip install fancy-google-analytics` |
15
+
16
+ The `ui` package is the editor surface and is React on every host — a PHP or
17
+ Python project installs it *and* its own runtime package, and never the `js` one.
18
+
19
+ ## What it costs you
20
+
21
+ One dependency: `@particle-academy/fancy-connector-core` (or
22
+ `particle-academy/fancy-connector-core` on Composer), which the `js` and `php`
23
+ packages pull in themselves. The Python package has **zero** runtime
24
+ dependencies.
25
+
26
+ **No Google Analytics SDK.** Plain HTTP, deliberately: a vendor SDK is third-party code
27
+ subject to the kit's full approval bar, and one per provider is hundreds of
28
+ dependencies nobody is tracking.
29
+
30
+ ## Run it before you have credentials
31
+
32
+ Every operation ships a **faker**, whether or not Google Analytics has a sandbox. Set a
33
+ node's mode to `fake` and it returns the shape Google Analytics actually publishes — the
34
+ same field names, deterministically — so you can wire the downstream nodes before
35
+ touching an account, a key, or a network.
36
+
37
+ ## This repository is generated
38
+
39
+ `provider/` is the source. Everything under `packages/` is emitted from it and
40
+ **must not be hand-edited** — CI regenerates and diffs on every push, and the
41
+ next protocol sync destroys anything it finds. See [`AGENTS.md`](AGENTS.md).
42
+
43
+ ## Two namespaces, which do not match on purpose
44
+
45
+ The repo is `github.com/Fancy-Friends/google-analytics`; the packages publish under
46
+ `particle-academy`. Nothing derives one from the other — the names come from
47
+ weaver's `friends.json` and nowhere else.
48
+
49
+ ## Licence
50
+
51
+ MIT.
package/dist/index.cjs ADDED
@@ -0,0 +1,150 @@
1
+ 'use strict';
2
+
3
+ var connectors = require('@particle-academy/fancy-flow/connectors');
4
+
5
+ // src/service.ts
6
+ var CONNECTOR_API_VERSION = 1;
7
+ var GOOGLE_ANALYTICS_SERVICE = {
8
+ service: "google_analytics",
9
+ serviceTitle: "Google Analytics",
10
+ domain: "analytics",
11
+ sandbox: "none"
12
+ };
13
+ var GOOGLE_ANALYTICS_CREDENTIALS = [
14
+ {
15
+ "key": "clientId",
16
+ "label": "OAuth client ID",
17
+ "scope": "provider",
18
+ "secret": false,
19
+ "help": "From Google Cloud Console -> APIs & Services -> Credentials. ONE value for the whole installation, not per connected account."
20
+ },
21
+ {
22
+ "key": "clientSecret",
23
+ "label": "OAuth client secret",
24
+ "scope": "provider",
25
+ "secret": true,
26
+ "help": "The client secret for the same OAuth app. One value for the whole installation."
27
+ },
28
+ {
29
+ "key": "accessToken",
30
+ "label": "Access token",
31
+ "scope": "account",
32
+ "secret": true,
33
+ "help": "Per connected Google account, and it expires after ONE HOUR. The host refreshes it with the refresh token."
34
+ },
35
+ {
36
+ "key": "refreshToken",
37
+ "label": "Refresh token",
38
+ "scope": "account",
39
+ "secret": true,
40
+ "help": "Per connected Google account. Google issues one only when the consent request asks for offline access."
41
+ }
42
+ ];
43
+ var GOOGLE_ANALYTICS_OAUTH = {
44
+ "flow": "authorization_code",
45
+ "authorizeUrl": "https://accounts.google.com/o/oauth2/v2/auth",
46
+ "tokenUrl": "https://oauth2.googleapis.com/token",
47
+ "scopes": [
48
+ "https://www.googleapis.com/auth/analytics.readonly"
49
+ ],
50
+ "accessTokenCredential": "accessToken",
51
+ "refreshTokenCredential": "refreshToken",
52
+ "accessTokenTtlSeconds": 3600
53
+ };
54
+ function googleAnalyticsMeta(role, operation, docs) {
55
+ return { ...GOOGLE_ANALYTICS_SERVICE, role, operation, docs };
56
+ }
57
+ var GOOGLE_ANALYTICS_REPORT_KIND = "@particle-academy/google_analytics_report";
58
+ var GOOGLE_ANALYTICS_REPORT_OPERATION = "report_run";
59
+ var GOOGLE_ANALYTICS_REPORT_META = googleAnalyticsMeta("action", "run a report", "https://developers.google.com/analytics/devguides/reporting/data/v1/rest/v1beta/properties/runReport");
60
+ var GOOGLE_ANALYTICS_REPORT_OUTPUT = [
61
+ {
62
+ "path": "data.rows",
63
+ "type": "array",
64
+ "description": "One entry per combination of dimension values. Each carries dimensionValues and metricValues, in the order requested."
65
+ },
66
+ {
67
+ "path": "data.rowCount",
68
+ "type": "number",
69
+ "description": "Total rows matching the query, which can exceed the rows returned."
70
+ },
71
+ {
72
+ "path": "data.metricHeaders",
73
+ "type": "array",
74
+ "description": "The metrics in the order their values appear in each row -- the only thing that says which number is which."
75
+ }
76
+ ];
77
+ var googleAnalyticsReportKind = connectors.defineConnectorKind(GOOGLE_ANALYTICS_REPORT_META, {
78
+ name: GOOGLE_ANALYTICS_REPORT_KIND,
79
+ aliases: ["google_analytics_report"],
80
+ label: "Google Analytics report",
81
+ description: "Run a report against a Google Analytics 4 property.",
82
+ inputs: [{ id: "in" }],
83
+ outputs: [{ id: "out" }],
84
+ sideEffects: "none",
85
+ outputShape: GOOGLE_ANALYTICS_REPORT_OUTPUT,
86
+ configSchema: [
87
+ {
88
+ "type": "text",
89
+ "key": "property",
90
+ "label": "Property",
91
+ "required": true,
92
+ "default": "properties/",
93
+ "description": "The GA4 property, written as `properties/1234567890`. The numeric id alone is not accepted."
94
+ },
95
+ {
96
+ "type": "text",
97
+ "key": "startDate",
98
+ "label": "Start date",
99
+ "required": true,
100
+ "default": "28daysAgo",
101
+ "description": "YYYY-MM-DD, or a relative form Google accepts such as `28daysAgo`, `yesterday` or `today`."
102
+ },
103
+ {
104
+ "type": "text",
105
+ "key": "endDate",
106
+ "label": "End date",
107
+ "required": true,
108
+ "default": "today",
109
+ "description": "YYYY-MM-DD, or a relative form such as `today`."
110
+ },
111
+ {
112
+ "type": "text",
113
+ "key": "metrics",
114
+ "label": "Metrics",
115
+ "required": true,
116
+ "default": "activeUsers,sessions",
117
+ "description": "Metric names, comma separated. For example activeUsers, sessions, screenPageViews."
118
+ },
119
+ {
120
+ "type": "text",
121
+ "key": "dimensions",
122
+ "label": "Dimensions",
123
+ "default": "date",
124
+ "description": "Dimension names, comma separated. For example date, country, pagePath. Leave empty for a single total row."
125
+ }
126
+ ],
127
+ defaultConfig: {
128
+ "mode": "auto"
129
+ },
130
+ renderBody: ({ config }) => connectors.summarize(GOOGLE_ANALYTICS_REPORT_META, config, "run a report")
131
+ });
132
+
133
+ // src/index.ts
134
+ var GOOGLE_ANALYTICS_KINDS = [
135
+ googleAnalyticsReportKind
136
+ ];
137
+
138
+ exports.CONNECTOR_API_VERSION = CONNECTOR_API_VERSION;
139
+ exports.GOOGLE_ANALYTICS_CREDENTIALS = GOOGLE_ANALYTICS_CREDENTIALS;
140
+ exports.GOOGLE_ANALYTICS_KINDS = GOOGLE_ANALYTICS_KINDS;
141
+ exports.GOOGLE_ANALYTICS_OAUTH = GOOGLE_ANALYTICS_OAUTH;
142
+ exports.GOOGLE_ANALYTICS_REPORT_KIND = GOOGLE_ANALYTICS_REPORT_KIND;
143
+ exports.GOOGLE_ANALYTICS_REPORT_META = GOOGLE_ANALYTICS_REPORT_META;
144
+ exports.GOOGLE_ANALYTICS_REPORT_OPERATION = GOOGLE_ANALYTICS_REPORT_OPERATION;
145
+ exports.GOOGLE_ANALYTICS_REPORT_OUTPUT = GOOGLE_ANALYTICS_REPORT_OUTPUT;
146
+ exports.GOOGLE_ANALYTICS_SERVICE = GOOGLE_ANALYTICS_SERVICE;
147
+ exports.googleAnalyticsMeta = googleAnalyticsMeta;
148
+ exports.googleAnalyticsReportKind = googleAnalyticsReportKind;
149
+ //# sourceMappingURL=index.cjs.map
150
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/service.ts","../src/kinds/report-run.ts","../src/index.ts"],"names":["defineConnectorKind","summarize"],"mappings":";;;;;AAkCO,IAAM,qBAAA,GAAwB;AAG9B,IAAM,wBAAA,GAA2B;AAAA,EACtC,OAAA,EAAS,kBAAA;AAAA,EACT,YAAA,EAAc,kBAAA;AAAA,EACd,MAAA,EAAQ,WAAA;AAAA,EACR,OAAA,EAAS;AACX;AAGO,IAAM,4BAAA,GAA+B;AAAA,EAC1C;AAAA,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AA,EAAe;AAAA,KACjB;AAAA,IACA;AAAA,MACE,MAAA,EAAQ,MAAA;AAAA,MACR,KAAA,EAAO,SAAA;AAAA,MACP,OAAA,EAAS,SAAA;AAAA,MACT,UAAA,EAAY,IAAA;AAAA,MACZ,SAAA,EAAW,sBAAA;AAAA,MACX,aAAA,EAAe;AAAA,KACjB;AAAA,IACA;AAAA,MACE,MAAA,EAAQ,MAAA;AAAA,MACR,KAAA,EAAO,YAAA;AAAA,MACP,OAAA,EAAS,YAAA;AAAA,MACT,SAAA,EAAW,MAAA;AAAA,MACX,aAAA,EAAe;AAAA;AACjB,GACF;AAAA,EACA,aAAA,EAAe;AAAA,IACb,MAAA,EAAQ;AAAA,GACV;AAAA,EACA,UAAA,EAAY,CAAC,EAAE,MAAA,OACbC,oBAAA,CAAU,4BAAA,EAA8B,QAAmC,cAAc;AAC7F,CAAC;;;AClFM,IAAM,sBAAA,GAA+C;AAAA,EAC1D;AACF","file":"index.cjs","sourcesContent":["/**\n * GENERATED FILE — do not edit.\n *\n * Emitted from provider/manifest.json by weaver's generator.\n * A hand-edit here is destroyed by the next protocol sync, which is worse than\n * being rejected, because it works until it silently does not. Fix\n * provider/manifest.json (or weaver's template/) and regenerate:\n *\n * npm run provider -- google_analytics\n */\n\n/**\n * Google Analytics's identity on the authoring surface, shared by every Google\n * Analytics node.\n *\n * This file must import nothing from the js package: a PHP or Python project\n * installs the ui package and never that one, and the import would be a\n * dangling module the moment it did.\n *\n * ## The sandbox trap\n *\n * Google Analytics has no sandbox. A report reads a real property's real data\n * and spends real quota. The faker returns a plausibly-shaped report so a flow\n * can be built without a Google account.\n */\n\nimport type { ConnectorMeta } from \"@particle-academy/fancy-flow/connectors\";\n\n/**\n * The connector API version this package was GENERATED against.\n *\n * A literal, never imported — an imported constant lets an upgrade rewrite the\n * very claim it exists to detect.\n */\nexport const CONNECTOR_API_VERSION = 1;\n\n/** The parts of a connector's identity that belong to the SERVICE, not the node. */\nexport const GOOGLE_ANALYTICS_SERVICE = {\n service: \"google_analytics\",\n serviceTitle: \"Google Analytics\",\n domain: \"analytics\",\n sandbox: \"none\",\n} as const satisfies Pick<ConnectorMeta, \"service\" | \"serviceTitle\" | \"domain\" | \"sandbox\">;\n\n/** The credentials a Google Analytics connection holds. */\nexport const GOOGLE_ANALYTICS_CREDENTIALS = [\n {\n \"key\": \"clientId\",\n \"label\": \"OAuth client ID\",\n \"scope\": \"provider\",\n \"secret\": false,\n \"help\": \"From Google Cloud Console -> APIs & Services -> Credentials. ONE value for the whole installation, not per connected account.\"\n },\n {\n \"key\": \"clientSecret\",\n \"label\": \"OAuth client secret\",\n \"scope\": \"provider\",\n \"secret\": true,\n \"help\": \"The client secret for the same OAuth app. One value for the whole installation.\"\n },\n {\n \"key\": \"accessToken\",\n \"label\": \"Access token\",\n \"scope\": \"account\",\n \"secret\": true,\n \"help\": \"Per connected Google account, and it expires after ONE HOUR. The host refreshes it with the refresh token.\"\n },\n {\n \"key\": \"refreshToken\",\n \"label\": \"Refresh token\",\n \"scope\": \"account\",\n \"secret\": true,\n \"help\": \"Per connected Google account. Google issues one only when the consent request asks for offline access.\"\n }\n] as const;\n\n/**\n * The OAuth2 exchange Google Analytics requires — DECLARED here, performed by\n * the host.\n *\n * A consent screen needs a browser, a redirect URI and somewhere to persist\n * the result, and all three belong to the host; a package that ran the dance\n * itself would have to own a web server. So this says precisely enough for a\n * host to do it.\n *\n * The access token lasts 3600 seconds. A host that never refreshes will work\n * all afternoon and be broken by morning, which is why the lifetime is stated\n * rather than left to be discovered.\n */\nexport const GOOGLE_ANALYTICS_OAUTH = {\n \"flow\": \"authorization_code\",\n \"authorizeUrl\": \"https://accounts.google.com/o/oauth2/v2/auth\",\n \"tokenUrl\": \"https://oauth2.googleapis.com/token\",\n \"scopes\": [\n \"https://www.googleapis.com/auth/analytics.readonly\"\n ],\n \"accessTokenCredential\": \"accessToken\",\n \"refreshTokenCredential\": \"refreshToken\",\n \"accessTokenTtlSeconds\": 3600\n} as const;\n\n/** Build a Google Analytics node's connector metadata from the operation it performs. */\nexport function googleAnalyticsMeta(\n role: ConnectorMeta[\"role\"],\n operation: string,\n docs: string,\n): ConnectorMeta {\n return { ...GOOGLE_ANALYTICS_SERVICE, role, operation, docs };\n}\n","/**\n * GENERATED FILE — do not edit.\n *\n * Emitted from provider/actions/report-run.json by weaver's generator.\n * A hand-edit here is destroyed by the next protocol sync, which is worse than\n * being rejected, because it works until it silently does not. Fix\n * provider/actions/report-run.json (or weaver's template/) and regenerate:\n *\n * npm run provider -- google_analytics\n */\n\n/**\n * Google Analytics report — Run a report against a Google Analytics 4\n * property.\n *\n * https://developers.google.com/analytics/devguides/reporting/data/v1/rest/v1beta/properties/runReport\n */\n\nimport type { NodeKindDefinition } from \"@particle-academy/fancy-flow/engine\";\nimport { defineConnectorKind, summarize, type OutputField } from \"@particle-academy/fancy-flow/connectors\";\nimport { googleAnalyticsMeta } from \"../service.js\";\n\nexport const GOOGLE_ANALYTICS_REPORT_KIND = \"@particle-academy/google_analytics_report\";\nexport const GOOGLE_ANALYTICS_REPORT_OPERATION = \"report_run\";\n\nexport const GOOGLE_ANALYTICS_REPORT_META = googleAnalyticsMeta(\"action\", \"run a report\", \"https://developers.google.com/analytics/devguides/reporting/data/v1/rest/v1beta/properties/runReport\");\n\n/**\n * What this node emits — the \"ingredients\" a downstream node can reference.\n *\n * fancy-flow reads `outputShape` off the kind and offers it in the variable\n * picker, so declaring it is the whole of the work: an author configuring the\n * next node picks `{{ $json.data.id }}` off a list instead of typing a path\n * and hoping.\n */\nexport const GOOGLE_ANALYTICS_REPORT_OUTPUT: OutputField[] = [\n {\n \"path\": \"data.rows\",\n \"type\": \"array\",\n \"description\": \"One entry per combination of dimension values. Each carries dimensionValues and metricValues, in the order requested.\"\n },\n {\n \"path\": \"data.rowCount\",\n \"type\": \"number\",\n \"description\": \"Total rows matching the query, which can exceed the rows returned.\"\n },\n {\n \"path\": \"data.metricHeaders\",\n \"type\": \"array\",\n \"description\": \"The metrics in the order their values appear in each row -- the only thing that says which number is which.\"\n }\n];\n\nexport const googleAnalyticsReportKind: NodeKindDefinition = defineConnectorKind(GOOGLE_ANALYTICS_REPORT_META, {\n name: GOOGLE_ANALYTICS_REPORT_KIND,\n aliases: [\"google_analytics_report\"],\n label: \"Google Analytics report\",\n description: \"Run a report against a Google Analytics 4 property.\",\n inputs: [{ id: \"in\" }],\n outputs: [{ id: \"out\" }],\n sideEffects: \"none\",\n outputShape: GOOGLE_ANALYTICS_REPORT_OUTPUT,\n configSchema: [\n {\n \"type\": \"text\",\n \"key\": \"property\",\n \"label\": \"Property\",\n \"required\": true,\n \"default\": \"properties/\",\n \"description\": \"The GA4 property, written as `properties/1234567890`. The numeric id alone is not accepted.\"\n },\n {\n \"type\": \"text\",\n \"key\": \"startDate\",\n \"label\": \"Start date\",\n \"required\": true,\n \"default\": \"28daysAgo\",\n \"description\": \"YYYY-MM-DD, or a relative form Google accepts such as `28daysAgo`, `yesterday` or `today`.\"\n },\n {\n \"type\": \"text\",\n \"key\": \"endDate\",\n \"label\": \"End date\",\n \"required\": true,\n \"default\": \"today\",\n \"description\": \"YYYY-MM-DD, or a relative form such as `today`.\"\n },\n {\n \"type\": \"text\",\n \"key\": \"metrics\",\n \"label\": \"Metrics\",\n \"required\": true,\n \"default\": \"activeUsers,sessions\",\n \"description\": \"Metric names, comma separated. For example activeUsers, sessions, screenPageViews.\"\n },\n {\n \"type\": \"text\",\n \"key\": \"dimensions\",\n \"label\": \"Dimensions\",\n \"default\": \"date\",\n \"description\": \"Dimension names, comma separated. For example date, country, pagePath. Leave empty for a single total row.\"\n }\n ],\n defaultConfig: {\n \"mode\": \"auto\"\n },\n renderBody: ({ config }) =>\n summarize(GOOGLE_ANALYTICS_REPORT_META, config as Record<string, unknown>, \"run a report\"),\n});\n","/**\n * GENERATED FILE — do not edit.\n *\n * Emitted from provider/manifest.json by weaver's generator.\n * A hand-edit here is destroyed by the next protocol sync, which is worse than\n * being rejected, because it works until it silently does not. Fix\n * provider/manifest.json (or weaver's template/) and regenerate:\n *\n * npm run provider -- google_analytics\n */\n\n/**\n * Google Analytics's node kinds for fancy-flow.\n *\n * Install this on every host. The TypeScript executors live in the js\n * package's `./flow` subpath; PHP and Python hosts run their own and need only\n * this.\n */\n\nexport * from \"./service.js\";\nexport * from \"./kinds/report-run.js\";\n\nimport type { NodeKindDefinition } from \"@particle-academy/fancy-flow/engine\";\nimport { googleAnalyticsReportKind } from \"./kinds/report-run.js\";\n\n/** Every Google Analytics kind, for a host that registers the lot. */\nexport const GOOGLE_ANALYTICS_KINDS: NodeKindDefinition[] = [\n googleAnalyticsReportKind,\n];\n"]}
@@ -0,0 +1,130 @@
1
+ import * as _particle_academy_fancy_flow_connectors from '@particle-academy/fancy-flow/connectors';
2
+ import { ConnectorMeta, OutputField } from '@particle-academy/fancy-flow/connectors';
3
+ import { NodeKindDefinition } from '@particle-academy/fancy-flow/engine';
4
+
5
+ /**
6
+ * GENERATED FILE — do not edit.
7
+ *
8
+ * Emitted from provider/manifest.json by weaver's generator.
9
+ * A hand-edit here is destroyed by the next protocol sync, which is worse than
10
+ * being rejected, because it works until it silently does not. Fix
11
+ * provider/manifest.json (or weaver's template/) and regenerate:
12
+ *
13
+ * npm run provider -- google_analytics
14
+ */
15
+ /**
16
+ * Google Analytics's identity on the authoring surface, shared by every Google
17
+ * Analytics node.
18
+ *
19
+ * This file must import nothing from the js package: a PHP or Python project
20
+ * installs the ui package and never that one, and the import would be a
21
+ * dangling module the moment it did.
22
+ *
23
+ * ## The sandbox trap
24
+ *
25
+ * Google Analytics has no sandbox. A report reads a real property's real data
26
+ * and spends real quota. The faker returns a plausibly-shaped report so a flow
27
+ * can be built without a Google account.
28
+ */
29
+
30
+ /**
31
+ * The connector API version this package was GENERATED against.
32
+ *
33
+ * A literal, never imported — an imported constant lets an upgrade rewrite the
34
+ * very claim it exists to detect.
35
+ */
36
+ declare const CONNECTOR_API_VERSION = 1;
37
+ /** The parts of a connector's identity that belong to the SERVICE, not the node. */
38
+ declare const GOOGLE_ANALYTICS_SERVICE: {
39
+ readonly service: "google_analytics";
40
+ readonly serviceTitle: "Google Analytics";
41
+ readonly domain: "analytics";
42
+ readonly sandbox: "none";
43
+ };
44
+ /** The credentials a Google Analytics connection holds. */
45
+ declare const GOOGLE_ANALYTICS_CREDENTIALS: readonly [{
46
+ readonly key: "clientId";
47
+ readonly label: "OAuth client ID";
48
+ readonly scope: "provider";
49
+ readonly secret: false;
50
+ readonly help: "From Google Cloud Console -> APIs & Services -> Credentials. ONE value for the whole installation, not per connected account.";
51
+ }, {
52
+ readonly key: "clientSecret";
53
+ readonly label: "OAuth client secret";
54
+ readonly scope: "provider";
55
+ readonly secret: true;
56
+ readonly help: "The client secret for the same OAuth app. One value for the whole installation.";
57
+ }, {
58
+ readonly key: "accessToken";
59
+ readonly label: "Access token";
60
+ readonly scope: "account";
61
+ readonly secret: true;
62
+ readonly help: "Per connected Google account, and it expires after ONE HOUR. The host refreshes it with the refresh token.";
63
+ }, {
64
+ readonly key: "refreshToken";
65
+ readonly label: "Refresh token";
66
+ readonly scope: "account";
67
+ readonly secret: true;
68
+ readonly help: "Per connected Google account. Google issues one only when the consent request asks for offline access.";
69
+ }];
70
+ /**
71
+ * The OAuth2 exchange Google Analytics requires — DECLARED here, performed by
72
+ * the host.
73
+ *
74
+ * A consent screen needs a browser, a redirect URI and somewhere to persist
75
+ * the result, and all three belong to the host; a package that ran the dance
76
+ * itself would have to own a web server. So this says precisely enough for a
77
+ * host to do it.
78
+ *
79
+ * The access token lasts 3600 seconds. A host that never refreshes will work
80
+ * all afternoon and be broken by morning, which is why the lifetime is stated
81
+ * rather than left to be discovered.
82
+ */
83
+ declare const GOOGLE_ANALYTICS_OAUTH: {
84
+ readonly flow: "authorization_code";
85
+ readonly authorizeUrl: "https://accounts.google.com/o/oauth2/v2/auth";
86
+ readonly tokenUrl: "https://oauth2.googleapis.com/token";
87
+ readonly scopes: readonly ["https://www.googleapis.com/auth/analytics.readonly"];
88
+ readonly accessTokenCredential: "accessToken";
89
+ readonly refreshTokenCredential: "refreshToken";
90
+ readonly accessTokenTtlSeconds: 3600;
91
+ };
92
+ /** Build a Google Analytics node's connector metadata from the operation it performs. */
93
+ declare function googleAnalyticsMeta(role: ConnectorMeta["role"], operation: string, docs: string): ConnectorMeta;
94
+
95
+ declare const GOOGLE_ANALYTICS_REPORT_KIND = "@particle-academy/google_analytics_report";
96
+ declare const GOOGLE_ANALYTICS_REPORT_OPERATION = "report_run";
97
+ declare const GOOGLE_ANALYTICS_REPORT_META: _particle_academy_fancy_flow_connectors.ConnectorMeta;
98
+ /**
99
+ * What this node emits — the "ingredients" a downstream node can reference.
100
+ *
101
+ * fancy-flow reads `outputShape` off the kind and offers it in the variable
102
+ * picker, so declaring it is the whole of the work: an author configuring the
103
+ * next node picks `{{ $json.data.id }}` off a list instead of typing a path
104
+ * and hoping.
105
+ */
106
+ declare const GOOGLE_ANALYTICS_REPORT_OUTPUT: OutputField[];
107
+ declare const googleAnalyticsReportKind: NodeKindDefinition;
108
+
109
+ /**
110
+ * GENERATED FILE — do not edit.
111
+ *
112
+ * Emitted from provider/manifest.json by weaver's generator.
113
+ * A hand-edit here is destroyed by the next protocol sync, which is worse than
114
+ * being rejected, because it works until it silently does not. Fix
115
+ * provider/manifest.json (or weaver's template/) and regenerate:
116
+ *
117
+ * npm run provider -- google_analytics
118
+ */
119
+ /**
120
+ * Google Analytics's node kinds for fancy-flow.
121
+ *
122
+ * Install this on every host. The TypeScript executors live in the js
123
+ * package's `./flow` subpath; PHP and Python hosts run their own and need only
124
+ * this.
125
+ */
126
+
127
+ /** Every Google Analytics kind, for a host that registers the lot. */
128
+ declare const GOOGLE_ANALYTICS_KINDS: NodeKindDefinition[];
129
+
130
+ export { CONNECTOR_API_VERSION, GOOGLE_ANALYTICS_CREDENTIALS, GOOGLE_ANALYTICS_KINDS, GOOGLE_ANALYTICS_OAUTH, GOOGLE_ANALYTICS_REPORT_KIND, GOOGLE_ANALYTICS_REPORT_META, GOOGLE_ANALYTICS_REPORT_OPERATION, GOOGLE_ANALYTICS_REPORT_OUTPUT, GOOGLE_ANALYTICS_SERVICE, googleAnalyticsMeta, googleAnalyticsReportKind };
@@ -0,0 +1,130 @@
1
+ import * as _particle_academy_fancy_flow_connectors from '@particle-academy/fancy-flow/connectors';
2
+ import { ConnectorMeta, OutputField } from '@particle-academy/fancy-flow/connectors';
3
+ import { NodeKindDefinition } from '@particle-academy/fancy-flow/engine';
4
+
5
+ /**
6
+ * GENERATED FILE — do not edit.
7
+ *
8
+ * Emitted from provider/manifest.json by weaver's generator.
9
+ * A hand-edit here is destroyed by the next protocol sync, which is worse than
10
+ * being rejected, because it works until it silently does not. Fix
11
+ * provider/manifest.json (or weaver's template/) and regenerate:
12
+ *
13
+ * npm run provider -- google_analytics
14
+ */
15
+ /**
16
+ * Google Analytics's identity on the authoring surface, shared by every Google
17
+ * Analytics node.
18
+ *
19
+ * This file must import nothing from the js package: a PHP or Python project
20
+ * installs the ui package and never that one, and the import would be a
21
+ * dangling module the moment it did.
22
+ *
23
+ * ## The sandbox trap
24
+ *
25
+ * Google Analytics has no sandbox. A report reads a real property's real data
26
+ * and spends real quota. The faker returns a plausibly-shaped report so a flow
27
+ * can be built without a Google account.
28
+ */
29
+
30
+ /**
31
+ * The connector API version this package was GENERATED against.
32
+ *
33
+ * A literal, never imported — an imported constant lets an upgrade rewrite the
34
+ * very claim it exists to detect.
35
+ */
36
+ declare const CONNECTOR_API_VERSION = 1;
37
+ /** The parts of a connector's identity that belong to the SERVICE, not the node. */
38
+ declare const GOOGLE_ANALYTICS_SERVICE: {
39
+ readonly service: "google_analytics";
40
+ readonly serviceTitle: "Google Analytics";
41
+ readonly domain: "analytics";
42
+ readonly sandbox: "none";
43
+ };
44
+ /** The credentials a Google Analytics connection holds. */
45
+ declare const GOOGLE_ANALYTICS_CREDENTIALS: readonly [{
46
+ readonly key: "clientId";
47
+ readonly label: "OAuth client ID";
48
+ readonly scope: "provider";
49
+ readonly secret: false;
50
+ readonly help: "From Google Cloud Console -> APIs & Services -> Credentials. ONE value for the whole installation, not per connected account.";
51
+ }, {
52
+ readonly key: "clientSecret";
53
+ readonly label: "OAuth client secret";
54
+ readonly scope: "provider";
55
+ readonly secret: true;
56
+ readonly help: "The client secret for the same OAuth app. One value for the whole installation.";
57
+ }, {
58
+ readonly key: "accessToken";
59
+ readonly label: "Access token";
60
+ readonly scope: "account";
61
+ readonly secret: true;
62
+ readonly help: "Per connected Google account, and it expires after ONE HOUR. The host refreshes it with the refresh token.";
63
+ }, {
64
+ readonly key: "refreshToken";
65
+ readonly label: "Refresh token";
66
+ readonly scope: "account";
67
+ readonly secret: true;
68
+ readonly help: "Per connected Google account. Google issues one only when the consent request asks for offline access.";
69
+ }];
70
+ /**
71
+ * The OAuth2 exchange Google Analytics requires — DECLARED here, performed by
72
+ * the host.
73
+ *
74
+ * A consent screen needs a browser, a redirect URI and somewhere to persist
75
+ * the result, and all three belong to the host; a package that ran the dance
76
+ * itself would have to own a web server. So this says precisely enough for a
77
+ * host to do it.
78
+ *
79
+ * The access token lasts 3600 seconds. A host that never refreshes will work
80
+ * all afternoon and be broken by morning, which is why the lifetime is stated
81
+ * rather than left to be discovered.
82
+ */
83
+ declare const GOOGLE_ANALYTICS_OAUTH: {
84
+ readonly flow: "authorization_code";
85
+ readonly authorizeUrl: "https://accounts.google.com/o/oauth2/v2/auth";
86
+ readonly tokenUrl: "https://oauth2.googleapis.com/token";
87
+ readonly scopes: readonly ["https://www.googleapis.com/auth/analytics.readonly"];
88
+ readonly accessTokenCredential: "accessToken";
89
+ readonly refreshTokenCredential: "refreshToken";
90
+ readonly accessTokenTtlSeconds: 3600;
91
+ };
92
+ /** Build a Google Analytics node's connector metadata from the operation it performs. */
93
+ declare function googleAnalyticsMeta(role: ConnectorMeta["role"], operation: string, docs: string): ConnectorMeta;
94
+
95
+ declare const GOOGLE_ANALYTICS_REPORT_KIND = "@particle-academy/google_analytics_report";
96
+ declare const GOOGLE_ANALYTICS_REPORT_OPERATION = "report_run";
97
+ declare const GOOGLE_ANALYTICS_REPORT_META: _particle_academy_fancy_flow_connectors.ConnectorMeta;
98
+ /**
99
+ * What this node emits — the "ingredients" a downstream node can reference.
100
+ *
101
+ * fancy-flow reads `outputShape` off the kind and offers it in the variable
102
+ * picker, so declaring it is the whole of the work: an author configuring the
103
+ * next node picks `{{ $json.data.id }}` off a list instead of typing a path
104
+ * and hoping.
105
+ */
106
+ declare const GOOGLE_ANALYTICS_REPORT_OUTPUT: OutputField[];
107
+ declare const googleAnalyticsReportKind: NodeKindDefinition;
108
+
109
+ /**
110
+ * GENERATED FILE — do not edit.
111
+ *
112
+ * Emitted from provider/manifest.json by weaver's generator.
113
+ * A hand-edit here is destroyed by the next protocol sync, which is worse than
114
+ * being rejected, because it works until it silently does not. Fix
115
+ * provider/manifest.json (or weaver's template/) and regenerate:
116
+ *
117
+ * npm run provider -- google_analytics
118
+ */
119
+ /**
120
+ * Google Analytics's node kinds for fancy-flow.
121
+ *
122
+ * Install this on every host. The TypeScript executors live in the js
123
+ * package's `./flow` subpath; PHP and Python hosts run their own and need only
124
+ * this.
125
+ */
126
+
127
+ /** Every Google Analytics kind, for a host that registers the lot. */
128
+ declare const GOOGLE_ANALYTICS_KINDS: NodeKindDefinition[];
129
+
130
+ export { CONNECTOR_API_VERSION, GOOGLE_ANALYTICS_CREDENTIALS, GOOGLE_ANALYTICS_KINDS, GOOGLE_ANALYTICS_OAUTH, GOOGLE_ANALYTICS_REPORT_KIND, GOOGLE_ANALYTICS_REPORT_META, GOOGLE_ANALYTICS_REPORT_OPERATION, GOOGLE_ANALYTICS_REPORT_OUTPUT, GOOGLE_ANALYTICS_SERVICE, googleAnalyticsMeta, googleAnalyticsReportKind };
package/dist/index.js ADDED
@@ -0,0 +1,138 @@
1
+ import { defineConnectorKind, summarize } from '@particle-academy/fancy-flow/connectors';
2
+
3
+ // src/service.ts
4
+ var CONNECTOR_API_VERSION = 1;
5
+ var GOOGLE_ANALYTICS_SERVICE = {
6
+ service: "google_analytics",
7
+ serviceTitle: "Google Analytics",
8
+ domain: "analytics",
9
+ sandbox: "none"
10
+ };
11
+ var GOOGLE_ANALYTICS_CREDENTIALS = [
12
+ {
13
+ "key": "clientId",
14
+ "label": "OAuth client ID",
15
+ "scope": "provider",
16
+ "secret": false,
17
+ "help": "From Google Cloud Console -> APIs & Services -> Credentials. ONE value for the whole installation, not per connected account."
18
+ },
19
+ {
20
+ "key": "clientSecret",
21
+ "label": "OAuth client secret",
22
+ "scope": "provider",
23
+ "secret": true,
24
+ "help": "The client secret for the same OAuth app. One value for the whole installation."
25
+ },
26
+ {
27
+ "key": "accessToken",
28
+ "label": "Access token",
29
+ "scope": "account",
30
+ "secret": true,
31
+ "help": "Per connected Google account, and it expires after ONE HOUR. The host refreshes it with the refresh token."
32
+ },
33
+ {
34
+ "key": "refreshToken",
35
+ "label": "Refresh token",
36
+ "scope": "account",
37
+ "secret": true,
38
+ "help": "Per connected Google account. Google issues one only when the consent request asks for offline access."
39
+ }
40
+ ];
41
+ var GOOGLE_ANALYTICS_OAUTH = {
42
+ "flow": "authorization_code",
43
+ "authorizeUrl": "https://accounts.google.com/o/oauth2/v2/auth",
44
+ "tokenUrl": "https://oauth2.googleapis.com/token",
45
+ "scopes": [
46
+ "https://www.googleapis.com/auth/analytics.readonly"
47
+ ],
48
+ "accessTokenCredential": "accessToken",
49
+ "refreshTokenCredential": "refreshToken",
50
+ "accessTokenTtlSeconds": 3600
51
+ };
52
+ function googleAnalyticsMeta(role, operation, docs) {
53
+ return { ...GOOGLE_ANALYTICS_SERVICE, role, operation, docs };
54
+ }
55
+ var GOOGLE_ANALYTICS_REPORT_KIND = "@particle-academy/google_analytics_report";
56
+ var GOOGLE_ANALYTICS_REPORT_OPERATION = "report_run";
57
+ var GOOGLE_ANALYTICS_REPORT_META = googleAnalyticsMeta("action", "run a report", "https://developers.google.com/analytics/devguides/reporting/data/v1/rest/v1beta/properties/runReport");
58
+ var GOOGLE_ANALYTICS_REPORT_OUTPUT = [
59
+ {
60
+ "path": "data.rows",
61
+ "type": "array",
62
+ "description": "One entry per combination of dimension values. Each carries dimensionValues and metricValues, in the order requested."
63
+ },
64
+ {
65
+ "path": "data.rowCount",
66
+ "type": "number",
67
+ "description": "Total rows matching the query, which can exceed the rows returned."
68
+ },
69
+ {
70
+ "path": "data.metricHeaders",
71
+ "type": "array",
72
+ "description": "The metrics in the order their values appear in each row -- the only thing that says which number is which."
73
+ }
74
+ ];
75
+ var googleAnalyticsReportKind = defineConnectorKind(GOOGLE_ANALYTICS_REPORT_META, {
76
+ name: GOOGLE_ANALYTICS_REPORT_KIND,
77
+ aliases: ["google_analytics_report"],
78
+ label: "Google Analytics report",
79
+ description: "Run a report against a Google Analytics 4 property.",
80
+ inputs: [{ id: "in" }],
81
+ outputs: [{ id: "out" }],
82
+ sideEffects: "none",
83
+ outputShape: GOOGLE_ANALYTICS_REPORT_OUTPUT,
84
+ configSchema: [
85
+ {
86
+ "type": "text",
87
+ "key": "property",
88
+ "label": "Property",
89
+ "required": true,
90
+ "default": "properties/",
91
+ "description": "The GA4 property, written as `properties/1234567890`. The numeric id alone is not accepted."
92
+ },
93
+ {
94
+ "type": "text",
95
+ "key": "startDate",
96
+ "label": "Start date",
97
+ "required": true,
98
+ "default": "28daysAgo",
99
+ "description": "YYYY-MM-DD, or a relative form Google accepts such as `28daysAgo`, `yesterday` or `today`."
100
+ },
101
+ {
102
+ "type": "text",
103
+ "key": "endDate",
104
+ "label": "End date",
105
+ "required": true,
106
+ "default": "today",
107
+ "description": "YYYY-MM-DD, or a relative form such as `today`."
108
+ },
109
+ {
110
+ "type": "text",
111
+ "key": "metrics",
112
+ "label": "Metrics",
113
+ "required": true,
114
+ "default": "activeUsers,sessions",
115
+ "description": "Metric names, comma separated. For example activeUsers, sessions, screenPageViews."
116
+ },
117
+ {
118
+ "type": "text",
119
+ "key": "dimensions",
120
+ "label": "Dimensions",
121
+ "default": "date",
122
+ "description": "Dimension names, comma separated. For example date, country, pagePath. Leave empty for a single total row."
123
+ }
124
+ ],
125
+ defaultConfig: {
126
+ "mode": "auto"
127
+ },
128
+ renderBody: ({ config }) => summarize(GOOGLE_ANALYTICS_REPORT_META, config, "run a report")
129
+ });
130
+
131
+ // src/index.ts
132
+ var GOOGLE_ANALYTICS_KINDS = [
133
+ googleAnalyticsReportKind
134
+ ];
135
+
136
+ export { CONNECTOR_API_VERSION, GOOGLE_ANALYTICS_CREDENTIALS, GOOGLE_ANALYTICS_KINDS, GOOGLE_ANALYTICS_OAUTH, GOOGLE_ANALYTICS_REPORT_KIND, GOOGLE_ANALYTICS_REPORT_META, GOOGLE_ANALYTICS_REPORT_OPERATION, GOOGLE_ANALYTICS_REPORT_OUTPUT, GOOGLE_ANALYTICS_SERVICE, googleAnalyticsMeta, googleAnalyticsReportKind };
137
+ //# sourceMappingURL=index.js.map
138
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/service.ts","../src/kinds/report-run.ts","../src/index.ts"],"names":[],"mappings":";;;AAkCO,IAAM,qBAAA,GAAwB;AAG9B,IAAM,wBAAA,GAA2B;AAAA,EACtC,OAAA,EAAS,kBAAA;AAAA,EACT,YAAA,EAAc,kBAAA;AAAA,EACd,MAAA,EAAQ,WAAA;AAAA,EACR,OAAA,EAAS;AACX;AAGO,IAAM,4BAAA,GAA+B;AAAA,EAC1C;AAAA,IACE,KAAA,EAAO,UAAA;AAAA,IACP,OAAA,EAAS,iBAAA;AAAA,IACT,OAAA,EAAS,UAAA;AAAA,IACT,QAAA,EAAU,KAAA;AAAA,IACV,MAAA,EAAQ;AAAA,GACV;AAAA,EACA;AAAA,IACE,KAAA,EAAO,cAAA;AAAA,IACP,OAAA,EAAS,qBAAA;AAAA,IACT,OAAA,EAAS,UAAA;AAAA,IACT,QAAA,EAAU,IAAA;AAAA,IACV,MAAA,EAAQ;AAAA,GACV;AAAA,EACA;AAAA,IACE,KAAA,EAAO,aAAA;AAAA,IACP,OAAA,E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AAA;AACjB,GACF;AAAA,EACA,aAAA,EAAe;AAAA,IACb,MAAA,EAAQ;AAAA,GACV;AAAA,EACA,UAAA,EAAY,CAAC,EAAE,MAAA,OACb,SAAA,CAAU,4BAAA,EAA8B,QAAmC,cAAc;AAC7F,CAAC;;;AClFM,IAAM,sBAAA,GAA+C;AAAA,EAC1D;AACF","file":"index.js","sourcesContent":["/**\n * GENERATED FILE — do not edit.\n *\n * Emitted from provider/manifest.json by weaver's generator.\n * A hand-edit here is destroyed by the next protocol sync, which is worse than\n * being rejected, because it works until it silently does not. Fix\n * provider/manifest.json (or weaver's template/) and regenerate:\n *\n * npm run provider -- google_analytics\n */\n\n/**\n * Google Analytics's identity on the authoring surface, shared by every Google\n * Analytics node.\n *\n * This file must import nothing from the js package: a PHP or Python project\n * installs the ui package and never that one, and the import would be a\n * dangling module the moment it did.\n *\n * ## The sandbox trap\n *\n * Google Analytics has no sandbox. A report reads a real property's real data\n * and spends real quota. The faker returns a plausibly-shaped report so a flow\n * can be built without a Google account.\n */\n\nimport type { ConnectorMeta } from \"@particle-academy/fancy-flow/connectors\";\n\n/**\n * The connector API version this package was GENERATED against.\n *\n * A literal, never imported — an imported constant lets an upgrade rewrite the\n * very claim it exists to detect.\n */\nexport const CONNECTOR_API_VERSION = 1;\n\n/** The parts of a connector's identity that belong to the SERVICE, not the node. */\nexport const GOOGLE_ANALYTICS_SERVICE = {\n service: \"google_analytics\",\n serviceTitle: \"Google Analytics\",\n domain: \"analytics\",\n sandbox: \"none\",\n} as const satisfies Pick<ConnectorMeta, \"service\" | \"serviceTitle\" | \"domain\" | \"sandbox\">;\n\n/** The credentials a Google Analytics connection holds. */\nexport const GOOGLE_ANALYTICS_CREDENTIALS = [\n {\n \"key\": \"clientId\",\n \"label\": \"OAuth client ID\",\n \"scope\": \"provider\",\n \"secret\": false,\n \"help\": \"From Google Cloud Console -> APIs & Services -> Credentials. ONE value for the whole installation, not per connected account.\"\n },\n {\n \"key\": \"clientSecret\",\n \"label\": \"OAuth client secret\",\n \"scope\": \"provider\",\n \"secret\": true,\n \"help\": \"The client secret for the same OAuth app. One value for the whole installation.\"\n },\n {\n \"key\": \"accessToken\",\n \"label\": \"Access token\",\n \"scope\": \"account\",\n \"secret\": true,\n \"help\": \"Per connected Google account, and it expires after ONE HOUR. The host refreshes it with the refresh token.\"\n },\n {\n \"key\": \"refreshToken\",\n \"label\": \"Refresh token\",\n \"scope\": \"account\",\n \"secret\": true,\n \"help\": \"Per connected Google account. Google issues one only when the consent request asks for offline access.\"\n }\n] as const;\n\n/**\n * The OAuth2 exchange Google Analytics requires — DECLARED here, performed by\n * the host.\n *\n * A consent screen needs a browser, a redirect URI and somewhere to persist\n * the result, and all three belong to the host; a package that ran the dance\n * itself would have to own a web server. So this says precisely enough for a\n * host to do it.\n *\n * The access token lasts 3600 seconds. A host that never refreshes will work\n * all afternoon and be broken by morning, which is why the lifetime is stated\n * rather than left to be discovered.\n */\nexport const GOOGLE_ANALYTICS_OAUTH = {\n \"flow\": \"authorization_code\",\n \"authorizeUrl\": \"https://accounts.google.com/o/oauth2/v2/auth\",\n \"tokenUrl\": \"https://oauth2.googleapis.com/token\",\n \"scopes\": [\n \"https://www.googleapis.com/auth/analytics.readonly\"\n ],\n \"accessTokenCredential\": \"accessToken\",\n \"refreshTokenCredential\": \"refreshToken\",\n \"accessTokenTtlSeconds\": 3600\n} as const;\n\n/** Build a Google Analytics node's connector metadata from the operation it performs. */\nexport function googleAnalyticsMeta(\n role: ConnectorMeta[\"role\"],\n operation: string,\n docs: string,\n): ConnectorMeta {\n return { ...GOOGLE_ANALYTICS_SERVICE, role, operation, docs };\n}\n","/**\n * GENERATED FILE — do not edit.\n *\n * Emitted from provider/actions/report-run.json by weaver's generator.\n * A hand-edit here is destroyed by the next protocol sync, which is worse than\n * being rejected, because it works until it silently does not. Fix\n * provider/actions/report-run.json (or weaver's template/) and regenerate:\n *\n * npm run provider -- google_analytics\n */\n\n/**\n * Google Analytics report — Run a report against a Google Analytics 4\n * property.\n *\n * https://developers.google.com/analytics/devguides/reporting/data/v1/rest/v1beta/properties/runReport\n */\n\nimport type { NodeKindDefinition } from \"@particle-academy/fancy-flow/engine\";\nimport { defineConnectorKind, summarize, type OutputField } from \"@particle-academy/fancy-flow/connectors\";\nimport { googleAnalyticsMeta } from \"../service.js\";\n\nexport const GOOGLE_ANALYTICS_REPORT_KIND = \"@particle-academy/google_analytics_report\";\nexport const GOOGLE_ANALYTICS_REPORT_OPERATION = \"report_run\";\n\nexport const GOOGLE_ANALYTICS_REPORT_META = googleAnalyticsMeta(\"action\", \"run a report\", \"https://developers.google.com/analytics/devguides/reporting/data/v1/rest/v1beta/properties/runReport\");\n\n/**\n * What this node emits — the \"ingredients\" a downstream node can reference.\n *\n * fancy-flow reads `outputShape` off the kind and offers it in the variable\n * picker, so declaring it is the whole of the work: an author configuring the\n * next node picks `{{ $json.data.id }}` off a list instead of typing a path\n * and hoping.\n */\nexport const GOOGLE_ANALYTICS_REPORT_OUTPUT: OutputField[] = [\n {\n \"path\": \"data.rows\",\n \"type\": \"array\",\n \"description\": \"One entry per combination of dimension values. Each carries dimensionValues and metricValues, in the order requested.\"\n },\n {\n \"path\": \"data.rowCount\",\n \"type\": \"number\",\n \"description\": \"Total rows matching the query, which can exceed the rows returned.\"\n },\n {\n \"path\": \"data.metricHeaders\",\n \"type\": \"array\",\n \"description\": \"The metrics in the order their values appear in each row -- the only thing that says which number is which.\"\n }\n];\n\nexport const googleAnalyticsReportKind: NodeKindDefinition = defineConnectorKind(GOOGLE_ANALYTICS_REPORT_META, {\n name: GOOGLE_ANALYTICS_REPORT_KIND,\n aliases: [\"google_analytics_report\"],\n label: \"Google Analytics report\",\n description: \"Run a report against a Google Analytics 4 property.\",\n inputs: [{ id: \"in\" }],\n outputs: [{ id: \"out\" }],\n sideEffects: \"none\",\n outputShape: GOOGLE_ANALYTICS_REPORT_OUTPUT,\n configSchema: [\n {\n \"type\": \"text\",\n \"key\": \"property\",\n \"label\": \"Property\",\n \"required\": true,\n \"default\": \"properties/\",\n \"description\": \"The GA4 property, written as `properties/1234567890`. The numeric id alone is not accepted.\"\n },\n {\n \"type\": \"text\",\n \"key\": \"startDate\",\n \"label\": \"Start date\",\n \"required\": true,\n \"default\": \"28daysAgo\",\n \"description\": \"YYYY-MM-DD, or a relative form Google accepts such as `28daysAgo`, `yesterday` or `today`.\"\n },\n {\n \"type\": \"text\",\n \"key\": \"endDate\",\n \"label\": \"End date\",\n \"required\": true,\n \"default\": \"today\",\n \"description\": \"YYYY-MM-DD, or a relative form such as `today`.\"\n },\n {\n \"type\": \"text\",\n \"key\": \"metrics\",\n \"label\": \"Metrics\",\n \"required\": true,\n \"default\": \"activeUsers,sessions\",\n \"description\": \"Metric names, comma separated. For example activeUsers, sessions, screenPageViews.\"\n },\n {\n \"type\": \"text\",\n \"key\": \"dimensions\",\n \"label\": \"Dimensions\",\n \"default\": \"date\",\n \"description\": \"Dimension names, comma separated. For example date, country, pagePath. Leave empty for a single total row.\"\n }\n ],\n defaultConfig: {\n \"mode\": \"auto\"\n },\n renderBody: ({ config }) =>\n summarize(GOOGLE_ANALYTICS_REPORT_META, config as Record<string, unknown>, \"run a report\"),\n});\n","/**\n * GENERATED FILE — do not edit.\n *\n * Emitted from provider/manifest.json by weaver's generator.\n * A hand-edit here is destroyed by the next protocol sync, which is worse than\n * being rejected, because it works until it silently does not. Fix\n * provider/manifest.json (or weaver's template/) and regenerate:\n *\n * npm run provider -- google_analytics\n */\n\n/**\n * Google Analytics's node kinds for fancy-flow.\n *\n * Install this on every host. The TypeScript executors live in the js\n * package's `./flow` subpath; PHP and Python hosts run their own and need only\n * this.\n */\n\nexport * from \"./service.js\";\nexport * from \"./kinds/report-run.js\";\n\nimport type { NodeKindDefinition } from \"@particle-academy/fancy-flow/engine\";\nimport { googleAnalyticsReportKind } from \"./kinds/report-run.js\";\n\n/** Every Google Analytics kind, for a host that registers the lot. */\nexport const GOOGLE_ANALYTICS_KINDS: NodeKindDefinition[] = [\n googleAnalyticsReportKind,\n];\n"]}
package/package.json ADDED
@@ -0,0 +1,67 @@
1
+ {
2
+ "name": "@particle-academy/google-analytics-ui",
3
+ "version": "0.1.0",
4
+ "description": "Google Analytics's authoring surface for fancy-flow — the node kinds, their config schemas and their declared output shapes. React on every host; carries no executor.",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/Fancy-Friends/google-analytics.git"
8
+ },
9
+ "homepage": "https://github.com/Fancy-Friends/google-analytics#readme",
10
+ "bugs": "https://github.com/Fancy-Friends/google-analytics/issues",
11
+ "type": "module",
12
+ "main": "./dist/index.cjs",
13
+ "module": "./dist/index.js",
14
+ "types": "./dist/index.d.ts",
15
+ "exports": {
16
+ ".": {
17
+ "import": {
18
+ "types": "./dist/index.d.ts",
19
+ "default": "./dist/index.js"
20
+ },
21
+ "require": {
22
+ "types": "./dist/index.d.cts",
23
+ "default": "./dist/index.cjs"
24
+ }
25
+ },
26
+ "./package.json": "./package.json"
27
+ },
28
+ "files": [
29
+ "dist",
30
+ "README.md",
31
+ "CHANGELOG.md",
32
+ "LICENSE"
33
+ ],
34
+ "scripts": {
35
+ "build": "tsup",
36
+ "lint": "tsc --noEmit",
37
+ "test": "node --import tsx --test tests/*.test.ts",
38
+ "prepublishOnly": "tsup"
39
+ },
40
+ "dependencies": {},
41
+ "peerDependencies": {
42
+ "@particle-academy/fancy-flow": ">=0.48.0 <2.0"
43
+ },
44
+ "devDependencies": {
45
+ "@particle-academy/fancy-flow": ">=0.48.0 <2.0",
46
+ "@types/node": "^26.2.0",
47
+ "tsup": "^8.5.0",
48
+ "tsx": "^4.19.0",
49
+ "typescript": "^5.8.0"
50
+ },
51
+ "publishConfig": {
52
+ "access": "public"
53
+ },
54
+ "keywords": [
55
+ "google_analytics",
56
+ "analytics",
57
+ "connector",
58
+ "fancy-flow",
59
+ "fancy-ui",
60
+ "particle-academy"
61
+ ],
62
+ "license": "MIT",
63
+ "sideEffects": false,
64
+ "engines": {
65
+ "node": ">=22"
66
+ }
67
+ }