@powerhousedao/pieces-framework 6.2.3-dev.100

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.
@@ -0,0 +1,289 @@
1
+ import { i as IAction, s as ActionClassification } from "./action-C-O5Jgbl.js";
2
+ import { Dt as StaticDropdownProperty, E as Store, F as InputPropertyMap, Ft as ApFile, G as ObjectProperty, It as ApStreamingFile, V as Property, _t as CheckboxProperty, it as DropdownProperty, l as FilesService, lt as PieceAuthProperty, n as AppConnectionValueForAuthProperty, q as DynamicProperties, st as ExtractPieceAuthPropertyTypeForMethods, vt as NumberProperty, wt as OAuth2PropertyValue, x as ServerContext, z as StaticPropsValue } from "./index-DZ0aWCvr.js";
3
+ import * as z from "zod/mini";
4
+ import { Readable } from "node:stream";
5
+ //#region upstream/common/lib/authentication/index.d.ts
6
+ export type Authentication = BearerTokenAuthentication | BasicAuthentication;
7
+ export declare enum AuthenticationType {
8
+ BEARER_TOKEN = "BEARER_TOKEN",
9
+ BASIC = "BASIC"
10
+ }
11
+ export type BaseAuthentication<T extends AuthenticationType> = {
12
+ type: T;
13
+ };
14
+ export type BearerTokenAuthentication = BaseAuthentication<AuthenticationType.BEARER_TOKEN> & {
15
+ token: string;
16
+ };
17
+ export type BasicAuthentication = BaseAuthentication<AuthenticationType.BASIC> & {
18
+ username: string;
19
+ password: string;
20
+ };
21
+ //#endregion
22
+ //#region upstream/common/lib/http/core/http-headers.d.ts
23
+ type HttpHeaders = Record<string, string | string[] | undefined>;
24
+ //#endregion
25
+ //#region upstream/common/lib/http/core/delegating-authentication-converter.d.ts
26
+ export declare class DelegatingAuthenticationConverter implements AuthenticationConverter<Authentication> {
27
+ private readonly converters;
28
+ constructor(bearerTokenConverter?: BearerTokenAuthenticationConverter, basicTokenConverter?: BasicTokenAuthenticationConverter);
29
+ convert(authentication: Authentication, headers: HttpHeaders): HttpHeaders;
30
+ }
31
+ declare class BearerTokenAuthenticationConverter implements AuthenticationConverter<BearerTokenAuthentication> {
32
+ convert(authentication: BearerTokenAuthentication, headers: HttpHeaders): HttpHeaders;
33
+ }
34
+ declare class BasicTokenAuthenticationConverter implements AuthenticationConverter<BasicAuthentication> {
35
+ convert(authentication: BasicAuthentication, headers: HttpHeaders): HttpHeaders;
36
+ }
37
+ type AuthenticationConverter<T extends Authentication> = {
38
+ convert: (authentication: T, headers: HttpHeaders) => HttpHeaders;
39
+ };
40
+ //#endregion
41
+ //#region upstream/common/lib/http/core/http-message-body.d.ts
42
+ type HttpMessageBody = any;
43
+ //#endregion
44
+ //#region upstream/common/lib/http/core/http-method.d.ts
45
+ export declare enum HttpMethod {
46
+ GET = "GET",
47
+ POST = "POST",
48
+ PATCH = "PATCH",
49
+ PUT = "PUT",
50
+ DELETE = "DELETE",
51
+ HEAD = "HEAD"
52
+ }
53
+ //#endregion
54
+ //#region upstream/common/lib/http/core/query-params.d.ts
55
+ type QueryParams = Record<string, string>;
56
+ //#endregion
57
+ //#region upstream/common/lib/http/core/http-request-body.d.ts
58
+ type HttpRequestBody = HttpMessageBody | string;
59
+ //#endregion
60
+ //#region upstream/common/lib/http/core/http-request.d.ts
61
+ type HttpRequest<RequestBody extends HttpRequestBody = any> = {
62
+ method: HttpMethod;
63
+ url: string;
64
+ body?: RequestBody | undefined;
65
+ headers?: HttpHeaders;
66
+ authentication?: Authentication | undefined;
67
+ queryParams?: QueryParams | undefined;
68
+ timeout?: number;
69
+ retries?: number;
70
+ responseType?: "arraybuffer" | "json" | "blob" | "text" | "stream";
71
+ followRedirects?: boolean;
72
+ redactBodyInErrors?: boolean;
73
+ };
74
+ //#endregion
75
+ //#region upstream/common/lib/http/core/http-response.d.ts
76
+ type HttpResponse<RequestBody extends HttpMessageBody = any> = {
77
+ status: number;
78
+ headers?: HttpHeaders | undefined;
79
+ body: RequestBody;
80
+ };
81
+ //#endregion
82
+ //#region upstream/common/lib/http/core/http-client.d.ts
83
+ export type HttpClient = {
84
+ sendRequest<RequestBody extends HttpRequestBody, ResponseBody extends HttpMessageBody>(request: HttpRequest<RequestBody>, options?: SendRequestOptions): Promise<HttpResponse<ResponseBody>>;
85
+ };
86
+ export declare const httpClient: FetchHttpClient;
87
+ //#endregion
88
+ //#region upstream/common/lib/http/core/base-http-client.d.ts
89
+ export declare abstract class BaseHttpClient implements HttpClient {
90
+ private readonly baseUrl;
91
+ private readonly authenticationConverter;
92
+ constructor(baseUrl: string, authenticationConverter: DelegatingAuthenticationConverter);
93
+ abstract sendRequest<RequestBody extends HttpMessageBody, ResponseBody extends HttpMessageBody>(request: HttpRequest<RequestBody>): Promise<HttpResponse<ResponseBody>>;
94
+ protected getUrl<RequestBody extends HttpMessageBody>(request: HttpRequest<RequestBody>): {
95
+ urlWithoutQueryParams: string;
96
+ queryParams: URLSearchParams;
97
+ };
98
+ protected getHeaders<RequestBody extends HttpRequestBody>(request: HttpRequest<RequestBody>): HttpHeaders;
99
+ private populateAuthentication;
100
+ }
101
+ //#endregion
102
+ //#region upstream/common/lib/http/core/fetch-http-client.d.ts
103
+ export declare class FetchHttpClient extends BaseHttpClient {
104
+ constructor(baseUrl?: string, authenticationConverter?: DelegatingAuthenticationConverter);
105
+ sendRequest<ResponseBody extends HttpMessageBody = any>(request: HttpRequest<HttpRequestBody>, options?: SendRequestOptions): Promise<HttpResponse<ResponseBody>>;
106
+ }
107
+ export declare function acceptsRequestBody(method: HttpMethod): boolean;
108
+ export type SendRequestOptions = {
109
+ dispatcher?: unknown;
110
+ };
111
+ //#endregion
112
+ //#region upstream/common/lib/http/core/http-error.d.ts
113
+ export declare class HttpError extends Error {
114
+ private readonly requestBody;
115
+ private readonly status;
116
+ private readonly responseBody;
117
+ constructor(requestBody: unknown, params: HttpErrorParams);
118
+ errorMessage(): {
119
+ response: {
120
+ status: number;
121
+ body: unknown;
122
+ };
123
+ request: {
124
+ body: unknown;
125
+ };
126
+ };
127
+ get response(): {
128
+ status: number;
129
+ body: unknown;
130
+ };
131
+ get request(): {
132
+ body: unknown;
133
+ };
134
+ }
135
+ export declare function toFailsafeOutput({ error, requestBody }: FailsafeOutputParams): {
136
+ response: {
137
+ status: number;
138
+ body: unknown;
139
+ };
140
+ request: {
141
+ body: unknown;
142
+ };
143
+ };
144
+ export type HttpErrorParams = {
145
+ status: number;
146
+ responseBody: unknown;
147
+ };
148
+ export type FailsafeOutputParams = {
149
+ error: unknown;
150
+ requestBody: unknown;
151
+ };
152
+ //#endregion
153
+ //#region upstream/common/lib/http/core/http-header.d.ts
154
+ export declare enum HttpHeader {
155
+ AUTHORIZATION = "Authorization",
156
+ ACCEPT = "Accept",
157
+ API_KEY = "x-api-key",
158
+ CONTENT_TYPE = "Content-Type"
159
+ }
160
+ //#endregion
161
+ //#region upstream/common/lib/http/core/media-type.d.ts
162
+ export declare enum MediaType {
163
+ APPLICATION_JSON = "application/json",
164
+ TEXT_CSV = "text/csv"
165
+ }
166
+ //#endregion
167
+ //#region upstream/common/lib/helpers/index.d.ts
168
+ export declare const getAccessTokenOrThrow: (auth: OAuth2PropertyValue | undefined) => string;
169
+ type BaseUrlGetter<PieceAuth extends PieceAuthProperty | PieceAuthProperty[] | undefined> = (auth?: AppConnectionValueForAuthProperty<ExtractPieceAuthPropertyTypeForMethods<PieceAuth>>) => string;
170
+ export declare function createCustomApiCallAction<PieceAuth extends PieceAuthProperty | PieceAuthProperty[] | undefined>({ auth, baseUrl, authMapping, description, displayName, name, props, extraProps, authLocation, classification }: {
171
+ auth?: PieceAuth;
172
+ baseUrl: BaseUrlGetter<PieceAuth>;
173
+ authMapping?: (auth: AppConnectionValueForAuthProperty<ExtractPieceAuthPropertyTypeForMethods<PieceAuth>>, propsValue: StaticPropsValue<any>) => Promise<HttpHeaders | QueryParams>;
174
+ description?: string | null;
175
+ displayName?: string | null;
176
+ name?: string | null;
177
+ props?: {
178
+ url?: Partial<ReturnType<typeof Property.ShortText>>;
179
+ method?: Partial<StaticDropdownProperty<HttpMethod, boolean>>;
180
+ headers?: Partial<ReturnType<typeof Property.Object>>;
181
+ queryParams?: Partial<ReturnType<typeof Property.Object>>;
182
+ body?: Partial<ReturnType<typeof Property.Json>>;
183
+ response_is_binary?: Partial<ReturnType<typeof Property.Checkbox>>;
184
+ failsafe?: Partial<ReturnType<typeof Property.Checkbox>>;
185
+ timeout?: Partial<ReturnType<typeof Property.Number>>;
186
+ followRedirects?: Partial<ReturnType<typeof Property.Checkbox>>;
187
+ };
188
+ extraProps?: InputPropertyMap;
189
+ authLocation?: "headers" | "queryParams";
190
+ classification?: ActionClassification;
191
+ }): IAction<PieceAuth, {
192
+ url: DynamicProperties<true, PieceAuth | undefined>;
193
+ method: StaticDropdownProperty<HttpMethod, false> | StaticDropdownProperty<HttpMethod, true>;
194
+ headers: ObjectProperty<false> | ObjectProperty<true>;
195
+ queryParams: ObjectProperty<false> | ObjectProperty<true>;
196
+ body_type: DropdownProperty<string, false, PieceAuth | undefined>;
197
+ body: DynamicProperties<false, PieceAuth | undefined>;
198
+ response_is_binary: CheckboxProperty<false> | CheckboxProperty<true>;
199
+ failsafe: CheckboxProperty<false> | CheckboxProperty<true>;
200
+ timeout: NumberProperty<false> | NumberProperty<true>;
201
+ followRedirects: CheckboxProperty<false> | CheckboxProperty<true>;
202
+ }>;
203
+ export declare function is_chromium_installed(): boolean;
204
+ //#endregion
205
+ //#region upstream/common/lib/polling/index.d.ts
206
+ interface TimebasedPolling<AuthValue, PropsValue> {
207
+ strategy: DedupeStrategy.TIMEBASED;
208
+ items: (params: {
209
+ auth: AuthValue;
210
+ store: Store;
211
+ propsValue: PropsValue;
212
+ lastFetchEpochMS: number;
213
+ server?: ServerContext;
214
+ }) => Promise<{
215
+ epochMilliSeconds: number;
216
+ data: unknown;
217
+ }[]>;
218
+ }
219
+ interface LastItemPolling<AuthValue extends AppConnectionValueForAuthProperty<any>, PropsValue> {
220
+ strategy: DedupeStrategy.LAST_ITEM;
221
+ items: (params: {
222
+ auth: AuthValue;
223
+ store: Store;
224
+ files?: FilesService;
225
+ propsValue: PropsValue;
226
+ lastItemId: unknown;
227
+ server?: ServerContext;
228
+ }) => Promise<{
229
+ id: unknown;
230
+ data: unknown;
231
+ }[]>;
232
+ }
233
+ export declare enum DedupeStrategy {
234
+ TIMEBASED = 0,
235
+ LAST_ITEM = 1
236
+ }
237
+ export type Polling<AuthValue extends AppConnectionValueForAuthProperty<any>, PropsValue> = TimebasedPolling<AuthValue, PropsValue> | LastItemPolling<AuthValue, PropsValue>;
238
+ export declare const pollingHelper: {
239
+ poll<AuthValue extends AppConnectionValueForAuthProperty<any>, PropsValue>(polling: Polling<AuthValue, PropsValue>, { store, auth, propsValue, maxItemsToPoll, files, server }: {
240
+ store: Store;
241
+ auth: AuthValue;
242
+ propsValue: PropsValue;
243
+ files: FilesService;
244
+ maxItemsToPoll?: number;
245
+ server?: ServerContext;
246
+ }): Promise<unknown[]>;
247
+ onEnable<AuthValue extends AppConnectionValueForAuthProperty<any>, PropsValue>(polling: Polling<AuthValue, PropsValue>, { store, auth, propsValue, server, isRepublish }: {
248
+ store: Store;
249
+ auth: AuthValue;
250
+ propsValue: PropsValue;
251
+ server?: ServerContext;
252
+ isRepublish?: boolean;
253
+ }): Promise<void>;
254
+ onDisable<AuthValue extends AppConnectionValueForAuthProperty<any>, PropsValue>(polling: Polling<AuthValue, PropsValue>, params: {
255
+ store: Store;
256
+ auth: AuthValue;
257
+ propsValue: PropsValue;
258
+ }): Promise<void>;
259
+ test<AuthValue extends AppConnectionValueForAuthProperty<any>, PropsValue>(polling: Polling<AuthValue, PropsValue>, { auth, propsValue, store, files, server }: {
260
+ store: Store;
261
+ auth: AuthValue;
262
+ propsValue: PropsValue;
263
+ files: FilesService;
264
+ server?: ServerContext;
265
+ }): Promise<unknown[]>;
266
+ };
267
+ //#endregion
268
+ //#region upstream/common/lib/stream/index.d.ts
269
+ declare function toStreamingBody(file: ApStreamingFile | ApFile): {
270
+ body: Readable;
271
+ size: number | undefined;
272
+ };
273
+ declare function readChunks({ readable, chunkSize }: {
274
+ readable: Readable;
275
+ chunkSize: number;
276
+ }): AsyncGenerator<Buffer>;
277
+ export declare const streamUtils: {
278
+ readChunks: typeof readChunks;
279
+ toStreamingBody: typeof toStreamingBody;
280
+ };
281
+ //#endregion
282
+ //#region upstream/common/lib/validation/index.d.ts
283
+ export declare const propsValidation: {
284
+ validateZod<T extends Record<string, unknown>>(props: T, schema: Partial<Record<keyof T, z.core.$ZodType>>): Promise<void>;
285
+ };
286
+ //#endregion
287
+ export { FetchHttpClient as AxiosHttpClient, type HttpHeaders, type HttpMessageBody, type HttpRequest, type HttpResponse, type QueryParams };
288
+ export {};
289
+ //# sourceMappingURL=common.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common.d.ts","names":[],"sources":["../upstream/common/lib/authentication/index.ts","../upstream/common/lib/http/core/http-headers.ts","../upstream/common/lib/http/core/delegating-authentication-converter.ts","../upstream/common/lib/http/core/http-message-body.ts","../upstream/common/lib/http/core/http-method.ts","../upstream/common/lib/http/core/query-params.ts","../upstream/common/lib/http/core/http-request-body.ts","../upstream/common/lib/http/core/http-request.ts","../upstream/common/lib/http/core/http-response.ts","../upstream/common/lib/http/core/http-client.ts","../upstream/common/lib/http/core/base-http-client.ts","../upstream/common/lib/http/core/fetch-http-client.ts","../upstream/common/lib/http/core/http-error.ts","../upstream/common/lib/http/core/http-header.ts","../upstream/common/lib/http/core/media-type.ts","../upstream/common/lib/helpers/index.ts","../upstream/common/lib/polling/index.ts","../upstream/common/lib/stream/index.ts","../upstream/common/lib/validation/index.ts"],"mappings":";;;;;YAEY,iBAAiB,4BAA4B;oBAE7C;EACV;EACA;;YAGU,mBAAmB,UAAU;EACvC,MAAM;;YAGI,4BACV,mBAAmB,mBAAmB;EACpC;;YAGQ,sBACV,mBAAmB,mBAAmB;EACpC;EACA;;;;KCnBQ,cAAc;;;qBCSb,6CAA6C,wBAAwB;mBAC/D;EAKjB,YACE,uBAAoB,oCACpB,sBAAmB;EAQrB,QAAQ,gBAAgB,gBAAgB,SAAS,cAAc;;cAM3D,8CAA8C,w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