@distilled.cloud/tinybird 0.0.0 → 1.0.0-rc.22
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/LICENSE +201 -0
- package/README.md +128 -4
- package/lib/.lazy.json +1 -0
- package/lib/_bundle/sdk.js +2 -0
- package/lib/_bundle/sdk.js.map +1 -0
- package/lib/credentials.d.ts +29 -0
- package/lib/credentials.d.ts.map +1 -0
- package/lib/credentials.js +1 -0
- package/lib/errors.d.ts +52 -0
- package/lib/errors.d.ts.map +1 -0
- package/lib/errors.js +1 -0
- package/lib/index.d.ts +48 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +5 -0
- package/lib/protocol.d.ts +19 -0
- package/lib/protocol.d.ts.map +1 -0
- package/lib/protocol.js +1 -0
- package/lib/retry.d.ts +50 -0
- package/lib/retry.d.ts.map +1 -0
- package/lib/retry.js +1 -0
- package/lib/services/analyze.d.ts +17 -0
- package/lib/services/analyze.d.ts.map +1 -0
- package/lib/services/analyze.js +2 -0
- package/lib/services/analyze.js.map +1 -0
- package/lib/services/api_endpoints.d.ts +26 -0
- package/lib/services/api_endpoints.d.ts.map +1 -0
- package/lib/services/api_endpoints.js +2 -0
- package/lib/services/api_endpoints.js.map +1 -0
- package/lib/services/copy_pipes.d.ts +102 -0
- package/lib/services/copy_pipes.d.ts.map +1 -0
- package/lib/services/copy_pipes.js +2 -0
- package/lib/services/copy_pipes.js.map +1 -0
- package/lib/services/datasource.d.ts +171 -0
- package/lib/services/datasource.d.ts.map +1 -0
- package/lib/services/datasource.js +2 -0
- package/lib/services/datasource.js.map +1 -0
- package/lib/services/environment_variables.d.ts +61 -0
- package/lib/services/environment_variables.d.ts.map +1 -0
- package/lib/services/environment_variables.js +2 -0
- package/lib/services/environment_variables.js.map +1 -0
- package/lib/services/events.d.ts +21 -0
- package/lib/services/events.d.ts.map +1 -0
- package/lib/services/events.js +2 -0
- package/lib/services/events.js.map +1 -0
- package/lib/services/index.d.ts +14 -0
- package/lib/services/index.d.ts.map +1 -0
- package/lib/services/index.js +13 -0
- package/lib/services/jobs.d.ts +45 -0
- package/lib/services/jobs.d.ts.map +1 -0
- package/lib/services/jobs.js +2 -0
- package/lib/services/jobs.js.map +1 -0
- package/lib/services/materialized_views.d.ts +64 -0
- package/lib/services/materialized_views.d.ts.map +1 -0
- package/lib/services/materialized_views.js +2 -0
- package/lib/services/materialized_views.js.map +1 -0
- package/lib/services/organizations.d.ts +214 -0
- package/lib/services/organizations.d.ts.map +1 -0
- package/lib/services/organizations.js +2 -0
- package/lib/services/organizations.js.map +1 -0
- package/lib/services/pipe.d.ts +243 -0
- package/lib/services/pipe.d.ts.map +1 -0
- package/lib/services/pipe.js +2 -0
- package/lib/services/pipe.js.map +1 -0
- package/lib/services/query.d.ts +50 -0
- package/lib/services/query.d.ts.map +1 -0
- package/lib/services/query.js +2 -0
- package/lib/services/query.js.map +1 -0
- package/lib/services/sink_pipes.d.ts +95 -0
- package/lib/services/sink_pipes.d.ts.map +1 -0
- package/lib/services/sink_pipes.js +2 -0
- package/lib/services/sink_pipes.js.map +1 -0
- package/lib/services/token.d.ts +107 -0
- package/lib/services/token.d.ts.map +1 -0
- package/lib/services/token.js +2 -0
- package/lib/services/token.js.map +1 -0
- package/lib/services.lazy/analyze.js +1 -0
- package/lib/services.lazy/api_endpoints.js +1 -0
- package/lib/services.lazy/copy_pipes.js +1 -0
- package/lib/services.lazy/datasource.js +1 -0
- package/lib/services.lazy/environment_variables.js +1 -0
- package/lib/services.lazy/events.js +1 -0
- package/lib/services.lazy/index.js +3 -0
- package/lib/services.lazy/jobs.js +1 -0
- package/lib/services.lazy/materialized_views.js +1 -0
- package/lib/services.lazy/organizations.js +1 -0
- package/lib/services.lazy/pipe.js +1 -0
- package/lib/services.lazy/query.js +1 -0
- package/lib/services.lazy/sink_pipes.js +1 -0
- package/lib/services.lazy/token.js +1 -0
- package/lib/traits.d.ts +10 -0
- package/lib/traits.d.ts.map +1 -0
- package/lib/traits.js +1 -0
- package/package.json +76 -2
- package/src/credentials.ts +76 -0
- package/src/errors.ts +83 -0
- package/src/index.ts +47 -0
- package/src/protocol.ts +48 -0
- package/src/retry.ts +69 -0
- package/src/services/analyze.ts +75 -0
- package/src/services/api_endpoints.ts +115 -0
- package/src/services/copy_pipes.ts +315 -0
- package/src/services/datasource.ts +438 -0
- package/src/services/environment_variables.ts +213 -0
- package/src/services/events.ts +86 -0
- package/src/services/index.ts +14 -0
- package/src/services/jobs.ts +156 -0
- package/src/services/materialized_views.ts +200 -0
- package/src/services/organizations.ts +552 -0
- package/src/services/pipe.ts +700 -0
- package/src/services/query.ts +150 -0
- package/src/services/sink_pipes.ts +295 -0
- package/src/services/token.ts +359 -0
- package/src/traits.ts +47 -0
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import * as API from "@distilled.cloud/core/api";
|
|
2
|
+
// AUTO-GENERATED by scripts/generate.ts from .generated-specs (specs/spec-mirror-tinybird/specs/api-reference). Do not edit.
|
|
3
|
+
import * as S from "@distilled.cloud/core/schema-lite";
|
|
4
|
+
import * as __L from "@distilled.cloud/core/schema-lite";
|
|
5
|
+
import { TinybirdServiceErrors } from "../errors.ts";
|
|
6
|
+
import { TinybirdProtocol, type TinybirdOpError, type TinybirdOpContext } from "../protocol.ts";
|
|
7
|
+
import * as Retry from "../retry.ts";
|
|
8
|
+
import * as T from "../traits.ts";
|
|
9
|
+
// Schema table, filled on first reach (see __S at the end).
|
|
10
|
+
const __s: any[] = [];
|
|
11
|
+
|
|
12
|
+
export type { TinybirdOpError, TinybirdOpContext };
|
|
13
|
+
|
|
14
|
+
/** Span facts shared by every operation (com.distilled.telemetry#service). */
|
|
15
|
+
const TELEMETRY = {
|
|
16
|
+
system: "tinybird-api",
|
|
17
|
+
responseHeaders: [
|
|
18
|
+
{ header: "x-request-id", name: "http.response.header.x-request-id", transform: "list" },
|
|
19
|
+
{ header: "request-id", name: "http.response.header.request-id", transform: "list" },
|
|
20
|
+
],
|
|
21
|
+
prefix: "Tinybird",
|
|
22
|
+
service: "Events",
|
|
23
|
+
propagate: "w3c",
|
|
24
|
+
} as const;
|
|
25
|
+
|
|
26
|
+
export interface SendEventsRequest {
|
|
27
|
+
/** name or ID of the target Data Source to append data to it */
|
|
28
|
+
name: string;
|
|
29
|
+
/** `ndjson` by default. Set to `json` to send a single JSON message. Other values return a 400 error. */
|
|
30
|
+
format?: string | undefined;
|
|
31
|
+
/** `false` by default. Set to `true` to wait until the database acknowledges the write. Use this flag to retry database errors. This setting adds latency, so turn it on when avoiding data loss is critical. Leave it off otherwise. */
|
|
32
|
+
wait?: boolean | undefined;
|
|
33
|
+
/** Newline-delimited JSON events (or one JSON document with `format: "json"`). */
|
|
34
|
+
body: string;
|
|
35
|
+
}
|
|
36
|
+
export type SendEventsResponseBodyMap = { [key: string]: unknown | undefined };
|
|
37
|
+
export type SendEventsResponse = SendEventsResponseBodyMap;
|
|
38
|
+
export type SendEventsError = TinybirdOpError;
|
|
39
|
+
/** Use this endpoint to send NDJSON (new-line delimited JSON) events to a Data Source. You can compress JSON events with Gzip or Zstandard and send the compressed payload to the Events API. You must include the `Content-Encoding` header in the request, set to `gzip` or `zstd` to indicate the compression algorithm used. Reference: https://www.tinybird.co/docs/api-reference/events-api */
|
|
40
|
+
export const sendEvents: API.OperationMethod<
|
|
41
|
+
SendEventsRequest,
|
|
42
|
+
SendEventsResponse,
|
|
43
|
+
SendEventsError,
|
|
44
|
+
TinybirdOpContext
|
|
45
|
+
> = /*@__PURE__*/ API.make(() => ({
|
|
46
|
+
input: __S(0, __c0, 0) as any as S.Schema<SendEventsRequest>,
|
|
47
|
+
output: __S(2, __c0, 2) as any as S.Schema<SendEventsResponse>,
|
|
48
|
+
errors: [],
|
|
49
|
+
serviceErrors: TinybirdServiceErrors,
|
|
50
|
+
protocol: TinybirdProtocol,
|
|
51
|
+
retry: Retry.Retry,
|
|
52
|
+
telemetry: TELEMETRY,
|
|
53
|
+
span: "SendEvents",
|
|
54
|
+
}));
|
|
55
|
+
|
|
56
|
+
// Schema builders: each runs one schema initializer, on that schema's first use.
|
|
57
|
+
function __c0(j: number): any {
|
|
58
|
+
switch (j) {
|
|
59
|
+
case 0:
|
|
60
|
+
return S.suspend(() =>
|
|
61
|
+
S.Struct({
|
|
62
|
+
name: S.String.pipe(T.Query()),
|
|
63
|
+
format: S.optional(S.String.pipe(T.Query())),
|
|
64
|
+
wait: S.optional(S.Boolean.pipe(T.Query())),
|
|
65
|
+
body: S.String.pipe(T.HttpBody()),
|
|
66
|
+
}).pipe(
|
|
67
|
+
T.Http({
|
|
68
|
+
method: "POST",
|
|
69
|
+
uri: "/v0/events",
|
|
70
|
+
code: 200,
|
|
71
|
+
bodyMediaType: "application/x-ndjson",
|
|
72
|
+
}),
|
|
73
|
+
),
|
|
74
|
+
).annotate({ identifier: "SendEventsRequest" });
|
|
75
|
+
case 1:
|
|
76
|
+
return S.Record(S.String, S.Unknown);
|
|
77
|
+
case 2:
|
|
78
|
+
return S.suspend(() => __S(1, __c0, 1).pipe(T.RawResponseRoot())).annotate({
|
|
79
|
+
identifier: "SendEventsResponse",
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
// Schema table: entry i is schema j of builder f, made on first reach.
|
|
84
|
+
function __S(i: number, f: (j: number) => unknown, j: number): any {
|
|
85
|
+
return (__s[i] ??= __L.at(f, j));
|
|
86
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// AUTO-GENERATED by scripts/generate.ts. Do not edit.
|
|
2
|
+
export * as analyze from "./analyze.ts";
|
|
3
|
+
export * as apiEndpoints from "./api_endpoints.ts";
|
|
4
|
+
export * as copyPipes from "./copy_pipes.ts";
|
|
5
|
+
export * as datasource from "./datasource.ts";
|
|
6
|
+
export * as environmentVariables from "./environment_variables.ts";
|
|
7
|
+
export * as events from "./events.ts";
|
|
8
|
+
export * as jobs from "./jobs.ts";
|
|
9
|
+
export * as materializedViews from "./materialized_views.ts";
|
|
10
|
+
export * as organizations from "./organizations.ts";
|
|
11
|
+
export * as pipe from "./pipe.ts";
|
|
12
|
+
export * as query from "./query.ts";
|
|
13
|
+
export * as sinkPipes from "./sink_pipes.ts";
|
|
14
|
+
export * as token from "./token.ts";
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import * as API from "@distilled.cloud/core/api";
|
|
2
|
+
// AUTO-GENERATED by scripts/generate.ts from .generated-specs (specs/spec-mirror-tinybird/specs/api-reference). Do not edit.
|
|
3
|
+
import * as S from "@distilled.cloud/core/schema-lite";
|
|
4
|
+
import * as __L from "@distilled.cloud/core/schema-lite";
|
|
5
|
+
import { TinybirdServiceErrors } from "../errors.ts";
|
|
6
|
+
import { TinybirdProtocol, type TinybirdOpError, type TinybirdOpContext } from "../protocol.ts";
|
|
7
|
+
import * as Retry from "../retry.ts";
|
|
8
|
+
import * as T from "../traits.ts";
|
|
9
|
+
// Schema table, filled on first reach (see __S at the end).
|
|
10
|
+
const __s: any[] = [];
|
|
11
|
+
|
|
12
|
+
export type { TinybirdOpError, TinybirdOpContext };
|
|
13
|
+
|
|
14
|
+
/** Span facts shared by every operation (com.distilled.telemetry#service). */
|
|
15
|
+
const TELEMETRY = {
|
|
16
|
+
system: "tinybird-api",
|
|
17
|
+
responseHeaders: [
|
|
18
|
+
{ header: "x-request-id", name: "http.response.header.x-request-id", transform: "list" },
|
|
19
|
+
{ header: "request-id", name: "http.response.header.request-id", transform: "list" },
|
|
20
|
+
],
|
|
21
|
+
prefix: "Tinybird",
|
|
22
|
+
service: "Jobs",
|
|
23
|
+
labels: "tinybird",
|
|
24
|
+
propagate: "w3c",
|
|
25
|
+
} as const;
|
|
26
|
+
|
|
27
|
+
export interface CancelJobRequest {
|
|
28
|
+
job: string;
|
|
29
|
+
}
|
|
30
|
+
export type CancelJobResponseBodyMap = { [key: string]: unknown | undefined };
|
|
31
|
+
export type CancelJobResponse = CancelJobResponseBodyMap;
|
|
32
|
+
export interface GetJobRequest {
|
|
33
|
+
job: string;
|
|
34
|
+
}
|
|
35
|
+
export type GetJobResponseBodyMap = { [key: string]: unknown | undefined };
|
|
36
|
+
export type GetJobResponse = GetJobResponseBodyMap;
|
|
37
|
+
export interface ListJobsRequest {
|
|
38
|
+
/** This will return only the jobs with that particular kind. Example: `kind=populateview` or `kind=copy` or `kind=import` */
|
|
39
|
+
kind?: string | undefined;
|
|
40
|
+
/** This will return only the jobs with the status provided. Example: `status=done` or `status=waiting` or `status=working` or `status=error` */
|
|
41
|
+
status?: string | undefined;
|
|
42
|
+
/** This will return only the jobs associated with the provided pipe id. Example: `pipe_id=t_31a0ff508c9843b59c32f7f81a156968` */
|
|
43
|
+
pipe_id?: string | undefined;
|
|
44
|
+
/** This will return only the jobs associated with the provided pipe name. Example: `pipe_name=test_pipe` */
|
|
45
|
+
pipe_name?: string | undefined;
|
|
46
|
+
/** This will return jobs that were created after the provided date in the ISO 8601 standard date format. Example: `created_after=2023-06-15T18:13:25.855Z` */
|
|
47
|
+
created_after?: string | undefined;
|
|
48
|
+
/** This will return jobs that were created before the provided date in the ISO 8601 standard date format. Example: `created_before=2023-06-19T18:13:25.855Z` */
|
|
49
|
+
created_before?: string | undefined;
|
|
50
|
+
}
|
|
51
|
+
export type ListJobsResponseBodyMap = { [key: string]: unknown | undefined };
|
|
52
|
+
export type ListJobsResponse = ListJobsResponseBodyMap;
|
|
53
|
+
export type CancelJobError = TinybirdOpError;
|
|
54
|
+
/** With this endpoint you can try to cancel an existing Job. All jobs can be cancelled if they are in the "waiting" status, but you can't cancel a Job in "done" or "error" status. In the case of the job of type "populate", you can cancel it in the "working" state. After successfully starting the cancellation process, you will see two different status in the job: - "cancelling": The Job can't be immediately cancelled as it's doing some work, but the cancellation will eventually happen. - "cancelled": The Job has been completely cancelled. A Job cancellation doesn't guarantee a complete rollback of the changes being made by it, sometimes you will need to delete new inserted rows or datasources created. The fastest way to know if a job is cancellable, is just reading the "is_cancellable" key inside the job JSON description. Depending on the Job and its status, when you try to cancel it you may get different responses: - HTTP Code 200: The Job has successfully started the cancellation process. Remember that if the Job has now a "cancelling" status, it may need some time to completely cancel itself. This request will return the status of the job. - HTTP Code 404: Job not found. - HTTP Code 403: The token provided doesn't have access to this Job. - HTTP Code 400: Job is not in a cancellable status or you are trying to cancel a job which is already in the "cancelling" state. Reference: https://www.tinybird.co/docs/api-reference/jobs-api */
|
|
55
|
+
export const cancelJob: API.OperationMethod<
|
|
56
|
+
CancelJobRequest,
|
|
57
|
+
CancelJobResponse,
|
|
58
|
+
CancelJobError,
|
|
59
|
+
TinybirdOpContext
|
|
60
|
+
> = /*@__PURE__*/ API.make(() => ({
|
|
61
|
+
input: __S(0, __c0, 0) as any as S.Schema<CancelJobRequest>,
|
|
62
|
+
output: __S(3, __c1, 1) as any as S.Schema<CancelJobResponse>,
|
|
63
|
+
errors: [],
|
|
64
|
+
serviceErrors: TinybirdServiceErrors,
|
|
65
|
+
protocol: TinybirdProtocol,
|
|
66
|
+
retry: Retry.Retry,
|
|
67
|
+
telemetry: TELEMETRY,
|
|
68
|
+
span: "CancelJob",
|
|
69
|
+
}));
|
|
70
|
+
|
|
71
|
+
export type GetJobError = TinybirdOpError;
|
|
72
|
+
/** Get the details of a specific Job. You can get the details of a Job by using its ID. The Token needs the `DATASOURCES:CREATE` scope, or the `DATASOURCES:APPEND` scope on the Data Source the Job targets. You will get a JSON response with the details of the Job, including the `kind`, `status`, `id`, `created_at`, `updated_at`, and the `datasource` associated with the Job. This is available for 48h after the Job creation. After that, you can consult the Job details in the Service Data Source jobs_log. Reference: https://www.tinybird.co/docs/api-reference/jobs-api */
|
|
73
|
+
export const getJob: API.OperationMethod<
|
|
74
|
+
GetJobRequest,
|
|
75
|
+
GetJobResponse,
|
|
76
|
+
GetJobError,
|
|
77
|
+
TinybirdOpContext
|
|
78
|
+
> = /*@__PURE__*/ API.make(() => ({
|
|
79
|
+
input: __S(4, __c2, 0) as any as S.Schema<GetJobRequest>,
|
|
80
|
+
output: __S(3, __c1, 1) as any as S.Schema<GetJobResponse>,
|
|
81
|
+
errors: [],
|
|
82
|
+
serviceErrors: TinybirdServiceErrors,
|
|
83
|
+
protocol: TinybirdProtocol,
|
|
84
|
+
retry: Retry.Retry,
|
|
85
|
+
telemetry: TELEMETRY,
|
|
86
|
+
span: "GetJob",
|
|
87
|
+
}));
|
|
88
|
+
|
|
89
|
+
export type ListJobsError = TinybirdOpError;
|
|
90
|
+
/** We can get a list of the last 100 jobs in the last 48 hours, with the possibility of filtering them by kind, status, pipe_id, pipe_name, created_after, and created_before. You will get a list of jobs with the `kind`, `status`, `id`, and the `url` to access the specific information about that job. Job details in `job_url` will be available for 48h after its creation. Reference: https://www.tinybird.co/docs/api-reference/jobs-api */
|
|
91
|
+
export const listJobs: API.OperationMethod<
|
|
92
|
+
ListJobsRequest,
|
|
93
|
+
ListJobsResponse,
|
|
94
|
+
ListJobsError,
|
|
95
|
+
TinybirdOpContext
|
|
96
|
+
> = /*@__PURE__*/ API.make(() => ({
|
|
97
|
+
input: __S(6, __c3, 0) as any as S.Schema<ListJobsRequest>,
|
|
98
|
+
output: __S(3, __c1, 1) as any as S.Schema<ListJobsResponse>,
|
|
99
|
+
errors: [],
|
|
100
|
+
serviceErrors: TinybirdServiceErrors,
|
|
101
|
+
protocol: TinybirdProtocol,
|
|
102
|
+
retry: Retry.Retry,
|
|
103
|
+
telemetry: TELEMETRY,
|
|
104
|
+
span: "ListJobs",
|
|
105
|
+
}));
|
|
106
|
+
|
|
107
|
+
// Schema builders: each runs one schema initializer, on that schema's first use.
|
|
108
|
+
function __c0(j: number): any {
|
|
109
|
+
switch (j) {
|
|
110
|
+
case 0:
|
|
111
|
+
return S.suspend(() =>
|
|
112
|
+
S.Struct({
|
|
113
|
+
job: S.String.pipe(T.Label()),
|
|
114
|
+
}).pipe(T.Http({ method: "POST", uri: "/v0/jobs/{job}/cancel", code: 200 })),
|
|
115
|
+
).annotate({ identifier: "CancelJobRequest" });
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
function __c1(j: number): any {
|
|
119
|
+
switch (j) {
|
|
120
|
+
case 0:
|
|
121
|
+
return S.Record(S.String, S.Unknown);
|
|
122
|
+
case 1:
|
|
123
|
+
return S.suspend(() => __S(2, __c1, 0).pipe(T.RawResponseRoot())).annotate({
|
|
124
|
+
identifier: "CancelJobResponse",
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
function __c2(j: number): any {
|
|
129
|
+
switch (j) {
|
|
130
|
+
case 0:
|
|
131
|
+
return S.suspend(() =>
|
|
132
|
+
S.Struct({
|
|
133
|
+
job: S.String.pipe(T.Label()),
|
|
134
|
+
}).pipe(T.Http({ method: "GET", uri: "/v0/jobs/{job}", code: 200 })),
|
|
135
|
+
).annotate({ identifier: "GetJobRequest" });
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
function __c3(j: number): any {
|
|
139
|
+
switch (j) {
|
|
140
|
+
case 0:
|
|
141
|
+
return S.suspend(() =>
|
|
142
|
+
S.Struct({
|
|
143
|
+
kind: S.optional(S.String.pipe(T.Query())),
|
|
144
|
+
status: S.optional(S.String.pipe(T.Query())),
|
|
145
|
+
pipe_id: S.optional(S.String.pipe(T.Query())),
|
|
146
|
+
pipe_name: S.optional(S.String.pipe(T.Query())),
|
|
147
|
+
created_after: S.optional(S.String.pipe(T.Query())),
|
|
148
|
+
created_before: S.optional(S.String.pipe(T.Query())),
|
|
149
|
+
}).pipe(T.Http({ method: "GET", uri: "/v0/jobs", code: 200 })),
|
|
150
|
+
).annotate({ identifier: "ListJobsRequest" });
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
// Schema table: entry i is schema j of builder f, made on first reach.
|
|
154
|
+
function __S(i: number, f: (j: number) => unknown, j: number): any {
|
|
155
|
+
return (__s[i] ??= __L.at(f, j));
|
|
156
|
+
}
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import * as API from "@distilled.cloud/core/api";
|
|
2
|
+
// AUTO-GENERATED by scripts/generate.ts from .generated-specs (specs/spec-mirror-tinybird/specs/api-reference). Do not edit.
|
|
3
|
+
import * as S from "@distilled.cloud/core/schema-lite";
|
|
4
|
+
import * as __L from "@distilled.cloud/core/schema-lite";
|
|
5
|
+
import type * as Redacted from "effect/Redacted";
|
|
6
|
+
import { TinybirdServiceErrors } from "../errors.ts";
|
|
7
|
+
import { TinybirdProtocol, type TinybirdOpError, type TinybirdOpContext } from "../protocol.ts";
|
|
8
|
+
import * as Retry from "../retry.ts";
|
|
9
|
+
import * as T from "../traits.ts";
|
|
10
|
+
// Schema table, filled on first reach (see __S at the end).
|
|
11
|
+
const __s: any[] = [];
|
|
12
|
+
|
|
13
|
+
export type { TinybirdOpError, TinybirdOpContext };
|
|
14
|
+
|
|
15
|
+
/** Span facts shared by every operation (com.distilled.telemetry#service). */
|
|
16
|
+
const TELEMETRY = {
|
|
17
|
+
system: "tinybird-api",
|
|
18
|
+
responseHeaders: [
|
|
19
|
+
{ header: "x-request-id", name: "http.response.header.x-request-id", transform: "list" },
|
|
20
|
+
{ header: "request-id", name: "http.response.header.request-id", transform: "list" },
|
|
21
|
+
],
|
|
22
|
+
prefix: "Tinybird",
|
|
23
|
+
service: "MaterializedViews",
|
|
24
|
+
labels: "tinybird",
|
|
25
|
+
propagate: "w3c",
|
|
26
|
+
} as const;
|
|
27
|
+
|
|
28
|
+
export interface CreatePipeNodeMaterializationRequest {
|
|
29
|
+
pipe: string;
|
|
30
|
+
node: string;
|
|
31
|
+
/** Auth token. Ensure it has the `PIPE:CREATE` scope on it */
|
|
32
|
+
token?: string | Redacted.Redacted<string> | undefined;
|
|
33
|
+
/** Required. Specifies the name of the destination Data Source where the Materialized View schema is defined. If the Data Source does not exist, it creates automatically with the default settings. */
|
|
34
|
+
datasource: string;
|
|
35
|
+
/** Optional. Default `false` When the target Data Source of the Materialized View exists in the Workspace it'll be overridden by the `datasource` specified in the request. */
|
|
36
|
+
override_datasource?: boolean | undefined;
|
|
37
|
+
/** Optional. Default `false`. When `true`, a job is triggered to populate the destination datasource. */
|
|
38
|
+
populate?: boolean | undefined;
|
|
39
|
+
/** Optional. Populate with a subset percent of the data (limited to a maximum of 2M rows), this is useful to quickly test a materialized node with some data. The subset must be greater than 0 and lower than 0.1. A subset of 0.1 means a 10 percent of the data in the source Data Source will be used to populate the Materialized View. Use it together with `populate=true`, it has precedence over `populate_condition` */
|
|
40
|
+
populate_subset?: number | undefined;
|
|
41
|
+
/** Optional. Populate with a SQL condition to be applied to the trigger Data Source of the Materialized View. For instance, `populate_condition='date == toYYYYMM(now())'` it'll populate taking all the rows from the trigger Data Source which `date` is the current month. Use it together with `populate=true`. `populate_condition` is not taken into account if the `populate_subset` param is present. Including in the `populate_condition` any column present in the Data Source `engine_sorting_key` will make the populate job process less data. */
|
|
42
|
+
populate_condition?: string | undefined;
|
|
43
|
+
/** Optional. Default is `false`. If the populate job fails the Materialized View is unlinked and new data won't be ingested in the Materialized View. */
|
|
44
|
+
unlink_on_populate_error?: string | undefined;
|
|
45
|
+
/** Optional. Engine for destination Materialized View. If the Data Source already exists, the settings are not overridden. */
|
|
46
|
+
engine?: string | undefined;
|
|
47
|
+
}
|
|
48
|
+
export type CreatePipeNodeMaterializationResponseBodyMap = { [key: string]: unknown | undefined };
|
|
49
|
+
export type CreatePipeNodeMaterializationResponse = CreatePipeNodeMaterializationResponseBodyMap;
|
|
50
|
+
export interface DeletePipeNodeMaterializationRequest {
|
|
51
|
+
pipe: string;
|
|
52
|
+
node: string;
|
|
53
|
+
}
|
|
54
|
+
export type DeletePipeNodeMaterializationResponseBodyMap = { [key: string]: unknown | undefined };
|
|
55
|
+
export type DeletePipeNodeMaterializationResponse = DeletePipeNodeMaterializationResponseBodyMap;
|
|
56
|
+
export interface PopulatePipeNodeRequest {
|
|
57
|
+
pipe: string;
|
|
58
|
+
node: string;
|
|
59
|
+
/** Auth token. Ensure it has the `PIPE:CREATE` scope on it */
|
|
60
|
+
token?: string | Redacted.Redacted<string> | undefined;
|
|
61
|
+
/** Optional. Populate with a subset percent of the data (limited to a maximum of 2M rows), this is useful to quickly test a materialized node with some data. The subset must be greater than 0 and lower than 0.1. A subset of 0.1 means a 10 percent of the data in the source Data Source will be used to populate the Materialized View. It has precedence over `populate_condition` */
|
|
62
|
+
populate_subset?: number | undefined;
|
|
63
|
+
/** Optional. Populate with a SQL condition to be applied to the trigger Data Source of the Materialized View. For instance, `populate_condition='date == toYYYYMM(now())'` it'll populate taking all the rows from the trigger Data Source which `date` is the current month. `populate_condition` is not taken into account if the `populate_subset` param is present. Including in the `populate_condition` any column present in the Data Source `engine_sorting_key` will make the populate job process less data. */
|
|
64
|
+
populate_condition?: string | undefined;
|
|
65
|
+
/** Optional. Default is `false`. Populates over existing data, useful to populate past data while new data is being ingested. Use `true` to truncate the Data Source before populating. */
|
|
66
|
+
truncate?: string | undefined;
|
|
67
|
+
/** Optional. Default is `false`. If the populate job fails the Materialized View is unlinked and new data won't be ingested in the Materialized View. */
|
|
68
|
+
unlink_on_populate_error?: string | undefined;
|
|
69
|
+
}
|
|
70
|
+
export type PopulatePipeNodeResponseBodyMap = { [key: string]: unknown | undefined };
|
|
71
|
+
export type PopulatePipeNodeResponse = PopulatePipeNodeResponseBodyMap;
|
|
72
|
+
export type CreatePipeNodeMaterializationError = TinybirdOpError;
|
|
73
|
+
/** Creates a Materialized View SQL query for the materialized node must be sent in the body encoded in utf-8 Reference: https://www.tinybird.co/docs/api-reference/pipe-api/materialized-views */
|
|
74
|
+
export const createPipeNodeMaterialization: API.OperationMethod<
|
|
75
|
+
CreatePipeNodeMaterializationRequest,
|
|
76
|
+
CreatePipeNodeMaterializationResponse,
|
|
77
|
+
CreatePipeNodeMaterializationError,
|
|
78
|
+
TinybirdOpContext
|
|
79
|
+
> = /*@__PURE__*/ API.make(() => ({
|
|
80
|
+
input: __S(0, __c0, 0) as any as S.Schema<CreatePipeNodeMaterializationRequest>,
|
|
81
|
+
output: __S(3, __c1, 1) as any as S.Schema<CreatePipeNodeMaterializationResponse>,
|
|
82
|
+
errors: [],
|
|
83
|
+
serviceErrors: TinybirdServiceErrors,
|
|
84
|
+
protocol: TinybirdProtocol,
|
|
85
|
+
retry: Retry.Retry,
|
|
86
|
+
telemetry: TELEMETRY,
|
|
87
|
+
span: "CreatePipeNodeMaterialization",
|
|
88
|
+
}));
|
|
89
|
+
|
|
90
|
+
export type DeletePipeNodeMaterializationError = TinybirdOpError;
|
|
91
|
+
/** Removes a Materialized View By removing a Materialized View, nor the Data Source nor the Node are deleted. The Data Source will still be present, but will stop receiving data from the Node. Reference: https://www.tinybird.co/docs/api-reference/pipe-api/materialized-views */
|
|
92
|
+
export const deletePipeNodeMaterialization: API.OperationMethod<
|
|
93
|
+
DeletePipeNodeMaterializationRequest,
|
|
94
|
+
DeletePipeNodeMaterializationResponse,
|
|
95
|
+
DeletePipeNodeMaterializationError,
|
|
96
|
+
TinybirdOpContext
|
|
97
|
+
> = /*@__PURE__*/ API.make(() => ({
|
|
98
|
+
input: __S(4, __c2, 0) as any as S.Schema<DeletePipeNodeMaterializationRequest>,
|
|
99
|
+
output: __S(3, __c1, 1) as any as S.Schema<DeletePipeNodeMaterializationResponse>,
|
|
100
|
+
errors: [],
|
|
101
|
+
serviceErrors: TinybirdServiceErrors,
|
|
102
|
+
protocol: TinybirdProtocol,
|
|
103
|
+
retry: Retry.Retry,
|
|
104
|
+
telemetry: TELEMETRY,
|
|
105
|
+
span: "DeletePipeNodeMaterialization",
|
|
106
|
+
}));
|
|
107
|
+
|
|
108
|
+
export type PopulatePipeNodeError = TinybirdOpError;
|
|
109
|
+
/** Populates a Materialized View The response will not be the final result of the import but a Job. You can check the job status and progress using the [Jobs API](/docs/api-reference/jobs-api). Alternatively you can use a query like this to check the operations related to the populate Job: When a populate job fails for the first time, the Materialized View is automatically unlinked. In that case you can get failed population jobs and their errors to fix them with a query like this: Alternatively you can use the `unlink_on_populate_error='true'` flag to always unlink the Materialized View if the populate job does not work as expected. Reference: https://www.tinybird.co/docs/api-reference/pipe-api/materialized-views */
|
|
110
|
+
export const populatePipeNode: API.OperationMethod<
|
|
111
|
+
PopulatePipeNodeRequest,
|
|
112
|
+
PopulatePipeNodeResponse,
|
|
113
|
+
PopulatePipeNodeError,
|
|
114
|
+
TinybirdOpContext
|
|
115
|
+
> = /*@__PURE__*/ API.make(() => ({
|
|
116
|
+
input: __S(6, __c3, 0) as any as S.Schema<PopulatePipeNodeRequest>,
|
|
117
|
+
output: __S(3, __c1, 1) as any as S.Schema<PopulatePipeNodeResponse>,
|
|
118
|
+
errors: [],
|
|
119
|
+
serviceErrors: TinybirdServiceErrors,
|
|
120
|
+
protocol: TinybirdProtocol,
|
|
121
|
+
retry: Retry.Retry,
|
|
122
|
+
telemetry: TELEMETRY,
|
|
123
|
+
span: "PopulatePipeNode",
|
|
124
|
+
}));
|
|
125
|
+
|
|
126
|
+
// Schema builders: each runs one schema initializer, on that schema's first use.
|
|
127
|
+
function __c0(j: number): any {
|
|
128
|
+
switch (j) {
|
|
129
|
+
case 0:
|
|
130
|
+
return S.suspend(() =>
|
|
131
|
+
S.Struct({
|
|
132
|
+
pipe: S.String.pipe(T.Label()),
|
|
133
|
+
node: S.String.pipe(T.Label()),
|
|
134
|
+
token: S.optional(S.String.pipe(T.Query(), T.SensitiveValue({}))),
|
|
135
|
+
datasource: S.String.pipe(T.Query()),
|
|
136
|
+
override_datasource: S.optional(S.Boolean.pipe(T.Query())),
|
|
137
|
+
populate: S.optional(S.Boolean.pipe(T.Query())),
|
|
138
|
+
populate_subset: S.optional(S.Number.pipe(T.Query())),
|
|
139
|
+
populate_condition: S.optional(S.String.pipe(T.Query())),
|
|
140
|
+
unlink_on_populate_error: S.optional(S.String.pipe(T.Query())),
|
|
141
|
+
engine: S.optional(S.String.pipe(T.Query())),
|
|
142
|
+
}).pipe(
|
|
143
|
+
T.Http({
|
|
144
|
+
method: "POST",
|
|
145
|
+
uri: "/v0/pipes/{pipe}/nodes/{node}/materialization",
|
|
146
|
+
code: 200,
|
|
147
|
+
}),
|
|
148
|
+
),
|
|
149
|
+
).annotate({ identifier: "CreatePipeNodeMaterializationRequest" });
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
function __c1(j: number): any {
|
|
153
|
+
switch (j) {
|
|
154
|
+
case 0:
|
|
155
|
+
return S.Record(S.String, S.Unknown);
|
|
156
|
+
case 1:
|
|
157
|
+
return S.suspend(() => __S(2, __c1, 0).pipe(T.RawResponseRoot())).annotate({
|
|
158
|
+
identifier: "CreatePipeNodeMaterializationResponse",
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
function __c2(j: number): any {
|
|
163
|
+
switch (j) {
|
|
164
|
+
case 0:
|
|
165
|
+
return S.suspend(() =>
|
|
166
|
+
S.Struct({
|
|
167
|
+
pipe: S.String.pipe(T.Label()),
|
|
168
|
+
node: S.String.pipe(T.Label()),
|
|
169
|
+
}).pipe(
|
|
170
|
+
T.Http({
|
|
171
|
+
method: "DELETE",
|
|
172
|
+
uri: "/v0/pipes/{pipe}/nodes/{node}/materialization",
|
|
173
|
+
code: 200,
|
|
174
|
+
}),
|
|
175
|
+
),
|
|
176
|
+
).annotate({ identifier: "DeletePipeNodeMaterializationRequest" });
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
function __c3(j: number): any {
|
|
180
|
+
switch (j) {
|
|
181
|
+
case 0:
|
|
182
|
+
return S.suspend(() =>
|
|
183
|
+
S.Struct({
|
|
184
|
+
pipe: S.String.pipe(T.Label()),
|
|
185
|
+
node: S.String.pipe(T.Label()),
|
|
186
|
+
token: S.optional(S.String.pipe(T.Query(), T.SensitiveValue({}))),
|
|
187
|
+
populate_subset: S.optional(S.Number.pipe(T.Query())),
|
|
188
|
+
populate_condition: S.optional(S.String.pipe(T.Query())),
|
|
189
|
+
truncate: S.optional(S.String.pipe(T.Query())),
|
|
190
|
+
unlink_on_populate_error: S.optional(S.String.pipe(T.Query())),
|
|
191
|
+
}).pipe(
|
|
192
|
+
T.Http({ method: "POST", uri: "/v0/pipes/{pipe}/nodes/{node}/population", code: 200 }),
|
|
193
|
+
),
|
|
194
|
+
).annotate({ identifier: "PopulatePipeNodeRequest" });
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
// Schema table: entry i is schema j of builder f, made on first reach.
|
|
198
|
+
function __S(i: number, f: (j: number) => unknown, j: number): any {
|
|
199
|
+
return (__s[i] ??= __L.at(f, j));
|
|
200
|
+
}
|