@flipstream/sdk 0.0.0-stage → 0.5.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 +102 -0
- package/LICENSE +202 -0
- package/README.md +491 -2
- package/dist/api/index.d.ts +1 -0
- package/dist/api/index.js +2 -0
- package/dist/api/index.js.map +1 -0
- package/dist/auth/discovery.d.ts +23 -0
- package/dist/auth/discovery.js +71 -0
- package/dist/auth/discovery.js.map +1 -0
- package/dist/auth/index.d.ts +5 -0
- package/dist/auth/index.js +5 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/auth/pkce.d.ts +10 -0
- package/dist/auth/pkce.js +25 -0
- package/dist/auth/pkce.js.map +1 -0
- package/dist/auth/signIn.d.ts +106 -0
- package/dist/auth/signIn.js +125 -0
- package/dist/auth/signIn.js.map +1 -0
- package/dist/auth/tokenEndpoint.d.ts +18 -0
- package/dist/auth/tokenEndpoint.js +36 -0
- package/dist/auth/tokenEndpoint.js.map +1 -0
- package/dist/auth/transport.d.ts +18 -0
- package/dist/auth/transport.js +26 -0
- package/dist/auth/transport.js.map +1 -0
- package/dist/core/body.d.ts +14 -0
- package/dist/core/body.js +69 -0
- package/dist/core/body.js.map +1 -0
- package/dist/core/call.d.ts +17 -0
- package/dist/core/call.js +116 -0
- package/dist/core/call.js.map +1 -0
- package/dist/core/fetch.d.ts +43 -0
- package/dist/core/fetch.js +130 -0
- package/dist/core/fetch.js.map +1 -0
- package/dist/core/read.d.ts +17 -0
- package/dist/core/read.js +92 -0
- package/dist/core/read.js.map +1 -0
- package/dist/core/result.d.ts +96 -0
- package/dist/core/result.js +42 -0
- package/dist/core/result.js.map +1 -0
- package/dist/core/retry.d.ts +40 -0
- package/dist/core/retry.js +41 -0
- package/dist/core/retry.js.map +1 -0
- package/dist/core/transport.d.ts +62 -0
- package/dist/core/transport.js +9 -0
- package/dist/core/transport.js.map +1 -0
- package/dist/flipstream.d.ts +52 -0
- package/dist/flipstream.js +36 -0
- package/dist/flipstream.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/node/clientSecret.d.ts +41 -0
- package/dist/node/clientSecret.js +124 -0
- package/dist/node/clientSecret.js.map +1 -0
- package/dist/node/fileLock.d.ts +27 -0
- package/dist/node/fileLock.js +248 -0
- package/dist/node/fileLock.js.map +1 -0
- package/dist/node/headless.d.ts +25 -0
- package/dist/node/headless.js +41 -0
- package/dist/node/headless.js.map +1 -0
- package/dist/node/index.d.ts +9 -0
- package/dist/node/index.js +11 -0
- package/dist/node/index.js.map +1 -0
- package/dist/node/loopback.d.ts +77 -0
- package/dist/node/loopback.js +183 -0
- package/dist/node/loopback.js.map +1 -0
- package/dist/node/session.d.ts +192 -0
- package/dist/node/session.js +480 -0
- package/dist/node/session.js.map +1 -0
- package/dist/query/catalog.d.ts +15 -0
- package/dist/query/catalog.js +41 -0
- package/dist/query/catalog.js.map +1 -0
- package/dist/query/errors.d.ts +8 -0
- package/dist/query/errors.js +16 -0
- package/dist/query/errors.js.map +1 -0
- package/dist/query/health.d.ts +16 -0
- package/dist/query/health.js +18 -0
- package/dist/query/health.js.map +1 -0
- package/dist/query/query.d.ts +35 -0
- package/dist/query/query.js +47 -0
- package/dist/query/query.js.map +1 -0
- package/dist/recorded/query-planner/catalog-google_search_console.json +140 -0
- package/dist/recorded/query-planner/catalog.json +1234 -0
- package/dist/spec/query-planner/index.d.ts +1 -0
- package/dist/spec/query-planner/index.js +3 -0
- package/dist/spec/query-planner/index.js.map +1 -0
- package/dist/spec/query-planner/types.gen.d.ts +300 -0
- package/dist/spec/query-planner/types.gen.js +3 -0
- package/dist/spec/query-planner/types.gen.js.map +1 -0
- package/dist/spec/query-planner/zod.gen.d.ts +325 -0
- package/dist/spec/query-planner/zod.gen.js +137 -0
- package/dist/spec/query-planner/zod.gen.js.map +1 -0
- package/package.json +99 -4
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { CallSpec } from '../core/call.js';
|
|
2
|
+
import type { QueryResponse, SortSpec } from '../spec/query-planner/types.gen.js';
|
|
3
|
+
/**
|
|
4
|
+
* A query, as the planner reads it: its spec's LogicalRequest, without `table` (fail closed,
|
|
5
|
+
* D407). The planner honours `table` only for an unmodelled source, and whether public callers may
|
|
6
|
+
* name a table at all is still open (DW50). If it stays public, a later change adds it, typed as
|
|
7
|
+
* the spec says. Written out rather than derived, so the public type names nothing the package
|
|
8
|
+
* doesn't export (#99); the check below keeps it the spec's.
|
|
9
|
+
*/
|
|
10
|
+
export interface QueryRequest {
|
|
11
|
+
source: string;
|
|
12
|
+
connection_id: string;
|
|
13
|
+
dimensions?: Array<string>;
|
|
14
|
+
metrics?: Array<string>;
|
|
15
|
+
filters?: Array<{
|
|
16
|
+
[key: string]: unknown;
|
|
17
|
+
}>;
|
|
18
|
+
sort?: Array<SortSpec>;
|
|
19
|
+
offset?: number;
|
|
20
|
+
rows?: number;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* `POST /query`. It only reads, but it is never tried again (D414): a timeout at the gateway may
|
|
24
|
+
* have run on the warehouse. Its one resend, after a 401, is the transport's. 60 s, until the
|
|
25
|
+
* planner has a deadline of its own (DW38).
|
|
26
|
+
*/
|
|
27
|
+
export declare function queryRun(base: string, request: QueryRequest): CallSpec<QueryResponse>;
|
|
28
|
+
/**
|
|
29
|
+
* The request's own keys that aren't FIELDS, in its order, or null when it has none. These are
|
|
30
|
+
* the keys JSON would have carried and the planner refuses (`additionalProperties: false`), so
|
|
31
|
+
* fs.query refuses a request with any rather than send it without them: a misspelt `dimension`
|
|
32
|
+
* would otherwise run, and change the numbers without a word (#113). The key is the mistake,
|
|
33
|
+
* whatever its value, so `undefined` counts too.
|
|
34
|
+
*/
|
|
35
|
+
export declare function unsentFields(request: QueryRequest): readonly [string, ...string[]] | null;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { zQueryQueryPostResponse } from '../spec/query-planner/zod.gen.js';
|
|
2
|
+
const matchesTheSpec = true;
|
|
3
|
+
void matchesTheSpec; // read once, so unused-locals checks keep it
|
|
4
|
+
/**
|
|
5
|
+
* `POST /query`. It only reads, but it is never tried again (D414): a timeout at the gateway may
|
|
6
|
+
* have run on the warehouse. Its one resend, after a 401, is the transport's. 60 s, until the
|
|
7
|
+
* planner has a deadline of its own (DW38).
|
|
8
|
+
*/
|
|
9
|
+
export function queryRun(base, request) {
|
|
10
|
+
return {
|
|
11
|
+
effect: 'read',
|
|
12
|
+
service: 'query',
|
|
13
|
+
endpoint: 'query.run',
|
|
14
|
+
deadlineMs: 60_000,
|
|
15
|
+
retry: 'never',
|
|
16
|
+
// Built when the request is, inside the transport's attempt, so a value JSON can't carry (a
|
|
17
|
+
// BigInt, a cycle) rejects the call's promise rather than throwing from fs.query itself (D436).
|
|
18
|
+
makeRequest: () => new Request(`${base}/query`, { method: 'POST', headers: { 'content-type': 'application/json' }, body: bodyOf(request) }),
|
|
19
|
+
schema: zQueryQueryPostResponse,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
/** The fields a query sends, each picked from the request (D435). `table` is not one (DW50). */
|
|
23
|
+
const FIELDS = ['source', 'connection_id', 'dimensions', 'metrics', 'filters', 'sort', 'offset', 'rows'];
|
|
24
|
+
const everyFieldPicked = true;
|
|
25
|
+
void everyFieldPicked; // read once, so unused-locals checks keep it
|
|
26
|
+
const SENT = new Set(FIELDS);
|
|
27
|
+
/**
|
|
28
|
+
* The request's own keys that aren't FIELDS, in its order, or null when it has none. These are
|
|
29
|
+
* the keys JSON would have carried and the planner refuses (`additionalProperties: false`), so
|
|
30
|
+
* fs.query refuses a request with any rather than send it without them: a misspelt `dimension`
|
|
31
|
+
* would otherwise run, and change the numbers without a word (#113). The key is the mistake,
|
|
32
|
+
* whatever its value, so `undefined` counts too.
|
|
33
|
+
*/
|
|
34
|
+
export function unsentFields(request) {
|
|
35
|
+
const [first, ...rest] = Object.keys(request).filter((key) => !SENT.has(key));
|
|
36
|
+
return first === undefined ? null : [first, ...rest];
|
|
37
|
+
}
|
|
38
|
+
/** The request as JSON: the declared fields, each left out when it's undefined. */
|
|
39
|
+
function bodyOf(request) {
|
|
40
|
+
const picked = {};
|
|
41
|
+
for (const field of FIELDS) {
|
|
42
|
+
if (request[field] !== undefined)
|
|
43
|
+
picked[field] = request[field];
|
|
44
|
+
}
|
|
45
|
+
return JSON.stringify(picked);
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=query.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query.js","sourceRoot":"","sources":["../../src/query/query.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAA;AAwB1E,MAAM,cAAc,GAAsD,IAAI,CAAA;AAC9E,KAAK,cAAc,CAAA,CAAC,6CAA6C;AAEjE;;;;GAIG;AACH,MAAM,UAAU,QAAQ,CAAC,IAAY,EAAE,OAAqB;IAC1D,OAAO;QACL,MAAM,EAAE,MAAM;QACd,OAAO,EAAE,OAAO;QAChB,QAAQ,EAAE,WAAW;QACrB,UAAU,EAAE,MAAM;QAClB,KAAK,EAAE,OAAO;QACd,4FAA4F;QAC5F,gGAAgG;QAChG,WAAW,EAAE,GAAG,EAAE,CAAC,IAAI,OAAO,CAAC,GAAG,IAAI,QAAQ,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE,EAAE,IAAI,EAAE,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;QAC3I,MAAM,EAAE,uBAAuB;KAChC,CAAA;AACH,CAAC;AAED,gGAAgG;AAChG,MAAM,MAAM,GAAG,CAAC,QAAQ,EAAE,eAAe,EAAE,YAAY,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAoD,CAAA;AAK3J,MAAM,gBAAgB,GAAiD,IAAI,CAAA;AAC3E,KAAK,gBAAgB,CAAA,CAAC,6CAA6C;AAEnE,MAAM,IAAI,GAAwB,IAAI,GAAG,CAAC,MAAM,CAAC,CAAA;AAEjD;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAAC,OAAqB;IAChD,MAAM,CAAC,KAAK,EAAE,GAAG,IAAI,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAA;IAC7E,OAAO,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,GAAG,IAAI,CAAC,CAAA;AACtD,CAAC;AAED,mFAAmF;AACnF,SAAS,MAAM,CAAC,OAAqB;IACnC,MAAM,MAAM,GAA4B,EAAE,CAAA;IAC1C,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,IAAI,OAAO,CAAC,KAAK,CAAC,KAAK,SAAS;YAAE,MAAM,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,CAAA;IAClE,CAAC;IACD,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAA;AAC/B,CAAC"}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "google_search_console",
|
|
3
|
+
"label": "Google Search Console",
|
|
4
|
+
"description": "Search performance: clicks, impressions, CTR, position.",
|
|
5
|
+
"dimensions": [
|
|
6
|
+
{
|
|
7
|
+
"name": "search_date",
|
|
8
|
+
"label": "Date",
|
|
9
|
+
"description": "Date of search performance",
|
|
10
|
+
"format": {
|
|
11
|
+
"type": "date",
|
|
12
|
+
"format": "YYYY-MM-DD"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"name": "search_type",
|
|
17
|
+
"label": "Search Type",
|
|
18
|
+
"description": "Type of search (web, image, video)",
|
|
19
|
+
"format": {
|
|
20
|
+
"type": "string"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"name": "device",
|
|
25
|
+
"label": "Device",
|
|
26
|
+
"description": "Device type (desktop, mobile, tablet)",
|
|
27
|
+
"format": {
|
|
28
|
+
"type": "string"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"name": "country",
|
|
33
|
+
"label": "Country",
|
|
34
|
+
"description": "Country code (ISO 3-letter format)",
|
|
35
|
+
"format": {
|
|
36
|
+
"type": "string"
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"name": "query",
|
|
41
|
+
"label": "Query",
|
|
42
|
+
"description": "Search query text",
|
|
43
|
+
"format": {
|
|
44
|
+
"type": "string"
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"name": "page",
|
|
49
|
+
"label": "Page",
|
|
50
|
+
"description": "Landing page URL",
|
|
51
|
+
"format": {
|
|
52
|
+
"type": "string"
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"name": "position_bucket",
|
|
57
|
+
"label": "Position Range",
|
|
58
|
+
"description": "Position range (1-3, 4-6, etc.)",
|
|
59
|
+
"format": {
|
|
60
|
+
"type": "string"
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"name": "position_bucket_index",
|
|
65
|
+
"label": "Position Range Index",
|
|
66
|
+
"description": "Numeric sort index for position bucket",
|
|
67
|
+
"format": {
|
|
68
|
+
"type": "number",
|
|
69
|
+
"decimals": 0
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
],
|
|
73
|
+
"metrics": [
|
|
74
|
+
{
|
|
75
|
+
"name": "clicks",
|
|
76
|
+
"label": "Clicks",
|
|
77
|
+
"description": "Total number of clicks",
|
|
78
|
+
"format": {
|
|
79
|
+
"type": "number",
|
|
80
|
+
"decimals": 0,
|
|
81
|
+
"thousandSeparator": true
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
"name": "impressions",
|
|
86
|
+
"label": "Impressions",
|
|
87
|
+
"description": "Total number of impressions",
|
|
88
|
+
"format": {
|
|
89
|
+
"type": "number",
|
|
90
|
+
"decimals": 0,
|
|
91
|
+
"thousandSeparator": true
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
"name": "avg_position",
|
|
96
|
+
"label": "Average Position",
|
|
97
|
+
"description": "Average search result position (lower is better)",
|
|
98
|
+
"format": {
|
|
99
|
+
"type": "number",
|
|
100
|
+
"decimals": 1
|
|
101
|
+
},
|
|
102
|
+
"lowerIsBetter": true
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
"name": "ctr",
|
|
106
|
+
"label": "CTR",
|
|
107
|
+
"description": "Click-through rate from aggregated clicks/impressions",
|
|
108
|
+
"format": {
|
|
109
|
+
"type": "percentage",
|
|
110
|
+
"decimals": 2
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
"name": "page_count",
|
|
115
|
+
"label": "Page Count",
|
|
116
|
+
"description": "Unique landing pages",
|
|
117
|
+
"format": {
|
|
118
|
+
"type": "number",
|
|
119
|
+
"decimals": 0,
|
|
120
|
+
"thousandSeparator": true
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
"name": "keyword_count",
|
|
125
|
+
"label": "Keyword Count",
|
|
126
|
+
"description": "Unique search queries",
|
|
127
|
+
"format": {
|
|
128
|
+
"type": "number",
|
|
129
|
+
"decimals": 0,
|
|
130
|
+
"thousandSeparator": true
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
],
|
|
134
|
+
"customDimensions": {
|
|
135
|
+
"supported": true,
|
|
136
|
+
"max": 100,
|
|
137
|
+
"resolve": "/custom-dimensions?connection_id={connectionId}"
|
|
138
|
+
},
|
|
139
|
+
"catalogVersion": "0.7.0"
|
|
140
|
+
}
|