Skip to content

Commit

Permalink
Publish Platform Types (#11706)
Browse files Browse the repository at this point in the history
* Add the `@pipedream/platform` types to the VCS
* Improve the specificity of the DB schema types
  • Loading branch information
jverce committed May 1, 2024
1 parent 0a24e5b commit d88770c
Show file tree
Hide file tree
Showing 10 changed files with 249 additions and 4 deletions.
1 change: 1 addition & 0 deletions platform/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
!*.d.ts
node_modules
10 changes: 10 additions & 0 deletions platform/dist/axios.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { AxiosRequestConfig } from "./index";
export declare function transformConfigForOauth(config: AxiosRequestConfig): {
method: string;
url: string;
};
declare function callAxios(step: any, config: AxiosRequestConfig, signConfig?: any): Promise<any>;
declare namespace callAxios {
var create: (config?: AxiosRequestConfig | undefined, signConfig?: any) => import("axios").AxiosInstance;
}
export default callAxios;
1 change: 1 addition & 0 deletions platform/dist/constants.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export declare const DEFAULT_POLLING_SOURCE_TIMER_INTERVAL: number;
4 changes: 4 additions & 0 deletions platform/dist/errors.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export declare class ConfigurationError extends Error {
exposeStack: boolean;
constructor(message: string, exposeStack?: boolean);
}
136 changes: 136 additions & 0 deletions platform/dist/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
import * as t from "io-ts";
import axios, { transformConfigForOauth } from "./axios";
import { AxiosRequestConfig as AxiosConfig } from "axios";
export { axios, transformConfigForOauth, };
export { cloneSafe, jsonStringifySafe, } from "./utils";
export { ConfigurationError, } from "./errors";
export { default as sqlProp, } from "./sql-prop";
export { default as sqlProxy, } from "./sql-proxy";
export { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL, } from "./constants";
export declare const SendConfigEmail: t.PartialC<{
html: t.StringC;
subject: t.StringC;
text: t.StringC;
}>;
export declare type SendConfigEmail = t.TypeOf<typeof SendConfigEmail>;
export declare const SendConfigEmit_required: t.ExactC<t.TypeC<{
raw_event: t.ObjectC;
}>>;
export declare const SendConfigEmit_optional: t.PartialC<{
event: t.ObjectC;
}>;
export declare const SendConfigEmit: t.IntersectionC<[t.ExactC<t.TypeC<{
raw_event: t.ObjectC;
}>>, t.PartialC<{
event: t.ObjectC;
}>]>;
export declare type SendConfigEmit = t.TypeOf<typeof SendConfigEmit>;
export declare const HTTP_METHODS: string[];
export declare const SendConfigHTTP: t.IntersectionC<[t.ExactC<t.TypeC<{
method: t.KeyofC<{}>;
url: t.StringC;
}>>, t.PartialC<{
auth: t.ExactC<t.TypeC<{
password: t.StringC;
username: t.StringC;
}>>;
data: t.UnionC<[t.StringC, t.ObjectC]>;
headers: t.ObjectC;
params: t.ObjectC;
}>]>;
export declare type SendConfigHTTP = t.TypeOf<typeof SendConfigHTTP>;
export declare const SendConfigS3: t.ExactC<t.TypeC<{
bucket: t.StringC;
payload: t.UnionC<[t.StringC, t.ObjectC]>;
prefix: t.StringC;
}>>;
export declare type SendConfigS3 = t.TypeOf<typeof SendConfigS3>;
export declare const SendConfigSQL: t.ExactC<t.TypeC<{
payload: t.UnionC<[t.StringC, t.ObjectC]>;
table: t.StringC;
}>>;
export declare type SendConfigSQL = t.TypeOf<typeof SendConfigSQL>;
export declare const SendConfigSnowflake: t.ExactC<t.TypeC<{
account: t.StringC;
database: t.StringC;
host: t.StringC;
payload: t.UnionC<[t.StringC, t.ObjectC]>;
pipe_name: t.StringC;
private_key: t.StringC;
schema: t.StringC;
stage_name: t.StringC;
user: t.StringC;
}>>;
export declare type SendConfigSnowflake = t.TypeOf<typeof SendConfigSnowflake>;
export declare const SendConfigSSE: t.ExactC<t.TypeC<{
channel: t.StringC;
payload: t.UnionC<[t.StringC, t.ObjectC]>;
}>>;
export declare type SendConfigSSE = t.TypeOf<typeof SendConfigSSE>;
interface SendFunctionsWrapper {
email: (config: SendConfigEmail) => void;
emit: (config: SendConfigEmit) => void;
http: (config: SendConfigHTTP) => void;
s3: (config: SendConfigS3) => void;
sql: (config: SendConfigSQL) => void;
snowflake: (config: SendConfigSnowflake) => void;
sse: (config: SendConfigSSE) => void;
}
export declare const sendTypeMap: {
email: t.PartialC<{
html: t.StringC;
subject: t.StringC;
text: t.StringC;
}>;
emit: t.IntersectionC<[t.ExactC<t.TypeC<{
raw_event: t.ObjectC;
}>>, t.PartialC<{
event: t.ObjectC;
}>]>;
http: t.IntersectionC<[t.ExactC<t.TypeC<{
method: t.KeyofC<{}>;
url: t.StringC;
}>>, t.PartialC<{
auth: t.ExactC<t.TypeC<{
password: t.StringC;
username: t.StringC;
}>>;
data: t.UnionC<[t.StringC, t.ObjectC]>;
headers: t.ObjectC;
params: t.ObjectC;
}>]>;
s3: t.ExactC<t.TypeC<{
bucket: t.StringC;
payload: t.UnionC<[t.StringC, t.ObjectC]>;
prefix: t.StringC;
}>>;
sql: t.ExactC<t.TypeC<{
payload: t.UnionC<[t.StringC, t.ObjectC]>;
table: t.StringC;
}>>;
snowflake: t.ExactC<t.TypeC<{
account: t.StringC;
database: t.StringC;
host: t.StringC;
payload: t.UnionC<[t.StringC, t.ObjectC]>;
pipe_name: t.StringC;
private_key: t.StringC;
schema: t.StringC;
stage_name: t.StringC;
user: t.StringC;
}>>;
sse: t.ExactC<t.TypeC<{
channel: t.StringC;
payload: t.UnionC<[t.StringC, t.ObjectC]>;
}>>;
};
export declare let $event: any;
export declare const END_NEEDLE = "__pd_end";
export declare function $end(message?: string): void;
export declare let $send: SendFunctionsWrapper;
export declare const $sendConfigRuntimeTypeChecker: {};
export interface AxiosRequestConfig extends AxiosConfig {
debug?: boolean;
body?: any;
returnFullResponse?: boolean;
}
31 changes: 31 additions & 0 deletions platform/dist/sql-prop.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { JsonPrimitive } from "type-fest";
export declare type DbSchema = {
[tableName: string]: {
[columnName: string]: {
columnDefault: JsonPrimitive;
dataType: string;
isNullable: boolean;
tableSchema?: string;
};
};
};
export declare type RowCount = {
[tableName: string]: {
_rowCount?: number;
};
};
declare const _default: {
methods: {
/**
* A helper method to get the schema of the database. Used by other features
* (like the `sql` prop) to enrich the code editor and provide the user with
* auto-complete and fields suggestion.
*
* @returns {DbSchema} The schema of the database, which is a
* JSON-serializable object.
* @throws {ConfigurationError} If the method is not implemented.
*/
getSchema(): DbSchema | RowCount;
};
};
export default _default;
45 changes: 45 additions & 0 deletions platform/dist/sql-proxy.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
export declare type ClientConfiguration = object;
export declare type ProxyArgs = {
query: string;
params?: unknown[];
};
export declare type ExecuteQueryArgs = object | string;
export declare type Row = object;
declare const _default: {
methods: {
/**
* A helper method to get the configuration object that's directly fed to
* the DB client constructor. Used by other features (like SQL proxy) to
* initialize their client in an identical way.
*
* @returns The configuration object for the DB client
*/
getClientConfiguration(): ClientConfiguration;
/**
* Executes a query against the database. This method takes care of
* connecting to the database, executing the query, and closing the
* connection.
*
* @param args - The query string or object to be sent to the DB. SQL query.
* @returns The rows returned by the DB as a result of the query.
*/
executeQuery(args: ExecuteQueryArgs): Row[];
/**
* Adapts the arguments to `executeQuery` so that they can be consumed by
* the SQL proxy (when applicable). Note that this method is not intended to
* be used by the component directly.
*
* @param args - The query string or object to be sent to the DB.
* @returns The adapted query and parameters.
*/
proxyAdapter(args: ExecuteQueryArgs): ProxyArgs;
/**
* A method that performs the inverse transformation of `proxyAdapter`.
*
* @param args - The output of `proxyAdapter`.
* @returns The query string or object to be sent to the DB.
*/
executeQueryAdapter(args: ProxyArgs): ExecuteQueryArgs;
};
};
export default _default;
2 changes: 2 additions & 0 deletions platform/dist/utils.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export declare function cloneSafe(o: any): any;
export declare function jsonStringifySafe(v: any, set?: Set<any>): string | undefined;
21 changes: 18 additions & 3 deletions platform/lib/sql-prop.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
import { ConfigurationError } from "./errors";
import { JsonValue } from "type-fest";
import { JsonPrimitive } from "type-fest";

export type DbSchema = JsonValue;
export type DbSchema = {
[tableName: string]: {
[columnName: string]: {
columnDefault: JsonPrimitive;
dataType: string;
isNullable: boolean;
tableSchema?: string;
};
};
};

export type RowCount = {
[tableName: string]: {
_rowCount?: number;
};
};

export default {
methods: {
Expand All @@ -14,7 +29,7 @@ export default {
* JSON-serializable object.
* @throws {ConfigurationError} If the method is not implemented.
*/
getSchema(): DbSchema {
getSchema(): DbSchema | RowCount {
throw new ConfigurationError("getSchema not implemented");
},
},
Expand Down
2 changes: 1 addition & 1 deletion platform/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/platform",
"version": "1.6.4",
"version": "1.6.5",
"description": "Pipedream platform globals (typing and runtime type checking)",
"homepage": "https://pipedream.com",
"main": "dist/index.js",
Expand Down

0 comments on commit d88770c

Please sign in to comment.