local-lite 0.2.5 → 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/README.md +18 -13
- package/dist/actions/manager.d.ts +9 -1
- package/dist/actions/manager.js +143 -62
- package/dist/actions/types.d.ts +33 -0
- package/dist/adapters/remote/index.d.ts +1 -0
- package/dist/adapters/remote/index.js +1 -0
- package/dist/adapters/remote/self-hosted.d.ts +64 -0
- package/dist/adapters/remote/self-hosted.js +126 -0
- package/dist/config/index.d.ts +2 -0
- package/dist/config/index.js +18 -1
- package/dist/config/resolve-remote.js +12 -0
- package/dist/config/types.d.ts +70 -0
- package/dist/devtools/SyncInspector.js +9 -2
- package/dist/email/index.d.ts +128 -0
- package/dist/email/index.js +431 -0
- package/dist/server/email.d.ts +41 -0
- package/dist/server/email.js +79 -0
- package/dist/server/index.d.ts +2 -0
- package/dist/server/index.js +16 -0
- package/dist/server/sync.d.ts +77 -0
- package/dist/server/sync.js +178 -0
- package/package.json +12 -1
- package/skills/local-lite-custom-adapter/SKILL.md +3 -0
- package/skills/local-lite-offline-actions/SKILL.md +69 -28
- package/skills/local-lite-react/SKILL.md +17 -0
- package/skills/local-lite-server/SKILL.md +53 -1
- package/skills/local-lite-setup/SKILL.md +18 -5
- package/skills/local-lite-upgrade/SKILL.md +9 -0
|
@@ -4,6 +4,7 @@ exports.resolveRemoteAdapter = resolveRemoteAdapter;
|
|
|
4
4
|
const supabase_js_1 = require("../adapters/remote/supabase.js");
|
|
5
5
|
const convex_js_1 = require("../adapters/remote/convex.js");
|
|
6
6
|
const firestore_js_1 = require("../adapters/remote/firestore.js");
|
|
7
|
+
const self_hosted_js_1 = require("../adapters/remote/self-hosted.js");
|
|
7
8
|
const demo_js_1 = require("../adapters/remote/demo.js");
|
|
8
9
|
const dynamic_js_1 = require("../utils/dynamic.js");
|
|
9
10
|
// Construct dynamically to prevent Metro, Webpack, and Rollup from treating
|
|
@@ -39,6 +40,17 @@ async function resolveRemoteAdapter(config) {
|
|
|
39
40
|
updatedAtColumn: config.convex.updatedAtColumn,
|
|
40
41
|
});
|
|
41
42
|
}
|
|
43
|
+
// 4. Self-hosted sync backend
|
|
44
|
+
if (config.server?.url) {
|
|
45
|
+
return new self_hosted_js_1.SelfHostedRemoteAdapter({
|
|
46
|
+
url: config.server.url,
|
|
47
|
+
token: config.server.token,
|
|
48
|
+
headers: config.server.headers,
|
|
49
|
+
tables: config.tables,
|
|
50
|
+
primaryKey: config.primaryKey,
|
|
51
|
+
pollIntervalMs: config.server.pollIntervalMs,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
42
54
|
const getSupabaseOptions = () => ({
|
|
43
55
|
tables: config.tables,
|
|
44
56
|
primaryKey: config.primaryKey,
|
package/dist/config/types.d.ts
CHANGED
|
@@ -69,6 +69,65 @@ export interface FirebaseConfigOptions {
|
|
|
69
69
|
*/
|
|
70
70
|
firestoreModule?: any;
|
|
71
71
|
}
|
|
72
|
+
export interface EmailConfig {
|
|
73
|
+
/**
|
|
74
|
+
* Email delivery provider:
|
|
75
|
+
* - 'nodemailer': Direct SMTP, Sendmail, SES, or custom transport via Nodemailer.
|
|
76
|
+
* - 'resend': Direct HTTP dispatch to Resend API.
|
|
77
|
+
* - 'sendgrid': Direct HTTP dispatch to SendGrid API.
|
|
78
|
+
* - 'postmark': Direct HTTP dispatch to Postmark API.
|
|
79
|
+
* - 'http': Custom HTTP endpoint or webhook.
|
|
80
|
+
*/
|
|
81
|
+
provider?: 'nodemailer' | 'resend' | 'sendgrid' | 'postmark' | 'http' | 'custom';
|
|
82
|
+
/**
|
|
83
|
+
* Transport configuration for Nodemailer:
|
|
84
|
+
* - A Nodemailer Transporter instance (e.g. from nodemailer.createTransport(...))
|
|
85
|
+
* - An SMTP configuration object ({ host, port, auth: { user, pass }, ... })
|
|
86
|
+
* - A connection URL string (e.g. 'smtps://user:pass@smtp.example.com')
|
|
87
|
+
*/
|
|
88
|
+
transport?: any;
|
|
89
|
+
/**
|
|
90
|
+
* API Key for HTTP email providers (Resend, SendGrid, Postmark).
|
|
91
|
+
*/
|
|
92
|
+
apiKey?: string;
|
|
93
|
+
/**
|
|
94
|
+
* Target endpoint URL for HTTP dispatch or custom webhook.
|
|
95
|
+
*/
|
|
96
|
+
endpoint?: string;
|
|
97
|
+
/**
|
|
98
|
+
* Custom HTTP request headers for HTTP providers.
|
|
99
|
+
*/
|
|
100
|
+
headers?: Record<string, string>;
|
|
101
|
+
/**
|
|
102
|
+
* Default email options (e.g. default 'from' address or headers).
|
|
103
|
+
*/
|
|
104
|
+
defaults?: {
|
|
105
|
+
from?: string;
|
|
106
|
+
[key: string]: any;
|
|
107
|
+
};
|
|
108
|
+
/**
|
|
109
|
+
* Additional handler options (template renderer, beforeSend, afterSend).
|
|
110
|
+
*/
|
|
111
|
+
options?: any;
|
|
112
|
+
}
|
|
113
|
+
export interface SelfHostedServerConfigOptions {
|
|
114
|
+
/**
|
|
115
|
+
* Endpoint base URL for the sync API (e.g. 'https://api.mycompany.com/api/sync').
|
|
116
|
+
*/
|
|
117
|
+
url: string;
|
|
118
|
+
/**
|
|
119
|
+
* Optional secret or JWT auth token sent in `Authorization: Bearer <token>`.
|
|
120
|
+
*/
|
|
121
|
+
token?: string;
|
|
122
|
+
/**
|
|
123
|
+
* Custom HTTP request headers.
|
|
124
|
+
*/
|
|
125
|
+
headers?: Record<string, string>;
|
|
126
|
+
/**
|
|
127
|
+
* Polling interval in milliseconds for live change detection. Default: 5000.
|
|
128
|
+
*/
|
|
129
|
+
pollIntervalMs?: number;
|
|
130
|
+
}
|
|
72
131
|
export interface LocalLiteConfig {
|
|
73
132
|
/**
|
|
74
133
|
* Local SQLite Database instance, name, factory function, or LocalDBAdapter.
|
|
@@ -119,6 +178,11 @@ export interface LocalLiteConfig {
|
|
|
119
178
|
* Firebase / Firestore backend connection options.
|
|
120
179
|
*/
|
|
121
180
|
firebase?: FirebaseConfigOptions;
|
|
181
|
+
/**
|
|
182
|
+
* Self-hosted sync backend options (using endpoints created with createSyncEndpoint() in local-lite/server).
|
|
183
|
+
* Enables complete cloud-adapter independence and self-hosting data sovereignty.
|
|
184
|
+
*/
|
|
185
|
+
server?: SelfHostedServerConfigOptions;
|
|
122
186
|
/**
|
|
123
187
|
* Custom remote adapter (overrides Supabase / Convex / Firebase).
|
|
124
188
|
*/
|
|
@@ -211,4 +275,10 @@ export interface LocalLiteConfig {
|
|
|
211
275
|
*/
|
|
212
276
|
auth?: LocalAuthEngineOptions;
|
|
213
277
|
localAuth?: LocalAuthEngineOptions;
|
|
278
|
+
/**
|
|
279
|
+
* Direct email delivery configuration (Nodemailer SMTP, Resend, SendGrid, Postmark, or custom HTTP).
|
|
280
|
+
* When set, `local-lite` handles all offline-queued emails directly without needing Convex,
|
|
281
|
+
* Supabase, or any external database adapters.
|
|
282
|
+
*/
|
|
283
|
+
email?: EmailConfig;
|
|
214
284
|
}
|
|
@@ -125,7 +125,14 @@ function SyncInspector({ client, position = 'bottom-right', variant = 'pill', in
|
|
|
125
125
|
{ id: 'retry', label: '🔄 Retry Failed', onPress: handleRetryFailed, bg: currentTheme.actionBg, color: currentTheme.actionText },
|
|
126
126
|
{ id: 'reset', label: '⏪ Reset Cursor', onPress: handleResetCursor, bg: currentTheme.actionBg, color: currentTheme.actionText },
|
|
127
127
|
{ id: 'clear-outbox', label: 'Clear Stuck Outbox', onPress: handleClearOutbox, disabled: status.pendingCount === 0, bg: '#EF4444', color: '#FFFFFF' },
|
|
128
|
-
|
|
128
|
+
{
|
|
129
|
+
id: 'flush-actions',
|
|
130
|
+
label: '📨 Flush Actions & Email',
|
|
131
|
+
onPress: () => runAction('Flushing actions & email...', (res) => `Flushed: ${res?.completed ?? 0} sent, ${res?.failed ?? 0} failed`, () => client.actions.flush()),
|
|
132
|
+
bg: '#8B5CF6',
|
|
133
|
+
color: '#FFFFFF',
|
|
134
|
+
},
|
|
135
|
+
], [handlePush, handlePull, handleRetryFailed, handleResetCursor, handleClearOutbox, runAction, client, currentTheme.actionBg, currentTheme.actionText, status.pendingCount]);
|
|
129
136
|
const triggerLabel = variant === 'compact'
|
|
130
137
|
? status.pendingCount > 0
|
|
131
138
|
? `${status.pendingCount} queued`
|
|
@@ -181,7 +188,7 @@ function SyncInspector({ client, position = 'bottom-right', variant = 'pill', in
|
|
|
181
188
|
backgroundColor: currentTheme.card,
|
|
182
189
|
borderColor: currentTheme.border,
|
|
183
190
|
},
|
|
184
|
-
], children: [(0, jsx_runtime_1.jsx)(Text, { style: [rnStyles.infoCardTitle, { color: currentTheme.textMuted }], children: "ENGINE ACTIONS" }), (0, jsx_runtime_1.jsx)(View, { style: rnStyles.btnRow, children: actionButtons.slice(0, 2).map((btn) => ((0, jsx_runtime_1.jsx)(TouchableOpacity, { onPress: btn.onPress, style: [rnStyles.actionBtn, { backgroundColor: btn.bg }], activeOpacity: 0.8, children: (0, jsx_runtime_1.jsx)(Text, { style: [rnStyles.actionBtnText, { color: btn.color }], children: btn.label }) }, btn.id))) }), (0, jsx_runtime_1.jsx)(View, { style: [rnStyles.btnRow, { marginTop: 8 }], children: actionButtons.slice(2, 4).map((btn) => ((0, jsx_runtime_1.jsx)(TouchableOpacity, { onPress: btn.onPress, style: [rnStyles.actionBtn, { backgroundColor: btn.bg }, btn.disabled && { opacity: 0.5 }], disabled: btn.disabled, activeOpacity: 0.8, children: (0, jsx_runtime_1.jsx)(Text, { style: [rnStyles.actionBtnText, { color: btn.color }], children: btn.label }) }, btn.id))) }), (0, jsx_runtime_1.jsx)(View, { style: [rnStyles.btnRow, { marginTop: 8 }], children: actionButtons.slice(4,
|
|
191
|
+
], children: [(0, jsx_runtime_1.jsx)(Text, { style: [rnStyles.infoCardTitle, { color: currentTheme.textMuted }], children: "ENGINE ACTIONS" }), (0, jsx_runtime_1.jsx)(View, { style: rnStyles.btnRow, children: actionButtons.slice(0, 2).map((btn) => ((0, jsx_runtime_1.jsx)(TouchableOpacity, { onPress: btn.onPress, style: [rnStyles.actionBtn, { backgroundColor: btn.bg }], activeOpacity: 0.8, children: (0, jsx_runtime_1.jsx)(Text, { style: [rnStyles.actionBtnText, { color: btn.color }], children: btn.label }) }, btn.id))) }), (0, jsx_runtime_1.jsx)(View, { style: [rnStyles.btnRow, { marginTop: 8 }], children: actionButtons.slice(2, 4).map((btn) => ((0, jsx_runtime_1.jsx)(TouchableOpacity, { onPress: btn.onPress, style: [rnStyles.actionBtn, { backgroundColor: btn.bg }, btn.disabled && { opacity: 0.5 }], disabled: btn.disabled, activeOpacity: 0.8, children: (0, jsx_runtime_1.jsx)(Text, { style: [rnStyles.actionBtnText, { color: btn.color }], children: btn.label }) }, btn.id))) }), (0, jsx_runtime_1.jsx)(View, { style: [rnStyles.btnRow, { marginTop: 8 }], children: actionButtons.slice(4, 6).map((btn) => ((0, jsx_runtime_1.jsx)(TouchableOpacity, { onPress: btn.onPress, style: [rnStyles.actionBtn, { backgroundColor: btn.bg }, btn.disabled && { opacity: 0.5 }], disabled: btn.disabled, activeOpacity: 0.8, children: (0, jsx_runtime_1.jsx)(Text, { style: [rnStyles.actionBtnText, { color: btn.color }], children: btn.label }) }, btn.id))) })] }), (metrics?.lastPushError || metrics?.lastPullError) && ((0, jsx_runtime_1.jsxs)(View, { style: [rnStyles.infoCard, { borderColor: '#EF444480', backgroundColor: '#7F1D1D20' }], children: [(0, jsx_runtime_1.jsx)(Text, { style: [rnStyles.infoCardTitle, { color: '#F87171' }], children: "SYNC ENGINE ERRORS" }), metrics?.lastPushError && ((0, jsx_runtime_1.jsxs)(View, { style: { marginBottom: 6 }, children: [(0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 11, color: '#FCA5A5', fontWeight: '700' }, children: "Last Push Error:" }), (0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 12, color: '#FECACA' }, children: String(metrics.lastPushError) })] })), metrics?.lastPullError && ((0, jsx_runtime_1.jsxs)(View, { children: [(0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 11, color: '#FCA5A5', fontWeight: '700' }, children: "Last Pull Error:" }), (0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 12, color: '#FECACA' }, children: String(metrics.lastPullError) })] }))] })), status.pendingRecords && status.pendingRecords.length > 0 && ((0, jsx_runtime_1.jsxs)(View, { style: [
|
|
185
192
|
rnStyles.infoCard,
|
|
186
193
|
{
|
|
187
194
|
backgroundColor: currentTheme.card,
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import type { Transporter, SendMailOptions, TransportOptions } from 'nodemailer';
|
|
2
|
+
import type { ActionHandlerContext, ActionRecord, EmailAttachment, EmailPayload } from '../actions/types.js';
|
|
3
|
+
export type EmailProviderType = 'nodemailer' | 'resend' | 'sendgrid' | 'postmark' | 'http' | 'dev' | 'preview' | 'custom';
|
|
4
|
+
export interface EmailHandlerOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Default sender address (e.g. '"Support" <support@example.com>')
|
|
7
|
+
* used when an enqueued email does not specify `from`.
|
|
8
|
+
*/
|
|
9
|
+
defaultFrom?: string;
|
|
10
|
+
/**
|
|
11
|
+
* Additional default options merged into every outgoing email.
|
|
12
|
+
*/
|
|
13
|
+
defaults?: Partial<SendMailOptions> & Record<string, any>;
|
|
14
|
+
/**
|
|
15
|
+
* Custom template renderer invoked when `template` or `templateData` is provided in EmailPayload.
|
|
16
|
+
*/
|
|
17
|
+
renderTemplate?: (template: any, data: Record<string, any> | undefined, payload: EmailPayload) => Promise<{
|
|
18
|
+
html?: string;
|
|
19
|
+
text?: string;
|
|
20
|
+
}> | {
|
|
21
|
+
html?: string;
|
|
22
|
+
text?: string;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Hook called before sending an email. Can inspect or modify outgoing options.
|
|
26
|
+
*/
|
|
27
|
+
beforeSend?: (mailOptions: any, payload: EmailPayload, record: ActionRecord<EmailPayload>) => Promise<any | void> | any | void;
|
|
28
|
+
/**
|
|
29
|
+
* Hook called after an email has been successfully dispatched.
|
|
30
|
+
*/
|
|
31
|
+
afterSend?: (result: any, payload: EmailPayload, record: ActionRecord<EmailPayload>) => Promise<void> | void;
|
|
32
|
+
}
|
|
33
|
+
export interface HttpEmailHandlerOptions extends EmailHandlerOptions {
|
|
34
|
+
provider?: 'resend' | 'sendgrid' | 'postmark' | 'http' | 'custom';
|
|
35
|
+
apiKey?: string;
|
|
36
|
+
endpoint?: string;
|
|
37
|
+
headers?: Record<string, string>;
|
|
38
|
+
fetch?: typeof fetch;
|
|
39
|
+
}
|
|
40
|
+
export interface EmailDeliveryConfig extends EmailHandlerOptions {
|
|
41
|
+
provider?: EmailProviderType;
|
|
42
|
+
/** Nodemailer transporter instance, connection URL, or transport options */
|
|
43
|
+
transport?: any;
|
|
44
|
+
/** API key for HTTP services (Resend, SendGrid, Postmark) */
|
|
45
|
+
apiKey?: string;
|
|
46
|
+
/** Target endpoint for generic HTTP or webhook dispatch */
|
|
47
|
+
endpoint?: string;
|
|
48
|
+
/** Custom HTTP request headers */
|
|
49
|
+
headers?: Record<string, string>;
|
|
50
|
+
/** Custom fetch implementation */
|
|
51
|
+
fetch?: typeof fetch;
|
|
52
|
+
/** Silent dev mode logging */
|
|
53
|
+
silentDev?: boolean;
|
|
54
|
+
}
|
|
55
|
+
export type NodemailerHandlerOptions = EmailHandlerOptions;
|
|
56
|
+
export type NodemailerTransportInput = Transporter | TransportOptions | string | any;
|
|
57
|
+
export interface EmailSendResult {
|
|
58
|
+
messageId: string;
|
|
59
|
+
response?: any;
|
|
60
|
+
accepted?: Array<string | any>;
|
|
61
|
+
rejected?: Array<string | any>;
|
|
62
|
+
[key: string]: any;
|
|
63
|
+
}
|
|
64
|
+
export type NodemailerSendResult = EmailSendResult;
|
|
65
|
+
export type ConcreteEmailHandler = (payload: EmailPayload, record: ActionRecord<EmailPayload>, context: ActionHandlerContext) => Promise<EmailSendResult>;
|
|
66
|
+
export interface DevSentEmail {
|
|
67
|
+
id: string;
|
|
68
|
+
sentAt: number;
|
|
69
|
+
mailOptions: SendMailOptions;
|
|
70
|
+
payload: EmailPayload;
|
|
71
|
+
record: ActionRecord<EmailPayload>;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* In-memory Dev Mailbox for inspecting locally dispatched emails during development.
|
|
75
|
+
*/
|
|
76
|
+
export declare class DevMailbox {
|
|
77
|
+
private static inbox;
|
|
78
|
+
static getInbox(): DevSentEmail[];
|
|
79
|
+
static getLatest(): DevSentEmail | undefined;
|
|
80
|
+
static clear(): void;
|
|
81
|
+
static record(email: DevSentEmail): void;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Dynamically loads the nodemailer module if not already available.
|
|
85
|
+
*/
|
|
86
|
+
export declare function loadNodemailer(): Promise<any>;
|
|
87
|
+
/**
|
|
88
|
+
* Resolves or instantiates a Nodemailer Transporter instance.
|
|
89
|
+
*/
|
|
90
|
+
export declare function resolveTransporter(input: NodemailerTransportInput, defaults?: Partial<SendMailOptions>): Promise<Transporter>;
|
|
91
|
+
/**
|
|
92
|
+
* Renders a React element or JSX component into clean HTML and plaintext fallback.
|
|
93
|
+
*/
|
|
94
|
+
export declare function renderReactEmail(element: any): Promise<{
|
|
95
|
+
html: string;
|
|
96
|
+
text: string;
|
|
97
|
+
}>;
|
|
98
|
+
/**
|
|
99
|
+
* Hydrates an attachment from a mobile file:// URI or local file path if possible.
|
|
100
|
+
*/
|
|
101
|
+
export declare function hydrateAttachment(att: EmailAttachment): Promise<any>;
|
|
102
|
+
/**
|
|
103
|
+
* Maps an offline Local-Lite EmailPayload to standard email options.
|
|
104
|
+
*/
|
|
105
|
+
export declare function buildMailOptions(payload: EmailPayload, options?: EmailHandlerOptions): SendMailOptions;
|
|
106
|
+
/**
|
|
107
|
+
* Creates an EmailHandler for local-lite ActionManager that sends emails
|
|
108
|
+
* directly via Nodemailer (SMTP, Sendmail, SES, etc.).
|
|
109
|
+
*/
|
|
110
|
+
export declare function createNodemailerHandler(transporterOrOptions: NodemailerTransportInput, handlerOptions?: NodemailerHandlerOptions): ConcreteEmailHandler;
|
|
111
|
+
/**
|
|
112
|
+
* Creates an EmailHandler for local-lite ActionManager that dispatches emails
|
|
113
|
+
* via HTTP APIs (e.g. Resend, SendGrid, Postmark, or custom webhooks/endpoints).
|
|
114
|
+
*/
|
|
115
|
+
export declare function createHttpEmailHandler(options: HttpEmailHandlerOptions): ConcreteEmailHandler;
|
|
116
|
+
/**
|
|
117
|
+
* Creates a local dev email handler that stores outgoing emails in DevMailbox
|
|
118
|
+
* and logs an interactive terminal preview without sending real network requests.
|
|
119
|
+
*/
|
|
120
|
+
export declare function createDevEmailHandler(options?: EmailHandlerOptions & {
|
|
121
|
+
silent?: boolean;
|
|
122
|
+
}): ConcreteEmailHandler;
|
|
123
|
+
/**
|
|
124
|
+
* Universal email handler factory that creates a dispatch handler
|
|
125
|
+
* supporting Nodemailer (SMTP, Sendmail), HTTP providers (Resend, SendGrid, Postmark),
|
|
126
|
+
* local dev mailbox, or custom webhooks.
|
|
127
|
+
*/
|
|
128
|
+
export declare function createEmailHandler(config: EmailDeliveryConfig): ConcreteEmailHandler;
|