@stepper-io/core 1.0.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/LICENSE ADDED
@@ -0,0 +1,7 @@
1
+ Copyright 2025 Paperform
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,528 @@
1
+ interface AuthenticationBase {
2
+ test: Invoke<any, Input>;
3
+ label?: string | Invoke<string, Input>;
4
+ /**
5
+ * If true, the data returned by the test function will be stored in the credentials object (available on Context.auth for actions/triggers).
6
+ **/
7
+ storeTestResult?: boolean;
8
+ }
9
+ interface BasicAuthentication extends AuthenticationBase {
10
+ type: 'basic';
11
+ fields?: InputFields;
12
+ }
13
+ interface OAuth2Authentication extends AuthenticationBase {
14
+ type: 'oauth2';
15
+ oauth2: {
16
+ authorizationUrl: string | Invoke<string, InputField[]>;
17
+ accessTokenUrl: string | Invoke<string, InputField[]>;
18
+ refreshAccessTokenUrl: string | Invoke<string, InputField[]>;
19
+ scopes: string[];
20
+ enablePkce?: boolean;
21
+ clientCredentialsIn?: 'headers' | 'body' | 'both';
22
+ detectOAuth2Error?: (response: Response, errorText: string) => {
23
+ isOAuth2Error: boolean;
24
+ errorType: 'invalid_grant' | 'invalid_token' | 'other' | null;
25
+ errorDescription: string;
26
+ } | null;
27
+ };
28
+ fields?: InputFields;
29
+ }
30
+ interface CustomAuthentication extends AuthenticationBase {
31
+ type: 'custom';
32
+ fields: InputFields;
33
+ custom?: {
34
+ redirectUrl: string | Invoke<string, InputField[]>;
35
+ handleReturnUrl: Invoke<any, any>;
36
+ handleRefreshCredentials?: Invoke<any, any>;
37
+ };
38
+ }
39
+ interface BearerAuthentication extends AuthenticationBase {
40
+ type: 'bearer';
41
+ fields?: InputFields;
42
+ }
43
+ interface NoneAuthentication extends AuthenticationBase {
44
+ type: 'none';
45
+ }
46
+ type DynamicList = Invoke<PaginatedResponse, any>;
47
+ interface DropdownOption {
48
+ id: string | number;
49
+ label: string;
50
+ value?: {
51
+ [key: string]: any;
52
+ };
53
+ }
54
+ interface BaseInputField {
55
+ key: string;
56
+ required: boolean;
57
+ label: string;
58
+ helpText?: string;
59
+ multiple?: boolean;
60
+ instructions?: string;
61
+ example?: string | {
62
+ [key: string]: any;
63
+ };
64
+ create?: undefined;
65
+ inputType?: string;
66
+ dependencies?: string[];
67
+ hidden?: boolean;
68
+ }
69
+ interface BaseInputFieldSingleValue extends BaseInputField {
70
+ multiple?: false;
71
+ value?: string;
72
+ default?: string;
73
+ type: 'string' | 'text' | 'number' | 'integer' | 'boolean' | 'datetime' | 'password';
74
+ }
75
+ interface HTMLInputField extends BaseInputField {
76
+ multiple?: false;
77
+ type: 'html';
78
+ value?: string;
79
+ default?: string;
80
+ }
81
+ interface MarkdownInputField extends BaseInputField {
82
+ multiple?: false;
83
+ type: 'markdown';
84
+ value?: string;
85
+ default?: string;
86
+ }
87
+ interface BaseInputFieldMultipleValue extends BaseInputField {
88
+ multiple: true;
89
+ type: 'string' | 'text' | 'number' | 'integer' | 'boolean' | 'datetime' | 'password';
90
+ value?: string[];
91
+ default?: string[];
92
+ }
93
+ interface EmbeddedInputField extends Omit<BaseInputField, 'create'> {
94
+ multiple?: false;
95
+ type: 'embedded';
96
+ value?: DropdownOption;
97
+ default?: DropdownOption;
98
+ html: string | ((context: Context) => string) | ((context: Context) => Promise<string>);
99
+ create?: {
100
+ action: string;
101
+ };
102
+ }
103
+ interface ObjectValue {
104
+ [key: string]: any;
105
+ }
106
+ interface ObjectInputField extends BaseInputField {
107
+ type: 'object';
108
+ value?: ObjectValue;
109
+ default?: ObjectValue;
110
+ fields?: InputField[];
111
+ allowAny?: boolean;
112
+ }
113
+ interface RefInputField extends BaseInputField {
114
+ type: 'ref';
115
+ default?: null;
116
+ ref?: {
117
+ types: ('scalar-array' | 'complex-array' | 'scalar' | 'complex')[];
118
+ };
119
+ }
120
+ interface MessageField extends Omit<BaseInputFieldSingleValue, 'type'> {
121
+ type: 'message';
122
+ message: string;
123
+ copyText?: string;
124
+ }
125
+ interface ErrorField extends Omit<BaseInputFieldSingleValue, 'type'> {
126
+ type: 'error';
127
+ message: string;
128
+ copyText?: string;
129
+ }
130
+ interface DropdownInputFieldSingleValue extends Omit<BaseInputField, 'create'> {
131
+ key: string;
132
+ type: 'dropdown';
133
+ multiple?: false;
134
+ /**
135
+ * @deprecated Now always allowed
136
+ */
137
+ allowCustom?: boolean;
138
+ searchable?: boolean;
139
+ customLabel?: string;
140
+ create?: {
141
+ action: string;
142
+ };
143
+ default?: DropdownOption;
144
+ options: DropdownOption[] | DynamicList;
145
+ value?: DropdownOption;
146
+ }
147
+ interface SchemaInputField extends BaseInputField {
148
+ type: 'schema';
149
+ value?: unknown;
150
+ default?: unknown;
151
+ hidden?: boolean;
152
+ }
153
+ interface DropdownInputFieldMultipleValue extends BaseInputField {
154
+ type: 'dropdown';
155
+ multiple: true;
156
+ /**
157
+ * @deprecated Now always allowed
158
+ */
159
+ allowCustom?: boolean;
160
+ searchable?: boolean;
161
+ create?: undefined;
162
+ default?: DropdownOption[];
163
+ options: DropdownOption[] | DynamicList;
164
+ value?: DropdownOption[];
165
+ }
166
+ type InputField = RefInputField | HTMLInputField | MarkdownInputField | BaseInputFieldSingleValue | BaseInputFieldMultipleValue | DropdownInputFieldSingleValue | DropdownInputFieldMultipleValue | SchemaInputField | EmbeddedInputField | MessageField | ErrorField | ObjectInputField;
167
+ type DynamicInputFields = (context: Context) => Promise<InputField[]> | InputField[];
168
+ type InputFields = (InputField | DynamicInputFields)[];
169
+ type RequestClient = (url: string | URL, options?: RequestInit) => Promise<Response>;
170
+ type TemporaryFile = {
171
+ type: 'base64';
172
+ fileName?: string;
173
+ mimeType?: string;
174
+ base64: string;
175
+ } | {
176
+ type: 'url';
177
+ fileName?: string;
178
+ mimeType?: string;
179
+ url: string;
180
+ };
181
+ type SubscriptionOptionFilter = {
182
+ path: string;
183
+ value: string | number | boolean | string[] | number[] | boolean[] | null;
184
+ operator: 'eq' | 'ne' | 'in' | 'nin' | 'gt' | 'gte' | 'lt' | 'lte' | 'contains' | 'notContains' | 'notIn';
185
+ }[];
186
+ type SubscriptionOptions = {
187
+ channel: string;
188
+ filters?: SubscriptionOptionFilter;
189
+ };
190
+ type API = {
191
+ request: RequestClient;
192
+ get: RequestClient;
193
+ post: RequestClient;
194
+ patch: RequestClient;
195
+ put: RequestClient;
196
+ delete: RequestClient;
197
+ callbackUrl: () => Promise<string>;
198
+ notificationUrl: () => Promise<{
199
+ success: string;
200
+ failure: string;
201
+ }>;
202
+ storeTemporaryFile: (file: TemporaryFile) => Promise<string>;
203
+ log: (message: string) => void;
204
+ hash: (input: string, algorithm: 'sha256' | 'sha512' | 'md5') => Promise<string>;
205
+ JSON: {
206
+ parse: (input: string) => any;
207
+ stringify: (input: any) => string;
208
+ };
209
+ events: {
210
+ subscribe: (subscriptionOptions: SubscriptionOptions) => Promise<{
211
+ subscriptionId: string;
212
+ }>;
213
+ unsubscribe: (subscriptionId: string) => Promise<void>;
214
+ };
215
+ kv: {
216
+ get: (key: string) => Promise<string | null>;
217
+ set: (key: string, value: string, options?: {
218
+ ttl?: number;
219
+ }) => Promise<void>;
220
+ delete: (key: string) => Promise<void>;
221
+ };
222
+ error: {
223
+ unknown: (message: string, details?: unknown) => void;
224
+ notFound: (message: string, details?: unknown) => void;
225
+ nonRetryable: (message: string, details?: unknown) => void;
226
+ rateLimitHit: (message: string, retryAfter?: number | Date, details?: unknown) => void;
227
+ staleAuthentication: (message: string, details?: unknown) => void;
228
+ criticalAuthentication: (message: string, details?: unknown) => void;
229
+ };
230
+ resolveURLParameters: (value: string) => string;
231
+ };
232
+ type ErrorType = 'unknown' | 'notFound' | 'nonRetryable' | 'rateLimitHit' | 'criticalAuthentication' | 'staleAuthentication';
233
+ declare class BaseError extends Error {
234
+ type: ErrorType;
235
+ details?: unknown;
236
+ constructor(message: string, type: ErrorType, details?: unknown);
237
+ }
238
+ declare class UnknownError extends BaseError {
239
+ constructor(message: string, details?: unknown);
240
+ }
241
+ declare class NonRetryableError extends BaseError {
242
+ constructor(message: string, details?: unknown);
243
+ }
244
+ declare class NotFoundError extends BaseError {
245
+ constructor(message: string, details?: unknown);
246
+ }
247
+ declare class RateLimitHitError extends BaseError {
248
+ retryAfter?: number | Date;
249
+ constructor(message: string, retryAfter?: number | Date, details?: unknown);
250
+ }
251
+ declare class CriticalAuthenticationError extends BaseError {
252
+ constructor(message: string, details?: unknown);
253
+ }
254
+ declare class StaleAuthenticationError extends BaseError {
255
+ constructor(message: string, details?: unknown);
256
+ }
257
+ type ErrorTypes = typeof UnknownError | typeof NonRetryableError | typeof RateLimitHitError | typeof CriticalAuthenticationError | typeof StaleAuthenticationError;
258
+ type Input = {
259
+ [key: string]: any;
260
+ };
261
+ type Context<TInput extends Input = Input> = {
262
+ input: TInput;
263
+ env: any;
264
+ auth: any;
265
+ app: StepperApp;
266
+ api: API;
267
+ metadata?: ContextMetadata;
268
+ };
269
+ type ContextMetadata = {
270
+ invocationId?: string;
271
+ runId?: string;
272
+ workflowId?: string;
273
+ [key: string]: any;
274
+ };
275
+ type Invoke<TResponse, TInput extends Input> = (context: Context<TInput>) => Promise<TResponse> | TResponse;
276
+ type Descriptions = {
277
+ key: string;
278
+ label: string;
279
+ helpText?: string;
280
+ example?: string;
281
+ }[];
282
+ type DescribeResponse<TResponse, TInput extends Input> = (context: Context<TInput>, response: TResponse) => Promise<Descriptions> | Descriptions;
283
+ interface Callable<TResponse, TInput extends Input> {
284
+ fields?: InputFields;
285
+ invoke: Invoke<TResponse, TInput>;
286
+ exampleItem?: any;
287
+ describe?: DescribeResponse<TResponse, TInput>;
288
+ }
289
+ interface CallableList<TResponse, TInput extends Input> extends Callable<TResponse, TInput> {
290
+ exampleItem?: DropdownOption | Invoke<DropdownOption, TInput>;
291
+ }
292
+ interface DefaultAction<TResponse, TInput extends Input> {
293
+ key: string;
294
+ name: string;
295
+ async?: false;
296
+ description: string;
297
+ aiHelp?: string;
298
+ hidden?: boolean;
299
+ icon?: string;
300
+ verb: 'create' | 'update' | 'delete' | 'lookup';
301
+ call: Callable<TResponse, TInput>;
302
+ cost?: number | Invoke<number, TInput>;
303
+ }
304
+ interface ListAction<TResponse, TInput extends {
305
+ [key: string]: any;
306
+ }> extends Omit<DefaultAction<TResponse, TInput>, 'call' | 'verb'> {
307
+ verb: 'list';
308
+ searchable?: false;
309
+ call: CallableList<PaginatedResponse, TInput & {
310
+ nextCursor?: string | number;
311
+ search?: string;
312
+ }>;
313
+ }
314
+ interface CreateListOptionAction<TResponse, TInput extends {
315
+ [key: string]: any;
316
+ }> extends Omit<DefaultAction<TResponse, TInput>, 'call' | 'verb'> {
317
+ verb: 'create-option';
318
+ call: Callable<DropdownOption, TInput>;
319
+ }
320
+ interface AsyncAction<TResponse, TInput extends {
321
+ [key: string]: any;
322
+ }> extends Omit<DefaultAction<TResponse, TInput>, 'call' | 'async'> {
323
+ async: true;
324
+ call: Callable<{
325
+ expiresAt?: number;
326
+ treatExpiryAsSuccess?: boolean;
327
+ } | undefined, TInput>;
328
+ }
329
+ interface SearchListAction<TInput extends {
330
+ [key: string]: any;
331
+ }> {
332
+ key: string;
333
+ name: string;
334
+ async?: false;
335
+ description: string;
336
+ icon?: string;
337
+ hidden?: boolean;
338
+ verb: 'list';
339
+ searchable: true;
340
+ cost?: number | Invoke<number, TInput>;
341
+ call: CallableList<PaginatedResponse, TInput & {
342
+ search?: string;
343
+ nextCursor?: string | number;
344
+ }>;
345
+ }
346
+ interface PaginatedResponse {
347
+ items: DropdownOption[];
348
+ hasMore?: boolean;
349
+ nextCursor: string | number | null;
350
+ }
351
+ type Action<TResponse extends any = any, TInput extends {
352
+ [key: string]: any;
353
+ } = {
354
+ [key: string]: any;
355
+ }> = AsyncAction<TResponse, TInput> | DefaultAction<TResponse, TInput> | ListAction<TResponse, TInput> | SearchListAction<TInput> | CreateListOptionAction<TResponse, TInput>;
356
+ interface BaseTrigger {
357
+ key: string;
358
+ name: string;
359
+ description: string;
360
+ poll: CallableList<PaginatedResponse, any>;
361
+ intervalMinutes?: number;
362
+ icon?: string;
363
+ hidden?: boolean;
364
+ }
365
+ interface PollingTrigger extends BaseTrigger {
366
+ type: 'polling';
367
+ }
368
+ interface WebhookPayload {
369
+ method: string;
370
+ headers?: Record<string, string | string[]>;
371
+ query?: Record<string, string | string[]>;
372
+ body?: any;
373
+ raw?: string;
374
+ received_at?: string;
375
+ }
376
+ interface WebhookBaseTrigger extends BaseTrigger {
377
+ type: 'webhook';
378
+ subscribe: Invoke<{
379
+ hookId: string | number;
380
+ }, {
381
+ [key: string]: any;
382
+ webhookUrl: string;
383
+ }>;
384
+ unsubscribe: Invoke<any, {
385
+ hookId: string | number;
386
+ }>;
387
+ disableListen?: boolean;
388
+ }
389
+ interface WebhookSourceTrigger extends WebhookBaseTrigger {
390
+ eventSource: 'webhook';
391
+ handleWebhook: Invoke<any, {
392
+ webhookPayload: WebhookPayload;
393
+ } & {
394
+ [key: string]: any;
395
+ }>;
396
+ }
397
+ interface WebhookPollSourceTrigger extends WebhookBaseTrigger {
398
+ eventSource: 'poll';
399
+ }
400
+ type WebhookTrigger = WebhookSourceTrigger | WebhookPollSourceTrigger;
401
+ interface ManualTrigger {
402
+ key: string;
403
+ name: string;
404
+ description: string;
405
+ type: 'manual';
406
+ icon?: string;
407
+ fields: InputFields;
408
+ hidden?: boolean;
409
+ }
410
+ type Trigger = PollingTrigger | WebhookTrigger | ManualTrigger;
411
+ type GlobalWebhookEvent = {
412
+ channel: string;
413
+ payload: WebhookPayload;
414
+ };
415
+ interface GlobalWebhookResponse {
416
+ events: GlobalWebhookEvent[] | null;
417
+ }
418
+ interface GlobalWebhook {
419
+ key: string;
420
+ name: string;
421
+ handleGlobalWebhook: Invoke<GlobalWebhookResponse | Response, {
422
+ webhookPayload: WebhookPayload;
423
+ }>;
424
+ }
425
+ type FlowRequestConfiguration = {
426
+ setBaseURI: (uri: string) => void;
427
+ setHeader: (key: string, value: string) => void;
428
+ };
429
+ type RequestMiddleware = {
430
+ before?: (request: FlowRequestConfiguration, context: Context) => void;
431
+ after?: (response: Response, context: Context<[]>) => Promise<Response> | Response;
432
+ disableDefaultErrorHandling?: boolean;
433
+ };
434
+ type Authentication = BasicAuthentication | OAuth2Authentication | CustomAuthentication | BearerAuthentication | NoneAuthentication;
435
+ interface DependencyInfo {
436
+ dependencies: string[] | null;
437
+ hasLimitations: boolean;
438
+ limitations: string[];
439
+ limitationMessages?: string[];
440
+ hasDynamicFields: boolean;
441
+ }
442
+ interface AppDependenciesMap {
443
+ actions: {
444
+ [key: string]: DependencyInfo;
445
+ };
446
+ triggers: {
447
+ [key: string]: DependencyInfo;
448
+ };
449
+ connection?: DependencyInfo;
450
+ }
451
+ interface StepperApp {
452
+ key: string;
453
+ name: string;
454
+ icon: string;
455
+ url: string;
456
+ description: string;
457
+ version: number;
458
+ platformVersion: string;
459
+ authentication: Authentication;
460
+ isPlatformApp?: boolean;
461
+ actions: Action[] | ((context: Context) => Promise<Action[]> | Action[]);
462
+ triggers: Trigger[] | ((context: Context) => Promise<Trigger[]> | Trigger[]);
463
+ globalWebhooks?: GlobalWebhook[];
464
+ requestMiddleware?: RequestMiddleware;
465
+ parameterDependencies?: AppDependenciesMap;
466
+ }
467
+ declare function app(app: StepperApp): StepperApp;
468
+ declare function action<TResponse, TInput extends {
469
+ [key: string]: any;
470
+ }>(action: Action<TResponse, TInput>): Action<TResponse, TInput>;
471
+ declare function trigger(trigger: Trigger): Trigger;
472
+ declare function authentication(authentication: Authentication): Authentication;
473
+ /**
474
+ * HTTP status code types - matches Hono's exact type structure
475
+ * @see https://github.com/honojs/hono
476
+ */
477
+ type InfoStatusCode = 100 | 101 | 102 | 103;
478
+ type SuccessStatusCode = 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 226;
479
+ type DeprecatedStatusCode = 305 | 306;
480
+ type RedirectStatusCode = 300 | 301 | 302 | 303 | 304 | DeprecatedStatusCode | 307 | 308;
481
+ type ClientErrorStatusCode = 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 421 | 422 | 423 | 424 | 425 | 426 | 428 | 429 | 431 | 451;
482
+ type ServerErrorStatusCode = 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511;
483
+ type UnofficialStatusCode = -1;
484
+ type StatusCode = InfoStatusCode | SuccessStatusCode | RedirectStatusCode | ClientErrorStatusCode | ServerErrorStatusCode | UnofficialStatusCode;
485
+ type ContentlessStatusCode = 101 | 204 | 205 | 304;
486
+ type ContentfulStatusCode = Exclude<StatusCode, ContentlessStatusCode>;
487
+ /**
488
+ * HTTP status code type alias - use ContentfulStatusCode for responses with content
489
+ */
490
+ type HTTPStatusCode = ContentfulStatusCode;
491
+ /**
492
+ * HTTP Error classes for proper status code handling in HTTP responses
493
+ * These are used by app-wrapper and dispatcher to return correct HTTP status codes
494
+ */
495
+ declare class HTTPError extends Error {
496
+ readonly statusCode: HTTPStatusCode;
497
+ readonly details?: any | undefined;
498
+ readonly __stepperHttpError: true;
499
+ constructor(message: string, statusCode: HTTPStatusCode, details?: any | undefined);
500
+ /**
501
+ * Type guard - safe across package boundaries (unlike instanceof)
502
+ * Uses brand property to avoid false positives from duck typing
503
+ */
504
+ static is(error: unknown): error is HTTPError;
505
+ static hasStatus(error: unknown, statusCode: HTTPStatusCode): boolean;
506
+ }
507
+ declare class HTTPNotFoundError extends HTTPError {
508
+ constructor(message: string, details?: any);
509
+ static is(error: unknown): error is HTTPNotFoundError;
510
+ }
511
+ declare class BadRequestError extends HTTPError {
512
+ constructor(message: string, details?: any);
513
+ static is(error: unknown): error is BadRequestError;
514
+ }
515
+ declare class UnprocessableEntityError extends HTTPError {
516
+ constructor(message: string, details?: any);
517
+ static is(error: unknown): error is UnprocessableEntityError;
518
+ }
519
+ declare class UnauthorizedError extends HTTPError {
520
+ constructor(message: string, details?: any);
521
+ static is(error: unknown): error is UnauthorizedError;
522
+ }
523
+ declare class ForbiddenError extends HTTPError {
524
+ constructor(message: string, details?: any);
525
+ static is(error: unknown): error is ForbiddenError;
526
+ }
527
+
528
+ export { type API, type Action, type AppDependenciesMap, type Authentication, BadRequestError, BaseError, type BasicAuthentication, type BearerAuthentication, type Callable, type CallableList, type ClientErrorStatusCode, type ContentfulStatusCode, type ContentlessStatusCode, type Context, type ContextMetadata, CriticalAuthenticationError, type CustomAuthentication, type DependencyInfo, type DeprecatedStatusCode, type DescribeResponse, type Descriptions, type DropdownInputFieldMultipleValue, type DropdownInputFieldSingleValue, type DropdownOption, type DynamicList, type EmbeddedInputField, type ErrorField, type ErrorType, type ErrorTypes, type FlowRequestConfiguration, ForbiddenError, type GlobalWebhook, type GlobalWebhookEvent, type GlobalWebhookResponse, HTTPError, HTTPNotFoundError, type HTTPStatusCode, type InfoStatusCode, type Input, type InputField, type InputFields, type Invoke, type ManualTrigger, type MessageField, NonRetryableError, type NoneAuthentication, NotFoundError, type OAuth2Authentication, type ObjectInputField, type PaginatedResponse, type PollingTrigger, RateLimitHitError, type RedirectStatusCode, type RefInputField, type RequestClient, type RequestMiddleware, type SchemaInputField, type ServerErrorStatusCode, StaleAuthenticationError, type StatusCode, type StepperApp, type SubscriptionOptionFilter, type SubscriptionOptions, type SuccessStatusCode, type TemporaryFile, type Trigger, UnauthorizedError, UnknownError, type UnofficialStatusCode, UnprocessableEntityError, type WebhookBaseTrigger, type WebhookPayload, type WebhookPollSourceTrigger, type WebhookSourceTrigger, type WebhookTrigger, action, app, authentication, trigger };
package/dist/index.mjs ADDED
@@ -0,0 +1,135 @@
1
+ // src/index.ts
2
+ var BaseError = class extends Error {
3
+ constructor(message, type, details) {
4
+ super(message);
5
+ this.type = type;
6
+ this.details = details;
7
+ }
8
+ };
9
+ var UnknownError = class extends BaseError {
10
+ constructor(message, details) {
11
+ super(message, "unknown", details);
12
+ }
13
+ };
14
+ var NonRetryableError = class extends BaseError {
15
+ constructor(message, details) {
16
+ super(message, "nonRetryable", details);
17
+ }
18
+ };
19
+ var NotFoundError = class extends BaseError {
20
+ constructor(message, details) {
21
+ super(message, "notFound", details);
22
+ }
23
+ };
24
+ var RateLimitHitError = class extends BaseError {
25
+ constructor(message, retryAfter, details) {
26
+ super(message, "rateLimitHit", details);
27
+ this.retryAfter = retryAfter;
28
+ }
29
+ };
30
+ var CriticalAuthenticationError = class extends BaseError {
31
+ constructor(message, details) {
32
+ super(message, "criticalAuthentication", details);
33
+ }
34
+ };
35
+ var StaleAuthenticationError = class extends BaseError {
36
+ constructor(message, details) {
37
+ super(message, "staleAuthentication", details);
38
+ }
39
+ };
40
+ function app(app2) {
41
+ return app2;
42
+ }
43
+ function action(action2) {
44
+ return action2;
45
+ }
46
+ function trigger(trigger2) {
47
+ return trigger2;
48
+ }
49
+ function authentication(authentication2) {
50
+ return authentication2;
51
+ }
52
+ var HTTPError = class _HTTPError extends Error {
53
+ constructor(message, statusCode, details) {
54
+ super(message);
55
+ this.statusCode = statusCode;
56
+ this.details = details;
57
+ // Brand property to avoid duck typing issues with other error objects
58
+ this.__stepperHttpError = true;
59
+ this.name = "HTTPError";
60
+ }
61
+ /**
62
+ * Type guard - safe across package boundaries (unlike instanceof)
63
+ * Uses brand property to avoid false positives from duck typing
64
+ */
65
+ static is(error) {
66
+ return error instanceof Error && "__stepperHttpError" in error && error.__stepperHttpError === true && "statusCode" in error && typeof error.statusCode === "number";
67
+ }
68
+ static hasStatus(error, statusCode) {
69
+ return _HTTPError.is(error) && error.statusCode === statusCode;
70
+ }
71
+ };
72
+ var HTTPNotFoundError = class extends HTTPError {
73
+ constructor(message, details) {
74
+ super(message, 404, details);
75
+ this.name = "HTTPNotFoundError";
76
+ }
77
+ static is(error) {
78
+ return HTTPError.hasStatus(error, 404);
79
+ }
80
+ };
81
+ var BadRequestError = class extends HTTPError {
82
+ constructor(message, details) {
83
+ super(message, 400, details);
84
+ this.name = "BadRequestError";
85
+ }
86
+ static is(error) {
87
+ return HTTPError.hasStatus(error, 400);
88
+ }
89
+ };
90
+ var UnprocessableEntityError = class extends HTTPError {
91
+ constructor(message, details) {
92
+ super(message, 422, details);
93
+ this.name = "UnprocessableEntityError";
94
+ }
95
+ static is(error) {
96
+ return HTTPError.hasStatus(error, 422);
97
+ }
98
+ };
99
+ var UnauthorizedError = class extends HTTPError {
100
+ constructor(message, details) {
101
+ super(message, 401, details);
102
+ this.name = "UnauthorizedError";
103
+ }
104
+ static is(error) {
105
+ return HTTPError.hasStatus(error, 401);
106
+ }
107
+ };
108
+ var ForbiddenError = class extends HTTPError {
109
+ constructor(message, details) {
110
+ super(message, 403, details);
111
+ this.name = "ForbiddenError";
112
+ }
113
+ static is(error) {
114
+ return HTTPError.hasStatus(error, 403);
115
+ }
116
+ };
117
+ export {
118
+ BadRequestError,
119
+ BaseError,
120
+ CriticalAuthenticationError,
121
+ ForbiddenError,
122
+ HTTPError,
123
+ HTTPNotFoundError,
124
+ NonRetryableError,
125
+ NotFoundError,
126
+ RateLimitHitError,
127
+ StaleAuthenticationError,
128
+ UnauthorizedError,
129
+ UnknownError,
130
+ UnprocessableEntityError,
131
+ action,
132
+ app,
133
+ authentication,
134
+ trigger
135
+ };
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "@stepper-io/core",
3
+ "version": "1.0.0",
4
+ "description": "Core types and runtime helpers for building Stepper apps",
5
+ "main": "dist/index.mjs",
6
+ "types": "dist/index.d.mts",
7
+ "exports": {
8
+ ".": {
9
+ "source": "./src/index.ts",
10
+ "types": "./dist/index.d.mts",
11
+ "import": "./dist/index.mjs",
12
+ "default": "./dist/index.mjs"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist"
17
+ ],
18
+ "sideEffects": false,
19
+ "keywords": [
20
+ "stepper",
21
+ "stepper-io",
22
+ "integrations",
23
+ "types"
24
+ ],
25
+ "author": "Paperform",
26
+ "license": "MIT",
27
+ "repository": {
28
+ "type": "git",
29
+ "url": "git+https://github.com/paperform-co/paperform.git",
30
+ "directory": "resources/stepper-io/core"
31
+ },
32
+ "homepage": "https://github.com/paperform-co/paperform/tree/main/resources/stepper-io/core",
33
+ "bugs": {
34
+ "url": "https://github.com/paperform-co/paperform/issues"
35
+ },
36
+ "engines": {
37
+ "node": ">=20"
38
+ },
39
+ "publishConfig": {
40
+ "access": "public"
41
+ },
42
+ "devDependencies": {
43
+ "tsup": "^8.5.0"
44
+ },
45
+ "scripts": {
46
+ "build": "tsup",
47
+ "typecheck": "tsc --noEmit"
48
+ }
49
+ }