@marktoflow/integrations 2.0.1 → 2.0.2

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,165 @@
1
+ /**
2
+ * Google Sheets Integration
3
+ *
4
+ * Spreadsheet automation platform.
5
+ * API Docs: https://developers.google.com/sheets/api
6
+ */
7
+ import { sheets_v4 } from 'googleapis';
8
+ import { SDKInitializer } from '@marktoflow/core';
9
+ export interface SpreadsheetInfo {
10
+ spreadsheetId: string;
11
+ properties: {
12
+ title: string;
13
+ locale: string;
14
+ autoRecalc: string;
15
+ timeZone: string;
16
+ };
17
+ sheets: SheetInfo[];
18
+ }
19
+ export interface SheetInfo {
20
+ sheetId: number;
21
+ title: string;
22
+ index: number;
23
+ sheetType: string;
24
+ gridProperties: {
25
+ rowCount: number;
26
+ columnCount: number;
27
+ };
28
+ }
29
+ export interface CellData {
30
+ row: number;
31
+ column: number;
32
+ value: string | number | boolean | null;
33
+ formattedValue?: string;
34
+ formula?: string;
35
+ }
36
+ export interface AppendValuesOptions {
37
+ range: string;
38
+ values: unknown[][];
39
+ valueInputOption?: 'RAW' | 'USER_ENTERED';
40
+ insertDataOption?: 'OVERWRITE' | 'INSERT_ROWS';
41
+ }
42
+ export interface UpdateValuesOptions {
43
+ range: string;
44
+ values: unknown[][];
45
+ valueInputOption?: 'RAW' | 'USER_ENTERED';
46
+ }
47
+ export interface BatchUpdateOptions {
48
+ data: {
49
+ range: string;
50
+ values: unknown[][];
51
+ }[];
52
+ valueInputOption?: 'RAW' | 'USER_ENTERED';
53
+ }
54
+ export interface CreateSpreadsheetOptions {
55
+ title: string;
56
+ sheets?: {
57
+ title: string;
58
+ rowCount?: number;
59
+ columnCount?: number;
60
+ }[];
61
+ locale?: string;
62
+ timeZone?: string;
63
+ }
64
+ export interface AddSheetOptions {
65
+ title: string;
66
+ rowCount?: number;
67
+ columnCount?: number;
68
+ index?: number;
69
+ }
70
+ /**
71
+ * Google Sheets actions for workflow integration
72
+ */
73
+ export declare class GoogleSheetsActions {
74
+ private sheets;
75
+ constructor(sheets: sheets_v4.Sheets);
76
+ /**
77
+ * Get spreadsheet metadata
78
+ */
79
+ getSpreadsheet(spreadsheetId: string): Promise<SpreadsheetInfo>;
80
+ /**
81
+ * Get values from a range
82
+ */
83
+ getValues(spreadsheetId: string, range: string): Promise<unknown[][]>;
84
+ /**
85
+ * Get multiple ranges at once
86
+ */
87
+ batchGetValues(spreadsheetId: string, ranges: string[]): Promise<{
88
+ range: string;
89
+ values: unknown[][];
90
+ }[]>;
91
+ /**
92
+ * Append values to a sheet
93
+ */
94
+ appendValues(spreadsheetId: string, options: AppendValuesOptions): Promise<{
95
+ updatedRange: string;
96
+ updatedRows: number;
97
+ updatedColumns: number;
98
+ }>;
99
+ /**
100
+ * Update values in a range
101
+ */
102
+ updateValues(spreadsheetId: string, options: UpdateValuesOptions): Promise<{
103
+ updatedRange: string;
104
+ updatedRows: number;
105
+ updatedColumns: number;
106
+ updatedCells: number;
107
+ }>;
108
+ /**
109
+ * Update multiple ranges at once
110
+ */
111
+ batchUpdateValues(spreadsheetId: string, options: BatchUpdateOptions): Promise<{
112
+ totalUpdatedRows: number;
113
+ totalUpdatedColumns: number;
114
+ totalUpdatedCells: number;
115
+ }>;
116
+ /**
117
+ * Clear values in a range
118
+ */
119
+ clearValues(spreadsheetId: string, range: string): Promise<{
120
+ clearedRange: string;
121
+ }>;
122
+ /**
123
+ * Create a new spreadsheet
124
+ */
125
+ createSpreadsheet(options: CreateSpreadsheetOptions): Promise<SpreadsheetInfo>;
126
+ /**
127
+ * Add a new sheet to an existing spreadsheet
128
+ */
129
+ addSheet(spreadsheetId: string, options: AddSheetOptions): Promise<SheetInfo>;
130
+ /**
131
+ * Delete a sheet
132
+ */
133
+ deleteSheet(spreadsheetId: string, sheetId: number): Promise<void>;
134
+ /**
135
+ * Duplicate a sheet
136
+ */
137
+ duplicateSheet(spreadsheetId: string, sourceSheetId: number, newSheetName?: string): Promise<SheetInfo>;
138
+ /**
139
+ * Find and replace text
140
+ */
141
+ findReplace(spreadsheetId: string, find: string, replacement: string, options?: {
142
+ sheetId?: number;
143
+ allSheets?: boolean;
144
+ matchCase?: boolean;
145
+ matchEntireCell?: boolean;
146
+ searchByRegex?: boolean;
147
+ }): Promise<{
148
+ occurrencesChanged: number;
149
+ valuesChanged: number;
150
+ }>;
151
+ /**
152
+ * Sort a range
153
+ */
154
+ sortRange(spreadsheetId: string, range: string, sortSpecs: {
155
+ dimensionIndex: number;
156
+ sortOrder: 'ASCENDING' | 'DESCENDING';
157
+ }[]): Promise<void>;
158
+ /**
159
+ * Parse A1 notation into grid range
160
+ * Helper method for internal use
161
+ */
162
+ private parseA1Notation;
163
+ }
164
+ export declare const GoogleSheetsInitializer: SDKInitializer;
165
+ //# sourceMappingURL=google-sheets.d.ts.map
@@ -0,0 +1,120 @@
1
+ /**
2
+ * HTTP Integration
3
+ *
4
+ * Generic REST API client for calling any HTTP endpoint.
5
+ * Essential for APIs without dedicated integrations.
6
+ */
7
+ import { SDKInitializer } from '@marktoflow/core';
8
+ export interface HttpRequestOptions {
9
+ method?: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'HEAD' | 'OPTIONS';
10
+ headers?: Record<string, string>;
11
+ query?: Record<string, string | number | boolean>;
12
+ body?: unknown;
13
+ timeout?: number;
14
+ followRedirects?: boolean;
15
+ validateStatus?: (status: number) => boolean;
16
+ }
17
+ export interface HttpResponse<T = unknown> {
18
+ status: number;
19
+ statusText: string;
20
+ headers: Record<string, string>;
21
+ data: T;
22
+ ok: boolean;
23
+ url: string;
24
+ }
25
+ export interface HttpClientConfig {
26
+ baseUrl?: string;
27
+ headers?: Record<string, string>;
28
+ timeout?: number;
29
+ auth?: {
30
+ type: 'bearer' | 'basic' | 'api-key';
31
+ token?: string;
32
+ username?: string;
33
+ password?: string;
34
+ apiKey?: string;
35
+ apiKeyHeader?: string;
36
+ };
37
+ }
38
+ /**
39
+ * Generic HTTP client for workflow integration
40
+ */
41
+ export declare class HttpClient {
42
+ private baseUrl;
43
+ private defaultHeaders;
44
+ private defaultTimeout;
45
+ constructor(config?: HttpClientConfig);
46
+ /**
47
+ * Make an HTTP request
48
+ */
49
+ request<T = unknown>(path: string, options?: HttpRequestOptions): Promise<HttpResponse<T>>;
50
+ /**
51
+ * GET request
52
+ */
53
+ get<T = unknown>(path: string, options?: Omit<HttpRequestOptions, 'method' | 'body'>): Promise<HttpResponse<T>>;
54
+ /**
55
+ * POST request
56
+ */
57
+ post<T = unknown>(path: string, body?: unknown, options?: Omit<HttpRequestOptions, 'method' | 'body'>): Promise<HttpResponse<T>>;
58
+ /**
59
+ * PUT request
60
+ */
61
+ put<T = unknown>(path: string, body?: unknown, options?: Omit<HttpRequestOptions, 'method' | 'body'>): Promise<HttpResponse<T>>;
62
+ /**
63
+ * PATCH request
64
+ */
65
+ patch<T = unknown>(path: string, body?: unknown, options?: Omit<HttpRequestOptions, 'method' | 'body'>): Promise<HttpResponse<T>>;
66
+ /**
67
+ * DELETE request
68
+ */
69
+ delete<T = unknown>(path: string, options?: Omit<HttpRequestOptions, 'method'>): Promise<HttpResponse<T>>;
70
+ /**
71
+ * HEAD request
72
+ */
73
+ head(path: string, options?: Omit<HttpRequestOptions, 'method' | 'body'>): Promise<HttpResponse<undefined>>;
74
+ /**
75
+ * Set a default header
76
+ */
77
+ setHeader(name: string, value: string): void;
78
+ /**
79
+ * Remove a default header
80
+ */
81
+ removeHeader(name: string): void;
82
+ /**
83
+ * Set bearer token
84
+ */
85
+ setBearerToken(token: string): void;
86
+ /**
87
+ * Set base URL
88
+ */
89
+ setBaseUrl(url: string): void;
90
+ }
91
+ /**
92
+ * HTTP error with response details
93
+ */
94
+ export declare class HttpError extends Error {
95
+ readonly status: number;
96
+ readonly statusText: string;
97
+ readonly headers: Record<string, string>;
98
+ readonly data: unknown;
99
+ readonly url: string;
100
+ constructor(response: HttpResponse);
101
+ }
102
+ /**
103
+ * Convenience function to make a one-off request
104
+ */
105
+ export declare function httpRequest<T = unknown>(url: string, options?: HttpRequestOptions & {
106
+ headers?: Record<string, string>;
107
+ }): Promise<HttpResponse<T>>;
108
+ /**
109
+ * GraphQL client helper
110
+ */
111
+ export declare class GraphQLClient {
112
+ private http;
113
+ constructor(endpoint: string, config?: Omit<HttpClientConfig, 'baseUrl'>);
114
+ /**
115
+ * Execute a GraphQL query or mutation
116
+ */
117
+ query<T = unknown>(query: string, variables?: Record<string, unknown>, operationName?: string): Promise<T>;
118
+ }
119
+ export declare const HttpInitializer: SDKInitializer;
120
+ //# sourceMappingURL=http.d.ts.map
@@ -0,0 +1,3 @@
1
+ import { SDKInitializer } from '@marktoflow/core';
2
+ export declare const JiraInitializer: SDKInitializer;
3
+ //# sourceMappingURL=jira.d.ts.map
@@ -0,0 +1,163 @@
1
+ /**
2
+ * Linear Integration
3
+ *
4
+ * Modern issue tracking for development teams.
5
+ * API Docs: https://developers.linear.app/docs/graphql/working-with-the-graphql-api
6
+ */
7
+ import { SDKInitializer } from '@marktoflow/core';
8
+ export interface LinearIssue {
9
+ id: string;
10
+ identifier: string;
11
+ title: string;
12
+ description?: string;
13
+ priority: number;
14
+ priorityLabel: string;
15
+ state: {
16
+ id: string;
17
+ name: string;
18
+ type: string;
19
+ };
20
+ assignee?: {
21
+ id: string;
22
+ name: string;
23
+ email: string;
24
+ };
25
+ team: {
26
+ id: string;
27
+ name: string;
28
+ key: string;
29
+ };
30
+ project?: {
31
+ id: string;
32
+ name: string;
33
+ };
34
+ labels: {
35
+ id: string;
36
+ name: string;
37
+ color: string;
38
+ }[];
39
+ createdAt: string;
40
+ updatedAt: string;
41
+ url: string;
42
+ }
43
+ export interface LinearProject {
44
+ id: string;
45
+ name: string;
46
+ description?: string;
47
+ state: string;
48
+ progress: number;
49
+ targetDate?: string;
50
+ teams: {
51
+ id: string;
52
+ name: string;
53
+ }[];
54
+ }
55
+ export interface LinearTeam {
56
+ id: string;
57
+ name: string;
58
+ key: string;
59
+ description?: string;
60
+ issueCount: number;
61
+ }
62
+ export interface CreateIssueOptions {
63
+ teamId: string;
64
+ title: string;
65
+ description?: string;
66
+ priority?: number;
67
+ assigneeId?: string;
68
+ labelIds?: string[];
69
+ projectId?: string;
70
+ stateId?: string;
71
+ estimate?: number;
72
+ dueDate?: string;
73
+ parentId?: string;
74
+ }
75
+ export interface UpdateIssueOptions {
76
+ title?: string;
77
+ description?: string;
78
+ priority?: number;
79
+ assigneeId?: string;
80
+ labelIds?: string[];
81
+ projectId?: string;
82
+ stateId?: string;
83
+ estimate?: number;
84
+ dueDate?: string;
85
+ }
86
+ export interface SearchIssuesOptions {
87
+ query?: string;
88
+ teamId?: string;
89
+ assigneeId?: string;
90
+ stateId?: string;
91
+ labelIds?: string[];
92
+ projectId?: string;
93
+ priority?: number;
94
+ first?: number;
95
+ after?: string;
96
+ }
97
+ /**
98
+ * Linear GraphQL client for workflow integration
99
+ */
100
+ export declare class LinearClient {
101
+ private apiKey;
102
+ constructor(apiKey: string);
103
+ private query;
104
+ /**
105
+ * Get the current user
106
+ */
107
+ getViewer(): Promise<{
108
+ id: string;
109
+ name: string;
110
+ email: string;
111
+ }>;
112
+ /**
113
+ * List teams
114
+ */
115
+ listTeams(): Promise<LinearTeam[]>;
116
+ /**
117
+ * Get an issue by ID or identifier
118
+ */
119
+ getIssue(idOrIdentifier: string): Promise<LinearIssue>;
120
+ /**
121
+ * Create an issue
122
+ */
123
+ createIssue(options: CreateIssueOptions): Promise<LinearIssue>;
124
+ /**
125
+ * Update an issue
126
+ */
127
+ updateIssue(issueId: string, options: UpdateIssueOptions): Promise<LinearIssue>;
128
+ /**
129
+ * Search issues
130
+ */
131
+ searchIssues(options?: SearchIssuesOptions): Promise<{
132
+ issues: LinearIssue[];
133
+ hasMore: boolean;
134
+ endCursor?: string;
135
+ }>;
136
+ /**
137
+ * List projects
138
+ */
139
+ listProjects(teamId?: string): Promise<LinearProject[]>;
140
+ /**
141
+ * Get workflow states for a team
142
+ */
143
+ getWorkflowStates(teamId: string): Promise<{
144
+ id: string;
145
+ name: string;
146
+ type: string;
147
+ position: number;
148
+ }[]>;
149
+ /**
150
+ * Add a comment to an issue
151
+ */
152
+ addComment(issueId: string, body: string): Promise<{
153
+ id: string;
154
+ body: string;
155
+ createdAt: string;
156
+ }>;
157
+ /**
158
+ * Archive an issue
159
+ */
160
+ archiveIssue(issueId: string): Promise<void>;
161
+ }
162
+ export declare const LinearInitializer: SDKInitializer;
163
+ //# sourceMappingURL=linear.d.ts.map
@@ -0,0 +1,91 @@
1
+ /**
2
+ * MySQL Integration
3
+ *
4
+ * Popular open-source relational database.
5
+ * API: Using mysql2 driver
6
+ */
7
+ import { SDKInitializer } from '@marktoflow/core';
8
+ export interface MySQLConfig {
9
+ host: string;
10
+ port?: number;
11
+ database: string;
12
+ user: string;
13
+ password: string;
14
+ ssl?: boolean | {
15
+ rejectUnauthorized?: boolean;
16
+ };
17
+ connectTimeout?: number;
18
+ connectionLimit?: number;
19
+ waitForConnections?: boolean;
20
+ queueLimit?: number;
21
+ }
22
+ export interface QueryResult<T = unknown> {
23
+ rows: T[];
24
+ fields: {
25
+ name: string;
26
+ type: string;
27
+ }[];
28
+ affectedRows?: number;
29
+ insertId?: number;
30
+ }
31
+ export interface MySQLTransaction {
32
+ query<T = unknown>(sql: string, params?: unknown[]): Promise<QueryResult<T>>;
33
+ commit(): Promise<void>;
34
+ rollback(): Promise<void>;
35
+ }
36
+ /**
37
+ * MySQL client wrapper for workflow integration
38
+ * Note: This is a lightweight wrapper. The actual mysql2 module will be dynamically imported.
39
+ */
40
+ export declare class MySQLClient {
41
+ private pool;
42
+ private config;
43
+ constructor(config: MySQLConfig);
44
+ /**
45
+ * Initialize the connection pool
46
+ */
47
+ connect(): Promise<void>;
48
+ /**
49
+ * Execute a SQL query
50
+ */
51
+ query<T = unknown>(sql: string, params?: unknown[]): Promise<QueryResult<T>>;
52
+ /**
53
+ * Select data from a table
54
+ */
55
+ select<T = Record<string, unknown>>(table: string, options?: {
56
+ columns?: string[];
57
+ where?: Record<string, unknown>;
58
+ orderBy?: string;
59
+ limit?: number;
60
+ offset?: number;
61
+ }): Promise<T[]>;
62
+ /**
63
+ * Insert data into a table
64
+ */
65
+ insert<T = Record<string, unknown>>(table: string, data: Record<string, unknown> | Record<string, unknown>[]): Promise<{
66
+ insertId: number;
67
+ affectedRows: number;
68
+ }>;
69
+ /**
70
+ * Update data in a table
71
+ */
72
+ update<T = Record<string, unknown>>(table: string, data: Record<string, unknown>, where: Record<string, unknown>): Promise<{
73
+ affectedRows: number;
74
+ }>;
75
+ /**
76
+ * Delete data from a table
77
+ */
78
+ delete<T = Record<string, unknown>>(table: string, where: Record<string, unknown>): Promise<{
79
+ affectedRows: number;
80
+ }>;
81
+ /**
82
+ * Begin a transaction
83
+ */
84
+ transaction<T>(callback: (trx: MySQLTransaction) => Promise<T>): Promise<T>;
85
+ /**
86
+ * Close the connection pool
87
+ */
88
+ close(): Promise<void>;
89
+ }
90
+ export declare const MySQLInitializer: SDKInitializer;
91
+ //# sourceMappingURL=mysql.d.ts.map
@@ -0,0 +1,121 @@
1
+ import { TriggerType } from '@marktoflow/core';
2
+ export interface OutlookTriggerConfig {
3
+ token: string;
4
+ notificationUrl: string;
5
+ changeTypes?: ('created' | 'updated' | 'deleted')[];
6
+ resource?: string;
7
+ expirationMinutes?: number;
8
+ clientState?: string;
9
+ triggers: Array<{
10
+ id: string;
11
+ event: 'email_received' | 'email_updated' | 'email_deleted';
12
+ handler: (payload: OutlookTriggerPayload) => Promise<void>;
13
+ }>;
14
+ }
15
+ export interface OutlookTriggerPayload {
16
+ type: TriggerType;
17
+ event: 'email_received' | 'email_updated' | 'email_deleted';
18
+ subscriptionId: string;
19
+ changeType: string;
20
+ resource: string;
21
+ resourceData?: {
22
+ id: string;
23
+ [key: string]: unknown;
24
+ };
25
+ clientState?: string;
26
+ tenantId?: string;
27
+ }
28
+ export interface GraphSubscription {
29
+ id: string;
30
+ resource: string;
31
+ changeType: string;
32
+ notificationUrl: string;
33
+ expirationDateTime: string;
34
+ clientState?: string;
35
+ }
36
+ export interface GraphNotification {
37
+ value: Array<{
38
+ subscriptionId: string;
39
+ subscriptionExpirationDateTime: string;
40
+ changeType: string;
41
+ resource: string;
42
+ resourceData?: {
43
+ '@odata.type': string;
44
+ '@odata.id': string;
45
+ '@odata.etag': string;
46
+ id: string;
47
+ [key: string]: unknown;
48
+ };
49
+ clientState?: string;
50
+ tenantId?: string;
51
+ }>;
52
+ }
53
+ export interface GraphValidationRequest extends Record<string, unknown> {
54
+ validationToken: string;
55
+ }
56
+ /**
57
+ * Outlook trigger handler for Microsoft Graph webhook subscriptions.
58
+ *
59
+ * Setup requirements:
60
+ * 1. Register an Azure AD application with Mail.Read permissions
61
+ * 2. Set up a publicly accessible webhook endpoint
62
+ * 3. Call subscribe() to start receiving notifications
63
+ * 4. Handle subscription renewal before expiration (max ~3 days)
64
+ */
65
+ export declare class OutlookTrigger {
66
+ private config;
67
+ private client;
68
+ private subscription?;
69
+ constructor(config: OutlookTriggerConfig);
70
+ /**
71
+ * Create a subscription to receive mail notifications.
72
+ */
73
+ subscribe(): Promise<GraphSubscription>;
74
+ /**
75
+ * Renew an existing subscription.
76
+ */
77
+ renew(expirationMinutes?: number): Promise<GraphSubscription>;
78
+ /**
79
+ * Delete the subscription (stop receiving notifications).
80
+ */
81
+ unsubscribe(): Promise<void>;
82
+ /**
83
+ * Get the current subscription status.
84
+ */
85
+ getSubscription(): GraphSubscription | undefined;
86
+ /**
87
+ * Check if subscription is still active (not expired).
88
+ */
89
+ isSubscriptionActive(): boolean;
90
+ /**
91
+ * Handle an incoming Graph notification.
92
+ * Call this from your webhook endpoint after validation.
93
+ */
94
+ handleNotification(notification: GraphNotification): Promise<void>;
95
+ /**
96
+ * Check if a request is a validation request from Graph.
97
+ */
98
+ static isValidationRequest(query: Record<string, unknown>): query is GraphValidationRequest;
99
+ /**
100
+ * Validate the notification body structure.
101
+ */
102
+ static validateNotification(body: unknown): body is GraphNotification;
103
+ }
104
+ /**
105
+ * Express/Fastify-compatible middleware for handling Outlook Graph webhooks.
106
+ *
107
+ * Handles both:
108
+ * - Subscription validation (GET with validationToken)
109
+ * - Notification processing (POST with notification payload)
110
+ */
111
+ export declare function createOutlookWebhookHandler(trigger: OutlookTrigger): (req: {
112
+ method: string;
113
+ query: Record<string, unknown>;
114
+ body: unknown;
115
+ }, res: {
116
+ status: (code: number) => {
117
+ send: (body?: string) => void;
118
+ };
119
+ contentType: (type: string) => void;
120
+ }) => Promise<void>;
121
+ //# sourceMappingURL=outlook-trigger.d.ts.map