@frontal-labs/data 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 +41 -0
- package/dist/client.d.ts +29 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/constants.d.ts +21 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/index.cjs +475 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +451 -0
- package/dist/sdk.d.ts +215 -0
- package/dist/sdk.d.ts.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +65 -0
- package/src/client.ts +77 -0
- package/src/constants.ts +24 -0
- package/src/index.ts +9 -0
- package/src/sdk.ts +441 -0
package/README.md
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# @frontal-labs/data
|
|
2
|
+
|
|
3
|
+
Client for the Frontal Data platform processing subdomains (`/v1/data/*`). Each
|
|
4
|
+
subdomain is a distinct backend service exposed as a namespace with a shared
|
|
5
|
+
`capabilities`/`health`/`info`/`runs` envelope:
|
|
6
|
+
|
|
7
|
+
`aggregations`, `archival`, `enrichment`, `exports`, `normalization`, `quality`,
|
|
8
|
+
`query`, `schemas`, `serving`, `streams`, `sync`, and `transformations`.
|
|
9
|
+
|
|
10
|
+
> Datasets (ingest + catalog), pipelines, and lineage have dedicated packages:
|
|
11
|
+
> `@frontal-labs/datasets`, `@frontal-labs/pipelines`, `@frontal-labs/lineage`.
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install @frontal-labs/data
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Quick Start
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
import { data } from "@frontal-labs/data";
|
|
23
|
+
|
|
24
|
+
// Resource subdomains share list/create/get/execute.
|
|
25
|
+
const aggregations = await data.aggregations.list();
|
|
26
|
+
const created = await data.quality.create({ name: "nulls-check" });
|
|
27
|
+
const run = await data.quality.execute(created.id as string); // -> evaluations
|
|
28
|
+
|
|
29
|
+
// Federated query and schema resolution.
|
|
30
|
+
const rows = await data.query.federated({ sql: "select 1" });
|
|
31
|
+
const schema = await data.schemas.resolve({ name: "users" });
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Environment Variables
|
|
35
|
+
|
|
36
|
+
| Variable | Required | Default | Description |
|
|
37
|
+
|----------|----------|---------|-------------|
|
|
38
|
+
| `FRONTAL_API_KEY` | Yes | — | Frontal API authentication key |
|
|
39
|
+
| `FRONTAL_API_URL` | No | `https://api.frontal.dev/v1` | Base URL for the Frontal API |
|
|
40
|
+
| `FRONTAL_ENV` | No | `development` | Runtime environment (`development`, `test`, `production`) |
|
|
41
|
+
| `FRONTAL_DEBUG` | No | `false` | Enable debug logging |
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { FrontalClient } from "@frontal-labs/core";
|
|
2
|
+
import { DataSdk } from "./sdk";
|
|
3
|
+
/**
|
|
4
|
+
* Configuration for creating a standalone Frontal Data client.
|
|
5
|
+
*/
|
|
6
|
+
export interface DataClientConfig {
|
|
7
|
+
/** Frontal API key. */
|
|
8
|
+
apiKey: string;
|
|
9
|
+
/** Base URL for the Data API. Defaults to {@link DEFAULT_DATA_BASE_URL}. */
|
|
10
|
+
baseUrl?: string;
|
|
11
|
+
/** Request timeout in milliseconds. Defaults to {@link DEFAULT_TIMEOUT}. */
|
|
12
|
+
timeout?: number;
|
|
13
|
+
/** Maximum number of retries for failed requests. Defaults to {@link DEFAULT_MAX_RETRIES}. */
|
|
14
|
+
maxRetries?: number;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Creates a {@link DataSdk} client from a {@link FrontalClient} instance or a
|
|
18
|
+
* {@link DataClientConfig} configuration object.
|
|
19
|
+
*
|
|
20
|
+
* @param config - An existing `FrontalClient` or a config object with `apiKey`.
|
|
21
|
+
* @returns A configured `DataSdk` instance.
|
|
22
|
+
*/
|
|
23
|
+
export declare function createDataClient(config: DataClientConfig | FrontalClient): DataSdk;
|
|
24
|
+
/**
|
|
25
|
+
* Convenience singleton proxy for the Frontal Data SDK.
|
|
26
|
+
* Lazily initialises from environment variables on first property access.
|
|
27
|
+
*/
|
|
28
|
+
export declare const data: DataSdk;
|
|
29
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EAGd,MAAM,oBAAoB,CAAC;AAO5B,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAGhC;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,uBAAuB;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,4EAA4E;IAC5E,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,4EAA4E;IAC5E,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,8FAA8F;IAC9F,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,gBAAgB,GAAG,aAAa,GACvC,OAAO,CAAC;AAwBX;;;GAGG;AACH,eAAO,MAAM,IAAI,SAWf,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default base URL for Frontal Data services.
|
|
3
|
+
*/
|
|
4
|
+
export declare const DEFAULT_DATA_BASE_URL = "https://api.frontal.dev/v1";
|
|
5
|
+
/**
|
|
6
|
+
* Package version.
|
|
7
|
+
*/
|
|
8
|
+
export declare const VERSION = "0.0.1";
|
|
9
|
+
/**
|
|
10
|
+
* Default timeout.
|
|
11
|
+
*/
|
|
12
|
+
export declare const DEFAULT_TIMEOUT = 30000;
|
|
13
|
+
/**
|
|
14
|
+
* Default max retry number.
|
|
15
|
+
*/
|
|
16
|
+
export declare const DEFAULT_MAX_RETRIES = 3;
|
|
17
|
+
/**
|
|
18
|
+
* Default retry delay.
|
|
19
|
+
*/
|
|
20
|
+
export declare const DEFAULT_RETRY_DELAY = 1000;
|
|
21
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,qBAAqB,+BAA+B,CAAC;AAElE;;GAEG;AACH,eAAO,MAAM,OAAO,UAAU,CAAC;AAE/B;;GAEG;AACH,eAAO,MAAM,eAAe,QAAS,CAAC;AAEtC;;GAEG;AACH,eAAO,MAAM,mBAAmB,IAAI,CAAC;AAErC;;GAEG;AACH,eAAO,MAAM,mBAAmB,OAAO,CAAC"}
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,475 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
DEFAULT_DATA_BASE_URL: () => DEFAULT_DATA_BASE_URL,
|
|
24
|
+
DataSdk: () => DataSdk,
|
|
25
|
+
VERSION: () => VERSION,
|
|
26
|
+
createDataClient: () => createDataClient,
|
|
27
|
+
data: () => data
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(index_exports);
|
|
30
|
+
|
|
31
|
+
// src/client.ts
|
|
32
|
+
var import_core2 = require("@frontal-labs/core");
|
|
33
|
+
|
|
34
|
+
// src/constants.ts
|
|
35
|
+
var DEFAULT_DATA_BASE_URL = "https://api.frontal.dev/v1";
|
|
36
|
+
var VERSION = "0.0.1";
|
|
37
|
+
var DEFAULT_TIMEOUT = 3e4;
|
|
38
|
+
var DEFAULT_MAX_RETRIES = 3;
|
|
39
|
+
var DEFAULT_RETRY_DELAY = 1e3;
|
|
40
|
+
|
|
41
|
+
// src/sdk.ts
|
|
42
|
+
var import_core = require("@frontal-labs/core");
|
|
43
|
+
var DataSdk = class {
|
|
44
|
+
/** Aggregation management subdomain. */
|
|
45
|
+
aggregations;
|
|
46
|
+
/** Archival policy subdomain. */
|
|
47
|
+
archival;
|
|
48
|
+
/** Enrichment profile subdomain. */
|
|
49
|
+
enrichment;
|
|
50
|
+
/** Data export subdomain. */
|
|
51
|
+
exports;
|
|
52
|
+
/** Normalization profile subdomain. */
|
|
53
|
+
normalization;
|
|
54
|
+
/** Data quality ruleset subdomain. */
|
|
55
|
+
quality;
|
|
56
|
+
/** Serving product subdomain. */
|
|
57
|
+
serving;
|
|
58
|
+
/** Stream management subdomain. */
|
|
59
|
+
streams;
|
|
60
|
+
/** Sync job subdomain. */
|
|
61
|
+
sync;
|
|
62
|
+
/** Transformation subdomain. */
|
|
63
|
+
transformations;
|
|
64
|
+
/** Federated query subdomain. */
|
|
65
|
+
query;
|
|
66
|
+
/** Schema registry subdomain. */
|
|
67
|
+
schemas;
|
|
68
|
+
/**
|
|
69
|
+
* @param http - The shared HTTP client used for all subdomain requests.
|
|
70
|
+
*/
|
|
71
|
+
constructor(http) {
|
|
72
|
+
this.aggregations = new AggregationsNamespace(http);
|
|
73
|
+
this.archival = new ArchivalNamespace(http);
|
|
74
|
+
this.enrichment = new EnrichmentNamespace(http);
|
|
75
|
+
this.exports = new ExportsNamespace(http);
|
|
76
|
+
this.normalization = new NormalizationNamespace(http);
|
|
77
|
+
this.quality = new QualityNamespace(http);
|
|
78
|
+
this.serving = new ServingNamespace(http);
|
|
79
|
+
this.streams = new StreamsNamespace(http);
|
|
80
|
+
this.sync = new SyncNamespace(http);
|
|
81
|
+
this.transformations = new TransformationsNamespace(http);
|
|
82
|
+
this.query = new QueryNamespace(http);
|
|
83
|
+
this.schemas = new SchemasNamespace(http);
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
var SubdomainBase = class {
|
|
87
|
+
/**
|
|
88
|
+
* @param http - The shared HTTP client.
|
|
89
|
+
* @param base - The subdomain base path (e.g. `/data/aggregations`).
|
|
90
|
+
*/
|
|
91
|
+
constructor(http, base) {
|
|
92
|
+
this.http = http;
|
|
93
|
+
this.base = base;
|
|
94
|
+
}
|
|
95
|
+
/** List available capabilities for this subdomain. */
|
|
96
|
+
capabilities() {
|
|
97
|
+
return this.http.get(`${this.base}/capabilities`);
|
|
98
|
+
}
|
|
99
|
+
/** Health check for this subdomain. */
|
|
100
|
+
health() {
|
|
101
|
+
return this.http.get(`${this.base}/health`);
|
|
102
|
+
}
|
|
103
|
+
/** Metadata about this subdomain service. */
|
|
104
|
+
info() {
|
|
105
|
+
return this.http.get(`${this.base}/info`);
|
|
106
|
+
}
|
|
107
|
+
/** List asynchronous runs, with optional cursor-based pagination. */
|
|
108
|
+
async runs(opts = {}) {
|
|
109
|
+
const raw = await this.http.get(`${this.base}/runs`, opts);
|
|
110
|
+
return (0, import_core.createPageResult)(
|
|
111
|
+
(0, import_core.asPagePayload)(raw),
|
|
112
|
+
(c) => this.runs({ ...opts, cursor: c })
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
/** Create a new asynchronous run. */
|
|
116
|
+
createRun(input) {
|
|
117
|
+
return this.http.post(`${this.base}/runs`, input);
|
|
118
|
+
}
|
|
119
|
+
/** Get a single run by its ID. */
|
|
120
|
+
run(runId) {
|
|
121
|
+
return this.http.get(`${this.base}/runs/${runId}`);
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
var AggregationsNamespace = class extends SubdomainBase {
|
|
125
|
+
constructor(http) {
|
|
126
|
+
super(http, "/data/aggregations");
|
|
127
|
+
}
|
|
128
|
+
/** List all aggregation definitions. */
|
|
129
|
+
async list(opts = {}) {
|
|
130
|
+
const raw = await this.http.get("/data/aggregations/aggregations", opts);
|
|
131
|
+
return (0, import_core.createPageResult)(
|
|
132
|
+
(0, import_core.asPagePayload)(raw),
|
|
133
|
+
(c) => this.list({ ...opts, cursor: c })
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
/** Create a new aggregation definition. */
|
|
137
|
+
create(body) {
|
|
138
|
+
return this.http.post("/data/aggregations/aggregations", body);
|
|
139
|
+
}
|
|
140
|
+
/** Get a single aggregation definition by ID. */
|
|
141
|
+
get(id) {
|
|
142
|
+
return this.http.get(`/data/aggregations/aggregations/${id}`);
|
|
143
|
+
}
|
|
144
|
+
/** Execute an aggregation and return a run result. */
|
|
145
|
+
execute(id, body = {}) {
|
|
146
|
+
return this.http.post(
|
|
147
|
+
`/data/aggregations/aggregations/${id}/executions`,
|
|
148
|
+
body
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
var ArchivalNamespace = class extends SubdomainBase {
|
|
153
|
+
constructor(http) {
|
|
154
|
+
super(http, "/data/archival");
|
|
155
|
+
}
|
|
156
|
+
/** List all archival policies. */
|
|
157
|
+
async list(opts = {}) {
|
|
158
|
+
const raw = await this.http.get("/data/archival/archival/policies", opts);
|
|
159
|
+
return (0, import_core.createPageResult)(
|
|
160
|
+
(0, import_core.asPagePayload)(raw),
|
|
161
|
+
(c) => this.list({ ...opts, cursor: c })
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
/** Create a new archival policy. */
|
|
165
|
+
create(body) {
|
|
166
|
+
return this.http.post("/data/archival/archival/policies", body);
|
|
167
|
+
}
|
|
168
|
+
/** Get a single archival policy by ID. */
|
|
169
|
+
get(id) {
|
|
170
|
+
return this.http.get(`/data/archival/archival/policies/${id}`);
|
|
171
|
+
}
|
|
172
|
+
/** Execute an archival policy. */
|
|
173
|
+
execute(id, body = {}) {
|
|
174
|
+
return this.http.post(
|
|
175
|
+
`/data/archival/archival/policies/${id}/executions`,
|
|
176
|
+
body
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
var EnrichmentNamespace = class extends SubdomainBase {
|
|
181
|
+
constructor(http) {
|
|
182
|
+
super(http, "/data/enrichment");
|
|
183
|
+
}
|
|
184
|
+
/** List all enrichment profiles. */
|
|
185
|
+
async list(opts = {}) {
|
|
186
|
+
const raw = await this.http.get(
|
|
187
|
+
"/data/enrichment/enrichment/profiles",
|
|
188
|
+
opts
|
|
189
|
+
);
|
|
190
|
+
return (0, import_core.createPageResult)(
|
|
191
|
+
(0, import_core.asPagePayload)(raw),
|
|
192
|
+
(c) => this.list({ ...opts, cursor: c })
|
|
193
|
+
);
|
|
194
|
+
}
|
|
195
|
+
/** Create a new enrichment profile. */
|
|
196
|
+
create(body) {
|
|
197
|
+
return this.http.post("/data/enrichment/enrichment/profiles", body);
|
|
198
|
+
}
|
|
199
|
+
/** Get a single enrichment profile by ID. */
|
|
200
|
+
get(id) {
|
|
201
|
+
return this.http.get(`/data/enrichment/enrichment/profiles/${id}`);
|
|
202
|
+
}
|
|
203
|
+
/** Execute an enrichment profile. */
|
|
204
|
+
execute(id, body = {}) {
|
|
205
|
+
return this.http.post(
|
|
206
|
+
`/data/enrichment/enrichment/profiles/${id}/executions`,
|
|
207
|
+
body
|
|
208
|
+
);
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
var ExportsNamespace = class extends SubdomainBase {
|
|
212
|
+
constructor(http) {
|
|
213
|
+
super(http, "/data/exports");
|
|
214
|
+
}
|
|
215
|
+
/** List all exports. */
|
|
216
|
+
async list(opts = {}) {
|
|
217
|
+
const raw = await this.http.get("/data/exports/exports", opts);
|
|
218
|
+
return (0, import_core.createPageResult)(
|
|
219
|
+
(0, import_core.asPagePayload)(raw),
|
|
220
|
+
(c) => this.list({ ...opts, cursor: c })
|
|
221
|
+
);
|
|
222
|
+
}
|
|
223
|
+
/** Create a new export job. */
|
|
224
|
+
create(body) {
|
|
225
|
+
return this.http.post("/data/exports/exports", body);
|
|
226
|
+
}
|
|
227
|
+
/** Get a single export by ID. */
|
|
228
|
+
get(id) {
|
|
229
|
+
return this.http.get(`/data/exports/exports/${id}`);
|
|
230
|
+
}
|
|
231
|
+
/** Execute an export job. */
|
|
232
|
+
execute(id, body = {}) {
|
|
233
|
+
return this.http.post(`/data/exports/exports/${id}/executions`, body);
|
|
234
|
+
}
|
|
235
|
+
};
|
|
236
|
+
var NormalizationNamespace = class extends SubdomainBase {
|
|
237
|
+
constructor(http) {
|
|
238
|
+
super(http, "/data/normalization");
|
|
239
|
+
}
|
|
240
|
+
/** List all normalization profiles. */
|
|
241
|
+
async list(opts = {}) {
|
|
242
|
+
const raw = await this.http.get(
|
|
243
|
+
"/data/normalization/normalization/profiles",
|
|
244
|
+
opts
|
|
245
|
+
);
|
|
246
|
+
return (0, import_core.createPageResult)(
|
|
247
|
+
(0, import_core.asPagePayload)(raw),
|
|
248
|
+
(c) => this.list({ ...opts, cursor: c })
|
|
249
|
+
);
|
|
250
|
+
}
|
|
251
|
+
/** Create a new normalization profile. */
|
|
252
|
+
create(body) {
|
|
253
|
+
return this.http.post("/data/normalization/normalization/profiles", body);
|
|
254
|
+
}
|
|
255
|
+
/** Get a single normalization profile by ID. */
|
|
256
|
+
get(id) {
|
|
257
|
+
return this.http.get(`/data/normalization/normalization/profiles/${id}`);
|
|
258
|
+
}
|
|
259
|
+
/** Execute a normalization profile. */
|
|
260
|
+
execute(id, body = {}) {
|
|
261
|
+
return this.http.post(
|
|
262
|
+
`/data/normalization/normalization/profiles/${id}/executions`,
|
|
263
|
+
body
|
|
264
|
+
);
|
|
265
|
+
}
|
|
266
|
+
};
|
|
267
|
+
var QualityNamespace = class extends SubdomainBase {
|
|
268
|
+
constructor(http) {
|
|
269
|
+
super(http, "/data/quality");
|
|
270
|
+
}
|
|
271
|
+
/** List all quality rulesets. */
|
|
272
|
+
async list(opts = {}) {
|
|
273
|
+
const raw = await this.http.get("/data/quality/quality/rulesets", opts);
|
|
274
|
+
return (0, import_core.createPageResult)(
|
|
275
|
+
(0, import_core.asPagePayload)(raw),
|
|
276
|
+
(c) => this.list({ ...opts, cursor: c })
|
|
277
|
+
);
|
|
278
|
+
}
|
|
279
|
+
/** Create a new quality ruleset. */
|
|
280
|
+
create(body) {
|
|
281
|
+
return this.http.post("/data/quality/quality/rulesets", body);
|
|
282
|
+
}
|
|
283
|
+
/** Get a single quality ruleset by ID. */
|
|
284
|
+
get(id) {
|
|
285
|
+
return this.http.get(`/data/quality/quality/rulesets/${id}`);
|
|
286
|
+
}
|
|
287
|
+
/** Evaluate a ruleset. */
|
|
288
|
+
execute(id, body = {}) {
|
|
289
|
+
return this.http.post(
|
|
290
|
+
`/data/quality/quality/rulesets/${id}/evaluations`,
|
|
291
|
+
body
|
|
292
|
+
);
|
|
293
|
+
}
|
|
294
|
+
};
|
|
295
|
+
var ServingNamespace = class extends SubdomainBase {
|
|
296
|
+
constructor(http) {
|
|
297
|
+
super(http, "/data/serving");
|
|
298
|
+
}
|
|
299
|
+
/** List all serving products. */
|
|
300
|
+
async list(opts = {}) {
|
|
301
|
+
const raw = await this.http.get("/data/serving/serving/products", opts);
|
|
302
|
+
return (0, import_core.createPageResult)(
|
|
303
|
+
(0, import_core.asPagePayload)(raw),
|
|
304
|
+
(c) => this.list({ ...opts, cursor: c })
|
|
305
|
+
);
|
|
306
|
+
}
|
|
307
|
+
/** Create a new serving product. */
|
|
308
|
+
create(body) {
|
|
309
|
+
return this.http.post("/data/serving/serving/products", body);
|
|
310
|
+
}
|
|
311
|
+
/** Get a single serving product by ID. */
|
|
312
|
+
get(id) {
|
|
313
|
+
return this.http.get(`/data/serving/serving/products/${id}`);
|
|
314
|
+
}
|
|
315
|
+
/** Refresh a serving product. */
|
|
316
|
+
execute(id, body = {}) {
|
|
317
|
+
return this.http.post(
|
|
318
|
+
`/data/serving/serving/products/${id}/refreshes`,
|
|
319
|
+
body
|
|
320
|
+
);
|
|
321
|
+
}
|
|
322
|
+
};
|
|
323
|
+
var StreamsNamespace = class extends SubdomainBase {
|
|
324
|
+
constructor(http) {
|
|
325
|
+
super(http, "/data/streams");
|
|
326
|
+
}
|
|
327
|
+
/** List all streams. */
|
|
328
|
+
async list(opts = {}) {
|
|
329
|
+
const raw = await this.http.get("/data/streams/streams", opts);
|
|
330
|
+
return (0, import_core.createPageResult)(
|
|
331
|
+
(0, import_core.asPagePayload)(raw),
|
|
332
|
+
(c) => this.list({ ...opts, cursor: c })
|
|
333
|
+
);
|
|
334
|
+
}
|
|
335
|
+
/** Create a new stream. */
|
|
336
|
+
create(body) {
|
|
337
|
+
return this.http.post("/data/streams/streams", body);
|
|
338
|
+
}
|
|
339
|
+
/** Get a single stream by ID. */
|
|
340
|
+
get(id) {
|
|
341
|
+
return this.http.get(`/data/streams/streams/${id}`);
|
|
342
|
+
}
|
|
343
|
+
/** Trigger deliveries for a stream. */
|
|
344
|
+
execute(id, body = {}) {
|
|
345
|
+
return this.http.post(`/data/streams/streams/${id}/deliveries`, body);
|
|
346
|
+
}
|
|
347
|
+
};
|
|
348
|
+
var SyncNamespace = class extends SubdomainBase {
|
|
349
|
+
constructor(http) {
|
|
350
|
+
super(http, "/data/sync");
|
|
351
|
+
}
|
|
352
|
+
/** List all sync jobs. */
|
|
353
|
+
async list(opts = {}) {
|
|
354
|
+
const raw = await this.http.get("/data/sync/sync/jobs", opts);
|
|
355
|
+
return (0, import_core.createPageResult)(
|
|
356
|
+
(0, import_core.asPagePayload)(raw),
|
|
357
|
+
(c) => this.list({ ...opts, cursor: c })
|
|
358
|
+
);
|
|
359
|
+
}
|
|
360
|
+
/** Create a new sync job. */
|
|
361
|
+
create(body) {
|
|
362
|
+
return this.http.post("/data/sync/sync/jobs", body);
|
|
363
|
+
}
|
|
364
|
+
/** Get a single sync job by ID. */
|
|
365
|
+
get(id) {
|
|
366
|
+
return this.http.get(`/data/sync/sync/jobs/${id}`);
|
|
367
|
+
}
|
|
368
|
+
/** Execute a sync job. */
|
|
369
|
+
execute(id, body = {}) {
|
|
370
|
+
return this.http.post(`/data/sync/sync/jobs/${id}/executions`, body);
|
|
371
|
+
}
|
|
372
|
+
};
|
|
373
|
+
var TransformationsNamespace = class extends SubdomainBase {
|
|
374
|
+
constructor(http) {
|
|
375
|
+
super(http, "/data/transformations");
|
|
376
|
+
}
|
|
377
|
+
/** List all transformations. */
|
|
378
|
+
async list(opts = {}) {
|
|
379
|
+
const raw = await this.http.get(
|
|
380
|
+
"/data/transformations/transformations",
|
|
381
|
+
opts
|
|
382
|
+
);
|
|
383
|
+
return (0, import_core.createPageResult)(
|
|
384
|
+
(0, import_core.asPagePayload)(raw),
|
|
385
|
+
(c) => this.list({ ...opts, cursor: c })
|
|
386
|
+
);
|
|
387
|
+
}
|
|
388
|
+
/** Create a new transformation. */
|
|
389
|
+
create(body) {
|
|
390
|
+
return this.http.post("/data/transformations/transformations", body);
|
|
391
|
+
}
|
|
392
|
+
/** Get a single transformation by ID. */
|
|
393
|
+
get(id) {
|
|
394
|
+
return this.http.get(`/data/transformations/transformations/${id}`);
|
|
395
|
+
}
|
|
396
|
+
/** Execute a transformation. */
|
|
397
|
+
execute(id, body = {}) {
|
|
398
|
+
return this.http.post(
|
|
399
|
+
`/data/transformations/transformations/${id}/executions`,
|
|
400
|
+
body
|
|
401
|
+
);
|
|
402
|
+
}
|
|
403
|
+
};
|
|
404
|
+
var QueryNamespace = class extends SubdomainBase {
|
|
405
|
+
constructor(http) {
|
|
406
|
+
super(http, "/data/query");
|
|
407
|
+
}
|
|
408
|
+
/** Execute a federated query across multiple data sources. */
|
|
409
|
+
federated(body) {
|
|
410
|
+
return this.http.post("/data/query/query/federated", body);
|
|
411
|
+
}
|
|
412
|
+
};
|
|
413
|
+
var SchemasNamespace = class extends SubdomainBase {
|
|
414
|
+
constructor(http) {
|
|
415
|
+
super(http, "/data/schemas");
|
|
416
|
+
}
|
|
417
|
+
/** List all registered schemas. */
|
|
418
|
+
async list(opts = {}) {
|
|
419
|
+
const raw = await this.http.get("/data/schemas/schemas", opts);
|
|
420
|
+
return (0, import_core.createPageResult)(
|
|
421
|
+
(0, import_core.asPagePayload)(raw),
|
|
422
|
+
(c) => this.list({ ...opts, cursor: c })
|
|
423
|
+
);
|
|
424
|
+
}
|
|
425
|
+
/** Register a new schema. */
|
|
426
|
+
create(body) {
|
|
427
|
+
return this.http.post("/data/schemas/schemas", body);
|
|
428
|
+
}
|
|
429
|
+
/** Resolve a schema reference to its definition. */
|
|
430
|
+
resolve(body) {
|
|
431
|
+
return this.http.post("/data/schemas/schemas/resolve", body);
|
|
432
|
+
}
|
|
433
|
+
/** Get a registered schema by reference. */
|
|
434
|
+
get(schemaRef) {
|
|
435
|
+
return this.http.get(`/data/schemas/schemas/${schemaRef}`);
|
|
436
|
+
}
|
|
437
|
+
};
|
|
438
|
+
|
|
439
|
+
// src/client.ts
|
|
440
|
+
var import_core3 = require("@frontal-labs/core");
|
|
441
|
+
function createDataClient(clientOrConfig) {
|
|
442
|
+
if (clientOrConfig instanceof import_core2.FrontalClient) {
|
|
443
|
+
return new DataSdk(clientOrConfig.httpClient);
|
|
444
|
+
}
|
|
445
|
+
const http = new import_core2.HttpClient({
|
|
446
|
+
apiKey: clientOrConfig.apiKey,
|
|
447
|
+
baseUrl: clientOrConfig.baseUrl ?? import_core3.env.FRONTAL_API_URL ?? DEFAULT_DATA_BASE_URL,
|
|
448
|
+
timeout: clientOrConfig.timeout ?? DEFAULT_TIMEOUT,
|
|
449
|
+
maxRetries: clientOrConfig.maxRetries ?? DEFAULT_MAX_RETRIES,
|
|
450
|
+
retryDelay: DEFAULT_RETRY_DELAY,
|
|
451
|
+
headers: {},
|
|
452
|
+
environment: import_core3.env.FRONTAL_ENV,
|
|
453
|
+
debug: import_core3.env.FRONTAL_DEBUG ?? false
|
|
454
|
+
});
|
|
455
|
+
return new DataSdk(http);
|
|
456
|
+
}
|
|
457
|
+
var _dataCache;
|
|
458
|
+
var data = new Proxy({}, {
|
|
459
|
+
get(_t, prop) {
|
|
460
|
+
if (!_dataCache) {
|
|
461
|
+
_dataCache = createDataClient((0, import_core2.getDefaultClient)());
|
|
462
|
+
}
|
|
463
|
+
const inst = _dataCache;
|
|
464
|
+
const val = inst[prop];
|
|
465
|
+
return typeof val === "function" ? val.bind(inst) : val;
|
|
466
|
+
}
|
|
467
|
+
});
|
|
468
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
469
|
+
0 && (module.exports = {
|
|
470
|
+
DEFAULT_DATA_BASE_URL,
|
|
471
|
+
DataSdk,
|
|
472
|
+
VERSION,
|
|
473
|
+
createDataClient,
|
|
474
|
+
data
|
|
475
|
+
});
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @frontal-labs/data
|
|
3
|
+
*
|
|
4
|
+
* Query, aggregate, enrich, transform, and serve data on Frontal.
|
|
5
|
+
*/
|
|
6
|
+
export { createDataClient, data, type DataClientConfig } from "./client";
|
|
7
|
+
export { DEFAULT_DATA_BASE_URL, VERSION } from "./constants";
|
|
8
|
+
export { DataSdk } from "./sdk";
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,gBAAgB,EAAE,IAAI,EAAE,KAAK,gBAAgB,EAAE,MAAM,UAAU,CAAC;AACzE,OAAO,EAAE,qBAAqB,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC"}
|