@hitch42/applet 0.1.1-beta.11 → 0.1.1-beta.13

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.
@@ -1,5 +1,5 @@
1
1
  import { t as AnyWorkflowDefinition } from "../workflow-DurM6Fwx.js";
2
- import { d as listEmailTrackersInputSchema, i as createEmailPixelInputSchema, p as markEmailTrackerSentBodySchema, t as TelephonyMessageReceivedEvent } from "../telephony-protocol-D-nf3Gca.js";
2
+ import { I as markEmailTrackerSentBodySchema, k as listEmailTrackersInputSchema, m as createEmailPixelInputSchema, n as TelephonyMessageReceivedEvent, t as EmailMessageReceivedEvent } from "../email-protocol-DqJ6YCiC.js";
3
3
  import { z } from "zod";
4
4
  //#region src/server/entry.d.ts
5
5
  declare function createWorkerEntry(server: {
@@ -8,6 +8,9 @@ declare function createWorkerEntry(server: {
8
8
  telephony?: {
9
9
  onMessageReceived?: (event: TelephonyMessageReceivedEvent) => void | Promise<void>;
10
10
  };
11
+ email?: {
12
+ onMessageReceived?: (event: EmailMessageReceivedEvent) => void | Promise<void>;
13
+ };
11
14
  }, options: {
12
15
  code: string;
13
16
  }): {
@@ -1,4 +1,4 @@
1
- import { c as listEmailTrackersInputSchema, t as createEmailPixelInputSchema, u as markEmailTrackerSentBodySchema } from "../email-DBTVhNB_.js";
1
+ import { C as markEmailTrackerSentBodySchema, g as listEmailTrackersInputSchema, t as createEmailPixelInputSchema } from "../email-WA4jnzZ0.js";
2
2
  import { a as HITCH_ORG_CODE_HEADER, c as HITCH_SCHEDULE_HEADER, d as HITCH_USER_HEADER, f as HITCH_WORKFLOW_HEADER, i as HITCH_ORGANIZATION_HEADER, l as HITCH_SCHEDULE_RUN_HEADER, m as HITCH_WORKFLOW_RUN_HEADER, n as HITCH_APPLET_HEADER, o as HITCH_RELEASE_HEADER, p as HITCH_WORKFLOW_INVOCATION_HEADER, r as HITCH_APPLET_TOKEN_HEADER, u as HITCH_SESSION_HEADER } from "../headers-DkNr9MLJ.js";
3
3
  import { a as getRequestContext, o as runWithRequestContext, r as toMilliseconds, t as MAX_DURATION_MS } from "../workflow-CTo2kZF1.js";
4
4
  import { a as errorNote, c as requestIdFrom, i as createNoteLog, r as cloudflareRequestFields, s as publishNote, t as APP_CONTEXT_CHANNEL } from "../log-context-zu8U9Sjm.js";
@@ -14,6 +14,16 @@ const telephonyMessageReceivedEventSchema = z.object({
14
14
  occurredAt: z.iso.datetime()
15
15
  });
16
16
  //#endregion
17
+ //#region src/server/email-protocol.ts
18
+ const emailMessageReceivedEventSchema = z.object({
19
+ eventId: z.string(),
20
+ type: z.literal("message.received"),
21
+ messageId: z.string(),
22
+ mailboxId: z.string(),
23
+ threadId: z.string(),
24
+ occurredAt: z.iso.datetime()
25
+ });
26
+ //#endregion
17
27
  //#region src/server/workflow-run.ts
18
28
  const MAX_RESULT_SIZE = 1048576;
19
29
  function errorMessage(error) {
@@ -208,6 +218,21 @@ function createWorkerEntry(server, options) {
208
218
  return jsonError(500, error instanceof Error ? error.message : String(error));
209
219
  }
210
220
  }
221
+ if (pathname === "/api/__hitch/email/message-received" && request.method === "POST") {
222
+ log.set({ route: "/api/__hitch/email/message-received" });
223
+ if (identity.kind !== "applet") return jsonError(403, "applet_identity_required");
224
+ const parsed = await request.json().then((body) => emailMessageReceivedEventSchema.safeParse(body)).catch(() => void 0);
225
+ if (!parsed?.success) return jsonError(400, "malformed_request");
226
+ const onMessageReceived = server.email?.onMessageReceived;
227
+ if (!onMessageReceived) return jsonError(404, "no_email_handler");
228
+ try {
229
+ await onMessageReceived(parsed.data);
230
+ return Response.json({ ok: true });
231
+ } catch (error) {
232
+ publishNote(requestId, errorNote(error), APP_CONTEXT_CHANNEL);
233
+ return jsonError(500, error instanceof Error ? error.message : String(error));
234
+ }
235
+ }
211
236
  if (pathname.startsWith(WORKFLOW_PATH_PREFIX)) {
212
237
  log.set({ route: `${WORKFLOW_PATH_PREFIX}:code` });
213
238
  const parsed = await request.json().then((body) => workflowInvocationRequestSchema.safeParse(body)).catch(() => void 0);
package/dist/applet.js CHANGED
@@ -99,23 +99,23 @@ async function main() {
99
99
  const noLogFlags = values.run === void 0 && values.filter === void 0 && values.level === void 0 && values.limit === void 0 && values.live === void 0 && values.search === void 0 && values.since === void 0;
100
100
  const noModeFlags = values["client-only"] === void 0 && values["server-only"] === void 0;
101
101
  if (positionals.length === 1 && positionals[0] === "bootstrap" && noModeFlags && noGitFlags && noVariableFlags && noLogFlags) {
102
- await (await import("./init-6oGPM46R.js")).runBootstrap({ install: values["no-install"] !== true });
102
+ await (await import("./init-CD-xOYWV.js")).runBootstrap({ install: values["no-install"] !== true });
103
103
  return;
104
104
  }
105
105
  if (positionals.length === 1 && positionals[0] === "generate" && values["no-install"] === void 0 && noModeFlags && noGitFlags && noVariableFlags && noLogFlags) {
106
- await (await import("./generate-Dox-OYt6.js")).runGenerate();
106
+ await (await import("./generate-CtbF9Zxd.js")).runGenerate();
107
107
  return;
108
108
  }
109
109
  if (positionals.length === 1 && positionals[0] === "build" && values["no-install"] === void 0 && noModeFlags && noGitFlags && noVariableFlags && noLogFlags) {
110
- await (await import("./build-Bh_S5BUv.js")).runBuild();
110
+ await (await import("./build-CeRZYhM9.js")).runBuild();
111
111
  return;
112
112
  }
113
113
  if (positionals.length === 1 && positionals[0] === "deploy" && values["no-install"] === void 0 && noModeFlags && noGitFlags && noVariableFlags && noLogFlags) {
114
- await (await import("./deploy-wGYjwXrx.js")).runDeploy({});
114
+ await (await import("./deploy-CaGPhe2h.js")).runDeploy({});
115
115
  return;
116
116
  }
117
117
  if (positionals.length === 2 && positionals[0] === "init" && noModeFlags && noVariableFlags && noLogFlags) {
118
- await (await import("./init-6oGPM46R.js")).runInit(positionals[1], {
118
+ await (await import("./init-CD-xOYWV.js")).runInit(positionals[1], {
119
119
  commit: values["no-commit"] !== true,
120
120
  git: values["no-git"] !== true,
121
121
  install: values["no-install"] !== true
@@ -123,7 +123,7 @@ async function main() {
123
123
  return;
124
124
  }
125
125
  if (positionals.length === 2 && positionals[0] === "new" && noGitFlags && noVariableFlags && noLogFlags) {
126
- await (await import("./init-6oGPM46R.js")).runNew({
126
+ await (await import("./init-CD-xOYWV.js")).runNew({
127
127
  code: positionals[1],
128
128
  clientOnly: values["client-only"],
129
129
  install: values["no-install"] !== true,
@@ -132,7 +132,7 @@ async function main() {
132
132
  return;
133
133
  }
134
134
  if ((positionals.length === 1 || positionals.length === 2) && positionals[0] === "logs" && values["no-install"] === void 0 && noModeFlags && noGitFlags && noVariableFlags) {
135
- await (await import("./logs-DSjuEN0Q.js")).runLogs({
135
+ await (await import("./logs-BySh9fnH.js")).runLogs({
136
136
  code: positionals[1],
137
137
  filter: values.filter,
138
138
  run: values.run,
@@ -145,14 +145,14 @@ async function main() {
145
145
  return;
146
146
  }
147
147
  if (positionals.length === 3 && positionals[0] === "schedules" && positionals[1] === "run" && values["no-install"] === void 0 && noModeFlags && noGitFlags && noLogFlags && values.secret === void 0) {
148
- await (await import("./schedules-C8_Svr4h.js")).runSchedule({
148
+ await (await import("./schedules-B_p9U-vM.js")).runSchedule({
149
149
  code: positionals[2],
150
150
  yes: values.yes
151
151
  });
152
152
  return;
153
153
  }
154
154
  if ((positionals.length === 3 || positionals.length === 4) && positionals[0] === "variables" && positionals[1] === "set" && values["no-install"] === void 0 && noModeFlags && noGitFlags && noLogFlags) {
155
- await (await import("./variables-DT5RyHdH.js")).runVariablesSet({
155
+ await (await import("./variables-D9nEFyOK.js")).runVariablesSet({
156
156
  key: positionals[2],
157
157
  secret: values.secret,
158
158
  value: positionals[3],
@@ -161,11 +161,11 @@ async function main() {
161
161
  return;
162
162
  }
163
163
  if (positionals.length === 2 && positionals[0] === "variables" && positionals[1] === "list" && values["no-install"] === void 0 && noModeFlags && noGitFlags && noVariableFlags && noLogFlags) {
164
- await (await import("./variables-DT5RyHdH.js")).runVariablesList();
164
+ await (await import("./variables-D9nEFyOK.js")).runVariablesList();
165
165
  return;
166
166
  }
167
167
  if (positionals.length === 3 && positionals[0] === "variables" && positionals[1] === "delete" && values["no-install"] === void 0 && noModeFlags && noGitFlags && values.secret === void 0 && noLogFlags) {
168
- await (await import("./variables-DT5RyHdH.js")).runVariablesDelete({
168
+ await (await import("./variables-D9nEFyOK.js")).runVariablesDelete({
169
169
  key: positionals[2],
170
170
  yes: values.yes
171
171
  });
@@ -0,0 +1,2 @@
1
+ import { i as runBuild } from "./build-CwOM9C0W.js";
2
+ export { runBuild };
@@ -1,4 +1,4 @@
1
- import { i as prepareAppletProjects, r as prepareAppletProject } from "./project-BRZGd6xq.js";
1
+ import { i as prepareAppletProjects, r as prepareAppletProject } from "./project-z7x0omdw.js";
2
2
  import { rm } from "node:fs/promises";
3
3
  import { resolve } from "node:path";
4
4
  import { spawn } from "node:child_process";
package/dist/client.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { f as RegisteredContract, m as RegisteredRouter, p as RegisteredManifest } from "./manifest-C6_F4bL8.js";
2
- import { t as NarrowContract } from "./contract-CsUpTBe0.js";
1
+ import { f as RegisteredContract, m as RegisteredRouter, p as RegisteredManifest } from "./manifest-ARAy2HP7.js";
2
+ import { t as NarrowContract } from "./contract-CZdT22tB.js";
3
3
  import { t as WithBatchRecorder } from "./batch-Qa4B4-Yp.js";
4
4
  import { o as WithFilesUpload } from "./upload-DKZzz5kW.js";
5
5
  import { RouterClient } from "@orpc/server";
@@ -1,4 +1,4 @@
1
- import { n as AppletManifest } from "./manifest-C6_F4bL8.js";
1
+ import { n as AppletManifest } from "./manifest-ARAy2HP7.js";
2
2
  import { AnyContractRouter } from "@orpc/contract";
3
3
  //#region src/hitch/contract.d.ts
4
4
  type ManifestObjectFor<Manifest, Code> = Manifest extends {
@@ -1,6 +1,6 @@
1
1
  import { i as readWorkspaceConfig, n as fetchWithOrgAuth } from "./workspace-D0dnnlxL.js";
2
2
  import { a as loadGitHubActionsSources, n as githubActionsContext, r as hitchResponseError, t as fetchWithGitHubActions } from "./ci-BKw14X2h.js";
3
- import { n as buildPreparedApplet, r as prepareWorkspaceBuild, t as buildApplet } from "./build-CEfFoIZZ.js";
3
+ import { n as buildPreparedApplet, r as prepareWorkspaceBuild, t as buildApplet } from "./build-CwOM9C0W.js";
4
4
  import { createRequire } from "node:module";
5
5
  import { createHash } from "node:crypto";
6
6
  import { existsSync } from "node:fs";
@@ -0,0 +1,211 @@
1
+ import { oc } from "@orpc/contract";
2
+ import { z } from "zod";
3
+ //#region src/hitch/email.ts
4
+ const emailTagKeySchema = z.string().regex(/^[A-Za-z][A-Za-z0-9_]{0,63}$/);
5
+ const emailTagsSchema = z.record(emailTagKeySchema, z.string().min(1).max(200)).refine((tags) => Object.keys(tags).length <= 10);
6
+ const createEmailPixelInputSchema = z.object({ tags: emailTagsSchema.optional() }).strict();
7
+ const createEmailPixelOutputSchema = z.object({
8
+ id: z.uuid(),
9
+ url: z.url()
10
+ });
11
+ const getEmailTrackerInputSchema = z.object({ id: z.uuid() });
12
+ const markEmailTrackerSentInputSchema = z.object({
13
+ id: z.uuid(),
14
+ sentAt: z.iso.datetime({ offset: true }).optional()
15
+ }).strict();
16
+ const markEmailTrackerSentBodySchema = z.object({ sentAt: z.iso.datetime({ offset: true }).optional() }).strict();
17
+ const emailTrackerSchema = z.object({
18
+ id: z.uuid(),
19
+ url: z.url(),
20
+ tags: emailTagsSchema,
21
+ createdAt: z.iso.datetime(),
22
+ sentAt: z.iso.datetime().nullable(),
23
+ firstHitAt: z.iso.datetime().nullable(),
24
+ lastHitAt: z.iso.datetime().nullable()
25
+ });
26
+ const listEmailTrackersInputSchema = z.object({
27
+ filter: emailTagsSchema.optional(),
28
+ sentAt: z.object({
29
+ $gte: z.iso.datetime({ offset: true }).optional(),
30
+ $lt: z.iso.datetime({ offset: true }).optional()
31
+ }).strict().optional(),
32
+ cursor: z.uuid().optional(),
33
+ limit: z.number().int().min(1).max(200).optional()
34
+ }).strict();
35
+ const listEmailTrackersOutputSchema = z.object({
36
+ trackers: z.array(emailTrackerSchema),
37
+ nextCursor: z.uuid().nullable()
38
+ });
39
+ function emailContract(appletCode) {
40
+ const path = `/v1/applets/${encodeURIComponent(appletCode)}/email/tracking`;
41
+ return {
42
+ mailboxes: { list: oc.route({
43
+ method: "GET",
44
+ path: "/v1/email/mailboxes"
45
+ }).input(z.void()).output(listHitchEmailMailboxesOutputSchema) },
46
+ threads: {
47
+ list: oc.route({
48
+ method: "GET",
49
+ path: "/v1/email/threads"
50
+ }).input(listHitchEmailThreadsInputSchema).output(listHitchEmailThreadsOutputSchema),
51
+ get: oc.route({
52
+ method: "GET",
53
+ path: "/v1/email/threads/{id}"
54
+ }).input(hitchEmailIdInputSchema).output(hitchEmailThreadSchema)
55
+ },
56
+ messages: {
57
+ list: oc.route({
58
+ method: "GET",
59
+ path: "/v1/email/messages"
60
+ }).input(listHitchEmailMessagesInputSchema).output(listHitchEmailMessagesOutputSchema),
61
+ get: oc.route({
62
+ method: "GET",
63
+ path: "/v1/email/messages/{id}"
64
+ }).input(hitchEmailIdInputSchema).output(hitchEmailMessageSchema),
65
+ send: oc.route({
66
+ method: "POST",
67
+ path: "/v1/email/messages",
68
+ successStatus: 201
69
+ }).input(sendHitchEmailInputSchema).output(hitchEmailMessageSchema),
70
+ raw: oc.route({
71
+ method: "GET",
72
+ path: "/v1/email/messages/{id}/raw"
73
+ }).input(hitchEmailIdInputSchema).output(getHitchEmailRawOutputSchema)
74
+ },
75
+ attachments: { get: oc.route({
76
+ method: "GET",
77
+ path: "/v1/email/attachments/{id}"
78
+ }).input(hitchEmailIdInputSchema).output(getHitchEmailAttachmentOutputSchema) },
79
+ tracking: {
80
+ createPixel: oc.route({
81
+ method: "POST",
82
+ path: `${path}/pixels`,
83
+ successStatus: 201
84
+ }).input(createEmailPixelInputSchema.optional()).output(createEmailPixelOutputSchema),
85
+ markSent: oc.route({
86
+ method: "POST",
87
+ path: `${path}/{id}/sent`
88
+ }).input(markEmailTrackerSentInputSchema).output(emailTrackerSchema),
89
+ get: oc.route({
90
+ method: "GET",
91
+ path: `${path}/{id}`
92
+ }).input(getEmailTrackerInputSchema).output(emailTrackerSchema),
93
+ list: oc.route({
94
+ method: "POST",
95
+ path: `${path}/list`
96
+ }).input(listEmailTrackersInputSchema.optional()).output(listEmailTrackersOutputSchema)
97
+ }
98
+ };
99
+ }
100
+ const hitchEmailAddressSchema = z.object({
101
+ address: z.string(),
102
+ name: z.string().nullable()
103
+ });
104
+ const hitchMailboxSchema = z.object({
105
+ id: z.uuid(),
106
+ address: z.string(),
107
+ label: z.string(),
108
+ enabled: z.boolean(),
109
+ receive: z.boolean(),
110
+ canRead: z.boolean(),
111
+ canSend: z.boolean()
112
+ });
113
+ const hitchEmailAttachmentSchema = z.object({
114
+ id: z.uuid(),
115
+ filename: z.string(),
116
+ contentType: z.string(),
117
+ sizeBytes: z.number(),
118
+ contentId: z.string().nullable(),
119
+ inline: z.boolean()
120
+ });
121
+ const hitchEmailMessageSchema = z.object({
122
+ id: z.uuid(),
123
+ mailboxId: z.uuid(),
124
+ threadId: z.uuid(),
125
+ direction: z.enum(["inbound", "outbound"]),
126
+ status: z.enum([
127
+ "received",
128
+ "unknown",
129
+ "sent",
130
+ "failed"
131
+ ]),
132
+ messageId: z.string().nullable(),
133
+ inReplyTo: z.string().nullable(),
134
+ references: z.array(z.string()),
135
+ from: hitchEmailAddressSchema,
136
+ to: z.array(hitchEmailAddressSchema),
137
+ cc: z.array(hitchEmailAddressSchema),
138
+ bcc: z.array(hitchEmailAddressSchema),
139
+ replyTo: z.array(hitchEmailAddressSchema),
140
+ subject: z.string(),
141
+ text: z.string().nullable(),
142
+ html: z.string().nullable(),
143
+ sentAt: z.string().nullable(),
144
+ automated: z.string().nullable(),
145
+ authentication: z.object({
146
+ spf: z.string().nullable(),
147
+ dkim: z.string().nullable(),
148
+ dmarc: z.string().nullable()
149
+ }).nullable(),
150
+ parseError: z.string().nullable(),
151
+ attachments: z.array(hitchEmailAttachmentSchema),
152
+ userId: z.uuid().nullable(),
153
+ appletId: z.uuid().nullable(),
154
+ requestId: z.string().nullable(),
155
+ errorDetail: z.string().nullable(),
156
+ createdAt: z.string()
157
+ });
158
+ const hitchEmailThreadSchema = z.object({
159
+ id: z.uuid(),
160
+ mailboxId: z.uuid(),
161
+ subject: z.string(),
162
+ messageCount: z.number(),
163
+ lastMessageAt: z.string(),
164
+ createdAt: z.string()
165
+ });
166
+ const listHitchEmailMailboxesOutputSchema = z.object({ data: z.array(hitchMailboxSchema) });
167
+ const listHitchEmailThreadsOutputSchema = z.object({
168
+ data: z.array(hitchEmailThreadSchema),
169
+ nextCursor: z.string().nullable()
170
+ });
171
+ const listHitchEmailMessagesOutputSchema = z.object({
172
+ data: z.array(hitchEmailMessageSchema),
173
+ nextCursor: z.string().nullable()
174
+ });
175
+ const getHitchEmailRawOutputSchema = z.object({ url: z.string() });
176
+ const getHitchEmailAttachmentOutputSchema = z.object({
177
+ url: z.string(),
178
+ filename: z.string(),
179
+ contentType: z.string(),
180
+ sizeBytes: z.number()
181
+ });
182
+ const hitchEmailIdInputSchema = z.object({ id: z.uuid() });
183
+ const listHitchEmailThreadsInputSchema = z.object({
184
+ mailboxId: z.uuid().optional(),
185
+ cursor: z.string().optional(),
186
+ limit: z.number().int().min(1).max(200).optional()
187
+ });
188
+ const listHitchEmailMessagesInputSchema = z.object({
189
+ mailboxId: z.uuid().optional(),
190
+ address: z.string().optional(),
191
+ threadId: z.uuid().optional(),
192
+ direction: z.enum(["inbound", "outbound"]).optional(),
193
+ since: z.iso.datetime().optional(),
194
+ until: z.iso.datetime().optional(),
195
+ cursor: z.string().optional(),
196
+ limit: z.number().int().min(1).max(50).optional()
197
+ });
198
+ const sendHitchEmailInputSchema = z.object({
199
+ mailboxId: z.uuid(),
200
+ to: z.array(z.string()).max(50).optional(),
201
+ cc: z.array(z.string()).max(50).optional(),
202
+ bcc: z.array(z.string()).max(50).optional(),
203
+ subject: z.string().max(998).optional(),
204
+ text: z.string().optional(),
205
+ html: z.string().optional(),
206
+ replyToMessageId: z.uuid().optional(),
207
+ attachmentFileIds: z.array(z.uuid()).max(32).optional(),
208
+ requestId: z.string().min(1).max(200).optional()
209
+ });
210
+ //#endregion
211
+ export { markEmailTrackerSentBodySchema as C, listHitchEmailThreadsOutputSchema as S, sendHitchEmailInputSchema as T, listEmailTrackersOutputSchema as _, emailTagsSchema as a, listHitchEmailMessagesOutputSchema as b, getHitchEmailAttachmentOutputSchema as c, hitchEmailAttachmentSchema as d, hitchEmailIdInputSchema as f, listEmailTrackersInputSchema as g, hitchMailboxSchema as h, emailTagKeySchema as i, getHitchEmailRawOutputSchema as l, hitchEmailThreadSchema as m, createEmailPixelOutputSchema as n, emailTrackerSchema as o, hitchEmailMessageSchema as p, emailContract as r, getEmailTrackerInputSchema as s, createEmailPixelInputSchema as t, hitchEmailAddressSchema as u, listHitchEmailMailboxesOutputSchema as v, markEmailTrackerSentInputSchema as w, listHitchEmailThreadsInputSchema as x, listHitchEmailMessagesInputSchema as y };
@@ -0,0 +1,230 @@
1
+ import { ContractProcedure, Meta } from "@orpc/contract";
2
+ import { z } from "zod";
3
+ //#region src/hitch/email.d.ts
4
+ type EmailTags = Record<string, string>;
5
+ type CreateEmailPixelInput = {
6
+ tags?: EmailTags;
7
+ };
8
+ type CreateEmailPixelOutput = {
9
+ id: string;
10
+ url: string;
11
+ };
12
+ type GetEmailTrackerInput = {
13
+ id: string;
14
+ };
15
+ type MarkEmailTrackerSentInput = {
16
+ id: string;
17
+ sentAt?: string;
18
+ };
19
+ type EmailTracker = {
20
+ id: string;
21
+ url: string;
22
+ tags: EmailTags;
23
+ createdAt: string;
24
+ sentAt: string | null;
25
+ firstHitAt: string | null;
26
+ lastHitAt: string | null;
27
+ };
28
+ type ListEmailTrackersInput = {
29
+ filter?: EmailTags;
30
+ sentAt?: {
31
+ $gte?: string;
32
+ $lt?: string;
33
+ };
34
+ cursor?: string;
35
+ limit?: number;
36
+ };
37
+ type ListEmailTrackersOutput = {
38
+ trackers: EmailTracker[];
39
+ nextCursor: string | null;
40
+ };
41
+ declare const emailTagKeySchema: z.ZodType<string, string>;
42
+ declare const emailTagsSchema: z.ZodType<EmailTags, EmailTags>;
43
+ declare const createEmailPixelInputSchema: z.ZodType<CreateEmailPixelInput, CreateEmailPixelInput>;
44
+ declare const createEmailPixelOutputSchema: z.ZodType<CreateEmailPixelOutput, CreateEmailPixelOutput>;
45
+ declare const getEmailTrackerInputSchema: z.ZodType<GetEmailTrackerInput, GetEmailTrackerInput>;
46
+ declare const markEmailTrackerSentInputSchema: z.ZodType<MarkEmailTrackerSentInput, MarkEmailTrackerSentInput>;
47
+ declare const markEmailTrackerSentBodySchema: z.ZodType<{
48
+ sentAt?: string;
49
+ }, {
50
+ sentAt?: string;
51
+ }>;
52
+ declare const emailTrackerSchema: z.ZodType<EmailTracker, EmailTracker>;
53
+ declare const listEmailTrackersInputSchema: z.ZodType<ListEmailTrackersInput, ListEmailTrackersInput>;
54
+ declare const listEmailTrackersOutputSchema: z.ZodType<ListEmailTrackersOutput, ListEmailTrackersOutput>;
55
+ type EmailContract = {
56
+ mailboxes: {
57
+ list: ContractProcedure<z.ZodType<void, void>, z.ZodType<HitchEmailMailboxesOutput, HitchEmailMailboxesOutput>, Record<never, never>, Meta>;
58
+ };
59
+ threads: {
60
+ list: ContractProcedure<z.ZodType<ListHitchEmailThreadsInput, ListHitchEmailThreadsInput>, z.ZodType<HitchEmailThreadsOutput, HitchEmailThreadsOutput>, Record<never, never>, Meta>;
61
+ get: ContractProcedure<z.ZodType<HitchEmailIdInput, HitchEmailIdInput>, z.ZodType<HitchEmailThread, HitchEmailThread>, Record<never, never>, Meta>;
62
+ };
63
+ messages: {
64
+ /** Newest first. Pass threadId to page through one thread. */
65
+ list: ContractProcedure<z.ZodType<ListHitchEmailMessagesInput, ListHitchEmailMessagesInput>, z.ZodType<HitchEmailMessagesOutput, HitchEmailMessagesOutput>, Record<never, never>, Meta>;
66
+ get: ContractProcedure<z.ZodType<HitchEmailIdInput, HitchEmailIdInput>, z.ZodType<HitchEmailMessage, HitchEmailMessage>, Record<never, never>, Meta>;
67
+ send: ContractProcedure<z.ZodType<SendHitchEmailInput, SendHitchEmailInput>, z.ZodType<HitchEmailMessage, HitchEmailMessage>, Record<never, never>, Meta>;
68
+ raw: ContractProcedure<z.ZodType<HitchEmailIdInput, HitchEmailIdInput>, z.ZodType<HitchEmailRawOutput, HitchEmailRawOutput>, Record<never, never>, Meta>;
69
+ };
70
+ attachments: {
71
+ get: ContractProcedure<z.ZodType<HitchEmailIdInput, HitchEmailIdInput>, z.ZodType<HitchEmailAttachmentOutput, HitchEmailAttachmentOutput>, Record<never, never>, Meta>;
72
+ };
73
+ tracking: {
74
+ createPixel: ContractProcedure<z.ZodType<CreateEmailPixelInput | undefined, CreateEmailPixelInput | undefined>, z.ZodType<CreateEmailPixelOutput, CreateEmailPixelOutput>, Record<never, never>, Meta>;
75
+ markSent: ContractProcedure<z.ZodType<MarkEmailTrackerSentInput, MarkEmailTrackerSentInput>, z.ZodType<EmailTracker, EmailTracker>, Record<never, never>, Meta>;
76
+ get: ContractProcedure<z.ZodType<GetEmailTrackerInput, GetEmailTrackerInput>, z.ZodType<EmailTracker, EmailTracker>, Record<never, never>, Meta>;
77
+ list: ContractProcedure<z.ZodType<ListEmailTrackersInput | undefined, ListEmailTrackersInput | undefined>, z.ZodType<ListEmailTrackersOutput, ListEmailTrackersOutput>, Record<never, never>, Meta>;
78
+ };
79
+ };
80
+ declare function emailContract(appletCode: string): EmailContract;
81
+ type HitchEmailAddress = {
82
+ address: string;
83
+ name: string | null;
84
+ };
85
+ type HitchMailbox = {
86
+ id: string;
87
+ address: string;
88
+ label: string;
89
+ enabled: boolean;
90
+ receive: boolean;
91
+ canRead: boolean;
92
+ canSend: boolean;
93
+ };
94
+ type HitchEmailAttachment = {
95
+ id: string;
96
+ filename: string;
97
+ contentType: string;
98
+ sizeBytes: number;
99
+ contentId: string | null;
100
+ inline: boolean;
101
+ };
102
+ type HitchEmailMessage = {
103
+ id: string;
104
+ mailboxId: string;
105
+ threadId: string;
106
+ direction: "inbound" | "outbound";
107
+ status: "received" | "unknown" | "sent" | "failed";
108
+ messageId: string | null;
109
+ inReplyTo: string | null;
110
+ references: string[];
111
+ from: HitchEmailAddress;
112
+ to: HitchEmailAddress[];
113
+ cc: HitchEmailAddress[];
114
+ bcc: HitchEmailAddress[];
115
+ replyTo: HitchEmailAddress[];
116
+ subject: string;
117
+ text: string | null;
118
+ html: string | null;
119
+ sentAt: string | null;
120
+ automated: string | null;
121
+ authentication: {
122
+ spf: string | null;
123
+ dkim: string | null;
124
+ dmarc: string | null;
125
+ } | null;
126
+ parseError: string | null;
127
+ attachments: HitchEmailAttachment[];
128
+ userId: string | null;
129
+ appletId: string | null;
130
+ requestId: string | null;
131
+ errorDetail: string | null;
132
+ createdAt: string;
133
+ };
134
+ type HitchEmailThread = {
135
+ id: string;
136
+ mailboxId: string;
137
+ subject: string;
138
+ messageCount: number;
139
+ lastMessageAt: string;
140
+ createdAt: string;
141
+ };
142
+ type ListHitchEmailThreadsInput = {
143
+ mailboxId?: string;
144
+ cursor?: string;
145
+ limit?: number;
146
+ };
147
+ type ListHitchEmailMessagesInput = {
148
+ mailboxId?: string;
149
+ address?: string;
150
+ threadId?: string;
151
+ direction?: "inbound" | "outbound";
152
+ since?: string;
153
+ until?: string;
154
+ cursor?: string;
155
+ limit?: number;
156
+ };
157
+ type SendHitchEmailInput = {
158
+ mailboxId: string;
159
+ to?: string[];
160
+ cc?: string[];
161
+ bcc?: string[];
162
+ subject?: string;
163
+ text?: string;
164
+ html?: string;
165
+ replyToMessageId?: string;
166
+ attachmentFileIds?: string[];
167
+ requestId?: string;
168
+ };
169
+ type HitchEmailIdInput = {
170
+ id: string;
171
+ };
172
+ type HitchEmailMailboxesOutput = {
173
+ data: HitchMailbox[];
174
+ };
175
+ type HitchEmailThreadsOutput = {
176
+ data: HitchEmailThread[];
177
+ nextCursor: string | null;
178
+ };
179
+ type HitchEmailMessagesOutput = {
180
+ data: HitchEmailMessage[];
181
+ nextCursor: string | null;
182
+ };
183
+ type HitchEmailRawOutput = {
184
+ url: string;
185
+ };
186
+ type HitchEmailAttachmentOutput = {
187
+ url: string;
188
+ filename: string;
189
+ contentType: string;
190
+ sizeBytes: number;
191
+ };
192
+ declare const hitchEmailAddressSchema: z.ZodType<HitchEmailAddress, HitchEmailAddress>;
193
+ declare const hitchMailboxSchema: z.ZodType<HitchMailbox, HitchMailbox>;
194
+ declare const hitchEmailAttachmentSchema: z.ZodType<HitchEmailAttachment, HitchEmailAttachment>;
195
+ declare const hitchEmailMessageSchema: z.ZodType<HitchEmailMessage, HitchEmailMessage>;
196
+ declare const hitchEmailThreadSchema: z.ZodType<HitchEmailThread, HitchEmailThread>;
197
+ declare const listHitchEmailMailboxesOutputSchema: z.ZodType<HitchEmailMailboxesOutput, HitchEmailMailboxesOutput>;
198
+ declare const listHitchEmailThreadsOutputSchema: z.ZodType<HitchEmailThreadsOutput, HitchEmailThreadsOutput>;
199
+ declare const listHitchEmailMessagesOutputSchema: z.ZodType<HitchEmailMessagesOutput, HitchEmailMessagesOutput>;
200
+ declare const getHitchEmailRawOutputSchema: z.ZodType<HitchEmailRawOutput, HitchEmailRawOutput>;
201
+ declare const getHitchEmailAttachmentOutputSchema: z.ZodType<HitchEmailAttachmentOutput, HitchEmailAttachmentOutput>;
202
+ declare const hitchEmailIdInputSchema: z.ZodType<HitchEmailIdInput, HitchEmailIdInput>;
203
+ declare const listHitchEmailThreadsInputSchema: z.ZodType<ListHitchEmailThreadsInput, ListHitchEmailThreadsInput>;
204
+ declare const listHitchEmailMessagesInputSchema: z.ZodType<ListHitchEmailMessagesInput, ListHitchEmailMessagesInput>;
205
+ declare const sendHitchEmailInputSchema: z.ZodType<SendHitchEmailInput, SendHitchEmailInput>;
206
+ //#endregion
207
+ //#region src/server/telephony-protocol.d.ts
208
+ /** Handle events at least once and without order. Use eventId for idempotency.
209
+ * Read the message with hitch.telephony.messages.get({ id: messageId }). */
210
+ type TelephonyMessageReceivedEvent = {
211
+ eventId: string;
212
+ type: "message.received";
213
+ messageId: string;
214
+ numberId: string;
215
+ occurredAt: string;
216
+ };
217
+ //#endregion
218
+ //#region src/server/email-protocol.d.ts
219
+ /** Handle events at least once and without order. Use eventId for idempotency.
220
+ * Read the message with hitch.email.messages.get({ id: messageId }). */
221
+ type EmailMessageReceivedEvent = {
222
+ eventId: string;
223
+ type: "message.received";
224
+ messageId: string;
225
+ mailboxId: string;
226
+ threadId: string;
227
+ occurredAt: string;
228
+ };
229
+ //#endregion
230
+ export { listEmailTrackersOutputSchema as A, hitchEmailAddressSchema as C, hitchEmailThreadSchema as D, hitchEmailMessageSchema as E, listHitchEmailThreadsOutputSchema as F, markEmailTrackerSentBodySchema as I, markEmailTrackerSentInputSchema as L, listHitchEmailMessagesInputSchema as M, listHitchEmailMessagesOutputSchema as N, hitchMailboxSchema as O, listHitchEmailThreadsInputSchema as P, sendHitchEmailInputSchema as R, getHitchEmailRawOutputSchema as S, hitchEmailIdInputSchema as T, emailTagKeySchema as _, HitchEmailAddress as a, getEmailTrackerInputSchema as b, HitchEmailThread as c, ListHitchEmailMessagesInput as d, ListHitchEmailThreadsInput as f, emailContract as g, createEmailPixelOutputSchema as h, EmailTracker as i, listHitchEmailMailboxesOutputSchema as j, listEmailTrackersInputSchema as k, HitchMailbox as l, createEmailPixelInputSchema as m, TelephonyMessageReceivedEvent as n, HitchEmailAttachment as o, SendHitchEmailInput as p, EmailContract as r, HitchEmailMessage as s, EmailMessageReceivedEvent as t, ListEmailTrackersOutput as u, emailTagsSchema as v, hitchEmailAttachmentSchema as w, getHitchEmailAttachmentOutputSchema as x, emailTrackerSchema as y };
@@ -1,7 +1,7 @@
1
1
  import { f as resolveInstanceUrl, l as organizationInstanceUrl, n as fetchWithOrgAuth } from "./workspace-D0dnnlxL.js";
2
2
  import { i as loadGitHubActionsBuildInputs, n as githubActionsContext } from "./ci-BKw14X2h.js";
3
- import { r as prepareAppletProject } from "./project-BRZGd6xq.js";
4
- import { t as loadAppletConfig } from "./load-config-xEdTXs0y.js";
3
+ import { r as prepareAppletProject } from "./project-z7x0omdw.js";
4
+ import { t as loadAppletConfig } from "./load-config-BeQZ2yOa.js";
5
5
  import { createRequire } from "node:module";
6
6
  import { existsSync } from "node:fs";
7
7
  import { access, mkdir, mkdtemp, readFile, readdir, rename, rm, writeFile } from "node:fs/promises";
@@ -310,7 +310,7 @@ ${Object.entries(catalog).map(([objectCode, attributeCodes]) => ` ${JSON.string
310
310
  };`;
311
311
  return `// Generated by @hitch42/applet — do not edit.
312
312
  import type manifest from "./manifest.gen.ts";
313
- ${options.hasServer ? "import type server from \"../src/server/main.ts\";\nimport type * as serverModule from \"../src/server/main.ts\";\n" : ""}${options.hasClient ? "import type { Route as indexRoute } from \"../src/client/routes/index.tsx\";\n" : ""}${options.hasServer ? "import type { AnyRouter } from \"@orpc/server\";\n" : ""}${options.hasClient ? "import type { AnyRoute } from \"@tanstack/react-router\";\n" : ""}${options.hasServer ? "import type { WorkflowDefinition } from \"@hitch42/applet/server\";\nimport type { TelephonyMessageReceivedEvent } from \"@hitch42/applet\";\n" : ""}
313
+ ${options.hasServer ? "import type server from \"../src/server/main.ts\";\nimport type * as serverModule from \"../src/server/main.ts\";\n" : ""}${options.hasClient ? "import type { Route as indexRoute } from \"../src/client/routes/index.tsx\";\n" : ""}${options.hasServer ? "import type { AnyRouter } from \"@orpc/server\";\n" : ""}${options.hasClient ? "import type { AnyRoute } from \"@tanstack/react-router\";\n" : ""}${options.hasServer ? "import type { WorkflowDefinition } from \"@hitch42/applet/server\";\nimport type { TelephonyMessageReceivedEvent, EmailMessageReceivedEvent } from \"@hitch42/applet\";\n" : ""}
314
314
  ${catalogType}
315
315
 
316
316
  type Expect<T extends true> = T;
@@ -324,6 +324,7 @@ type _SrcServerMainMustDefaultExportRouterAndValidWorkflows = Expect<
324
324
  router: AnyRouter;
325
325
  workflows?: Record<string, WorkflowDefinition<any, any>>;
326
326
  telephony?: { onMessageReceived?: (event: TelephonyMessageReceivedEvent) => void | Promise<void> };
327
+ email?: { onMessageReceived?: (event: EmailMessageReceivedEvent) => void | Promise<void> };
327
328
  }
328
329
  ? true
329
330
  : false
@@ -0,0 +1,2 @@
1
+ import { n as runGenerate } from "./generate-CORu1X2X.js";
2
+ export { runGenerate };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { _ as RegisteredWorkflows, a as AppletSourceDefinition, c as appletManifestSchema, d as RegisteredCatalog, f as RegisteredContract, g as RegisteredVariables, h as RegisteredVariableKeys, i as AppletPackages, l as appletSourceDefinitionSchema, m as RegisteredRouter, n as AppletManifest, o as RegisteredAppletSourceDefinition, p as RegisteredManifest, r as AppletManifestObject, s as appletDefinitionSchema, t as AppletDefinition, u as HitchRegister, v as registerHitchContract } from "./manifest-C6_F4bL8.js";
2
- import { n as pruneContract, t as NarrowContract } from "./contract-CsUpTBe0.js";
1
+ import { _ as RegisteredWorkflows, a as AppletSourceDefinition, c as appletManifestSchema, d as RegisteredCatalog, f as RegisteredContract, g as RegisteredVariables, h as RegisteredVariableKeys, i as AppletPackages, l as appletSourceDefinitionSchema, m as RegisteredRouter, n as AppletManifest, o as RegisteredAppletSourceDefinition, p as RegisteredManifest, r as AppletManifestObject, s as appletDefinitionSchema, t as AppletDefinition, u as HitchRegister, v as registerHitchContract } from "./manifest-ARAy2HP7.js";
2
+ import { n as pruneContract, t as NarrowContract } from "./contract-CZdT22tB.js";
3
3
  import { a as UploadedHitchFile, c as createFileOutputSchema, d as getFileOutputSchema, i as UploadProgress, l as fileSchema, n as FilesUpload, r as UploadFileOptions, s as uploadFile, t as FilesClient, u as filesContract } from "./upload-DKZzz5kW.js";
4
- import { a as createEmailPixelOutputSchema, c as emailTagsSchema, d as listEmailTrackersInputSchema, f as listEmailTrackersOutputSchema, i as createEmailPixelInputSchema, l as emailTrackerSchema, m as markEmailTrackerSentInputSchema, n as EmailTracker, o as emailContract, r as ListEmailTrackersOutput, s as emailTagKeySchema, t as TelephonyMessageReceivedEvent, u as getEmailTrackerInputSchema } from "./telephony-protocol-D-nf3Gca.js";
4
+ import { A as listEmailTrackersOutputSchema, C as hitchEmailAddressSchema, D as hitchEmailThreadSchema, E as hitchEmailMessageSchema, F as listHitchEmailThreadsOutputSchema, L as markEmailTrackerSentInputSchema, M as listHitchEmailMessagesInputSchema, N as listHitchEmailMessagesOutputSchema, O as hitchMailboxSchema, P as listHitchEmailThreadsInputSchema, R as sendHitchEmailInputSchema, S as getHitchEmailRawOutputSchema, T as hitchEmailIdInputSchema, _ as emailTagKeySchema, a as HitchEmailAddress, b as getEmailTrackerInputSchema, c as HitchEmailThread, d as ListHitchEmailMessagesInput, f as ListHitchEmailThreadsInput, g as emailContract, h as createEmailPixelOutputSchema, i as EmailTracker, j as listHitchEmailMailboxesOutputSchema, k as listEmailTrackersInputSchema, l as HitchMailbox, m as createEmailPixelInputSchema, n as TelephonyMessageReceivedEvent, o as HitchEmailAttachment, p as SendHitchEmailInput, r as EmailContract, s as HitchEmailMessage, t as EmailMessageReceivedEvent, u as ListEmailTrackersOutput, v as emailTagsSchema, w as hitchEmailAttachmentSchema, x as getHitchEmailAttachmentOutputSchema, y as emailTrackerSchema } from "./email-protocol-DqJ6YCiC.js";
5
5
  import { ContractProcedure, Meta } from "@orpc/contract";
6
6
  import { z } from "zod";
7
7
  //#region ../shared/auth/src/workspace.d.mts
@@ -183,4 +183,4 @@ type TeamsContract = {
183
183
  };
184
184
  declare const teamsContract: TeamsContract;
185
185
  //#endregion
186
- export { type AppletDefinition, type AppletManifest, type AppletManifestObject, type AppletPackages, type AppletSourceDefinition, type EmailTracker, type FilesClient, type FilesUpload, type HitchConfig, type HitchMe, type HitchMessage, type HitchPhoneNumber, type HitchRegister, type HitchTeam, type HitchTeamMember, type ListEmailTrackersOutput, type ListHitchMessagesInput, type NarrowContract, type RegisteredAppletSourceDefinition, type RegisteredCatalog, type RegisteredContract, type RegisteredManifest, type RegisteredRouter, type RegisteredVariableKeys, type RegisteredVariables, type RegisteredWorkflows, type SendHitchMessageInput, type TelephonyContract, type TelephonyMessageReceivedEvent, type UploadFileOptions, type UploadProgress, type UploadedHitchFile, appletDefinitionSchema, appletManifestSchema, appletSourceDefinitionSchema, createEmailPixelInputSchema, createEmailPixelOutputSchema, createFileOutputSchema, emailContract, emailTagKeySchema, emailTagsSchema, emailTrackerSchema, fileSchema, filesContract, getEmailTrackerInputSchema, getFileOutputSchema, hitchMessageSchema, hitchPhoneNumberSchema, listEmailTrackersInputSchema, listEmailTrackersOutputSchema, listHitchMessagesInputSchema, listHitchMessagesOutputSchema, listHitchNumbersOutputSchema, markEmailTrackerSentInputSchema, meContract, meSchema, pruneContract, registerHitchContract, sendHitchMessageInputSchema, teamMemberSchema, teamSchema, teamsContract, telephonyContract, uploadFile };
186
+ export { type AppletDefinition, type AppletManifest, type AppletManifestObject, type AppletPackages, type AppletSourceDefinition, type EmailContract, type EmailMessageReceivedEvent, type EmailTracker, type FilesClient, type FilesUpload, type HitchConfig, type HitchEmailAddress, type HitchEmailAttachment, type HitchEmailMessage, type HitchEmailThread, type HitchMailbox, type HitchMe, type HitchMessage, type HitchPhoneNumber, type HitchRegister, type HitchTeam, type HitchTeamMember, type ListEmailTrackersOutput, type ListHitchEmailMessagesInput, type ListHitchEmailThreadsInput, type ListHitchMessagesInput, type NarrowContract, type RegisteredAppletSourceDefinition, type RegisteredCatalog, type RegisteredContract, type RegisteredManifest, type RegisteredRouter, type RegisteredVariableKeys, type RegisteredVariables, type RegisteredWorkflows, type SendHitchEmailInput, type SendHitchMessageInput, type TelephonyContract, type TelephonyMessageReceivedEvent, type UploadFileOptions, type UploadProgress, type UploadedHitchFile, appletDefinitionSchema, appletManifestSchema, appletSourceDefinitionSchema, createEmailPixelInputSchema, createEmailPixelOutputSchema, createFileOutputSchema, emailContract, emailTagKeySchema, emailTagsSchema, emailTrackerSchema, fileSchema, filesContract, getEmailTrackerInputSchema, getFileOutputSchema, getHitchEmailAttachmentOutputSchema, getHitchEmailRawOutputSchema, hitchEmailAddressSchema, hitchEmailAttachmentSchema, hitchEmailIdInputSchema, hitchEmailMessageSchema, hitchEmailThreadSchema, hitchMailboxSchema, hitchMessageSchema, hitchPhoneNumberSchema, listEmailTrackersInputSchema, listEmailTrackersOutputSchema, listHitchEmailMailboxesOutputSchema, listHitchEmailMessagesInputSchema, listHitchEmailMessagesOutputSchema, listHitchEmailThreadsInputSchema, listHitchEmailThreadsOutputSchema, listHitchMessagesInputSchema, listHitchMessagesOutputSchema, listHitchNumbersOutputSchema, markEmailTrackerSentInputSchema, meContract, meSchema, pruneContract, registerHitchContract, sendHitchEmailInputSchema, sendHitchMessageInputSchema, teamMemberSchema, teamSchema, teamsContract, telephonyContract, uploadFile };
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { i as registerHitchContract, t as uploadFile } from "./upload-DRbVhuDm.js";
2
- import { a as emailTagsSchema, c as listEmailTrackersInputSchema, d as markEmailTrackerSentInputSchema, i as emailTagKeySchema, l as listEmailTrackersOutputSchema, n as createEmailPixelOutputSchema, o as emailTrackerSchema, r as emailContract, s as getEmailTrackerInputSchema, t as createEmailPixelInputSchema } from "./email-DBTVhNB_.js";
2
+ import { S as listHitchEmailThreadsOutputSchema, T as sendHitchEmailInputSchema, _ as listEmailTrackersOutputSchema, a as emailTagsSchema, b as listHitchEmailMessagesOutputSchema, c as getHitchEmailAttachmentOutputSchema, d as hitchEmailAttachmentSchema, f as hitchEmailIdInputSchema, g as listEmailTrackersInputSchema, h as hitchMailboxSchema, i as emailTagKeySchema, l as getHitchEmailRawOutputSchema, m as hitchEmailThreadSchema, n as createEmailPixelOutputSchema, o as emailTrackerSchema, p as hitchEmailMessageSchema, r as emailContract, s as getEmailTrackerInputSchema, t as createEmailPixelInputSchema, u as hitchEmailAddressSchema, v as listHitchEmailMailboxesOutputSchema, w as markEmailTrackerSentInputSchema, x as listHitchEmailThreadsInputSchema, y as listHitchEmailMessagesInputSchema } from "./email-WA4jnzZ0.js";
3
3
  import { n as meSchema, t as meContract } from "./me-BW7Paary.js";
4
- import { n as appletManifestSchema, r as appletSourceDefinitionSchema, t as appletDefinitionSchema } from "./manifest-CJSL9GuC.js";
4
+ import { n as appletManifestSchema, r as appletSourceDefinitionSchema, t as appletDefinitionSchema } from "./manifest-CuY3ICpN.js";
5
5
  import { oc } from "@orpc/contract";
6
6
  import { z } from "zod";
7
7
  //#region src/hitch/contract.ts
@@ -249,4 +249,4 @@ const teamsContract = {
249
249
  }).input(teamIdInputSchema).output(teamMembersOutputSchema) }
250
250
  };
251
251
  //#endregion
252
- export { appletDefinitionSchema, appletManifestSchema, appletSourceDefinitionSchema, createEmailPixelInputSchema, createEmailPixelOutputSchema, createFileOutputSchema, emailContract, emailTagKeySchema, emailTagsSchema, emailTrackerSchema, fileSchema, filesContract, getEmailTrackerInputSchema, getFileOutputSchema, hitchMessageSchema, hitchPhoneNumberSchema, listEmailTrackersInputSchema, listEmailTrackersOutputSchema, listHitchMessagesInputSchema, listHitchMessagesOutputSchema, listHitchNumbersOutputSchema, markEmailTrackerSentInputSchema, meContract, meSchema, pruneContract, registerHitchContract, sendHitchMessageInputSchema, teamMemberSchema, teamSchema, teamsContract, telephonyContract, uploadFile };
252
+ export { appletDefinitionSchema, appletManifestSchema, appletSourceDefinitionSchema, createEmailPixelInputSchema, createEmailPixelOutputSchema, createFileOutputSchema, emailContract, emailTagKeySchema, emailTagsSchema, emailTrackerSchema, fileSchema, filesContract, getEmailTrackerInputSchema, getFileOutputSchema, getHitchEmailAttachmentOutputSchema, getHitchEmailRawOutputSchema, hitchEmailAddressSchema, hitchEmailAttachmentSchema, hitchEmailIdInputSchema, hitchEmailMessageSchema, hitchEmailThreadSchema, hitchMailboxSchema, hitchMessageSchema, hitchPhoneNumberSchema, listEmailTrackersInputSchema, listEmailTrackersOutputSchema, listHitchEmailMailboxesOutputSchema, listHitchEmailMessagesInputSchema, listHitchEmailMessagesOutputSchema, listHitchEmailThreadsInputSchema, listHitchEmailThreadsOutputSchema, listHitchMessagesInputSchema, listHitchMessagesOutputSchema, listHitchNumbersOutputSchema, markEmailTrackerSentInputSchema, meContract, meSchema, pruneContract, registerHitchContract, sendHitchEmailInputSchema, sendHitchMessageInputSchema, teamMemberSchema, teamSchema, teamsContract, telephonyContract, uploadFile };
@@ -1,8 +1,8 @@
1
- import { a as ORG_CODE_PATTERN, i as APPLET_CODE_PATTERN } from "./manifest-CJSL9GuC.js";
1
+ import { a as ORG_CODE_PATTERN, i as APPLET_CODE_PATTERN } from "./manifest-CuY3ICpN.js";
2
2
  import { d as resolveAuthForOrg, f as resolveInstanceUrl, i as readWorkspaceConfig } from "./workspace-D0dnnlxL.js";
3
- import { n as runGenerate } from "./generate-BEIYs17x.js";
4
- import { a as writeAppletSupport, n as loadCliManifest, o as writeWorkspaceSupport, t as assertWorkspaceCli } from "./project-BRZGd6xq.js";
5
- import { n as loadAppletSourceDefinition } from "./load-config-xEdTXs0y.js";
3
+ import { n as runGenerate } from "./generate-CORu1X2X.js";
4
+ import { a as writeAppletSupport, n as loadCliManifest, o as writeWorkspaceSupport, t as assertWorkspaceCli } from "./project-z7x0omdw.js";
5
+ import { n as loadAppletSourceDefinition } from "./load-config-BeQZ2yOa.js";
6
6
  import { access, cp, mkdir, readdir, writeFile } from "node:fs/promises";
7
7
  import { relative, resolve } from "node:path";
8
8
  import { spawn } from "node:child_process";
@@ -1,4 +1,4 @@
1
- import { r as appletSourceDefinitionSchema } from "./manifest-CJSL9GuC.js";
1
+ import { r as appletSourceDefinitionSchema } from "./manifest-CuY3ICpN.js";
2
2
  import { t as resolveWorkspaceOrg } from "./workspace-D0dnnlxL.js";
3
3
  import { existsSync } from "node:fs";
4
4
  import { resolve } from "node:path";
@@ -1,6 +1,6 @@
1
- import { i as APPLET_CODE_PATTERN } from "./manifest-CJSL9GuC.js";
1
+ import { i as APPLET_CODE_PATTERN } from "./manifest-CuY3ICpN.js";
2
2
  import { i as readWorkspaceConfig, n as fetchWithOrgAuth, t as resolveWorkspaceOrg } from "./workspace-D0dnnlxL.js";
3
- import { t as loadAppletConfig } from "./load-config-xEdTXs0y.js";
3
+ import { t as loadAppletConfig } from "./load-config-BeQZ2yOa.js";
4
4
  import { z } from "zod";
5
5
  //#region src/logs.ts
6
6
  const LOG_LEVELS = [
@@ -39,6 +39,9 @@ interface AppletManifest {
39
39
  send?: boolean;
40
40
  events?: readonly "message.received"[];
41
41
  };
42
+ email?: {
43
+ events: readonly "message.received"[];
44
+ };
42
45
  schedules?: readonly {
43
46
  code: string;
44
47
  name: string;
@@ -78,6 +78,7 @@ const appletManifestShape = {
78
78
  send: z.boolean().optional(),
79
79
  events: z.array(z.literal("message.received")).min(1).refine((events) => new Set(events).size === events.length).readonly().optional()
80
80
  }).refine((telephony) => telephony.events === void 0 || telephony.read === true, "telephony.events needs telephony.read").optional(),
81
+ email: z.strictObject({ events: z.array(z.literal("message.received")).min(1).refine((events) => new Set(events).size === events.length).readonly() }).optional(),
81
82
  schedules: appletManifestSchedulesSchema.optional(),
82
83
  variables: appletManifestVariablesSchema.optional(),
83
84
  objects: appletManifestObjectsSchema
@@ -111,6 +112,7 @@ const appletDefinitionSchema = z.strictObject({
111
112
  code: appletManifestShape.code,
112
113
  requiresChangeset: appletManifestShape.requiresChangeset,
113
114
  telephony: appletManifestShape.telephony,
115
+ email: appletManifestShape.email,
114
116
  schedules: appletManifestShape.schedules,
115
117
  variables: appletManifestShape.variables,
116
118
  objects: appletManifestShape.objects
@@ -183,6 +185,7 @@ const appletSourceDefinitionSchema = z.strictObject({
183
185
  code: appletManifestShape.code,
184
186
  requiresChangeset: appletManifestShape.requiresChangeset,
185
187
  telephony: appletManifestShape.telephony,
188
+ email: appletManifestShape.email,
186
189
  schedules: appletManifestShape.schedules,
187
190
  variables: appletManifestShape.variables,
188
191
  objects: appletManifestShape.objects,
@@ -1,5 +1,5 @@
1
1
  import { i as readWorkspaceConfig, l as organizationInstanceUrl, s as DEFAULT_INSTANCE_URL } from "./workspace-D0dnnlxL.js";
2
- import { n as loadAppletSourceDefinition } from "./load-config-xEdTXs0y.js";
2
+ import { n as loadAppletSourceDefinition } from "./load-config-BeQZ2yOa.js";
3
3
  import { z } from "zod";
4
4
  import { existsSync } from "node:fs";
5
5
  import { cp, mkdir, readFile, readdir, rm, symlink, writeFile } from "node:fs/promises";
@@ -1,4 +1,4 @@
1
- import { t as loadAppletConfig } from "./load-config-xEdTXs0y.js";
1
+ import { t as loadAppletConfig } from "./load-config-BeQZ2yOa.js";
2
2
  import { t as question } from "./prompt-ChS-grYO.js";
3
3
  import { RPCLink } from "@orpc/client/fetch";
4
4
  import { readFile } from "node:fs/promises";
package/dist/server.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { a as createWorkflow, i as WorkflowStep, n as WorkflowDefinition, r as WorkflowDuration } from "./workflow-DurM6Fwx.js";
2
- import { _ as RegisteredWorkflows, f as RegisteredContract, g as RegisteredVariables, p as RegisteredManifest } from "./manifest-C6_F4bL8.js";
3
- import { t as NarrowContract } from "./contract-CsUpTBe0.js";
2
+ import { _ as RegisteredWorkflows, f as RegisteredContract, g as RegisteredVariables, p as RegisteredManifest } from "./manifest-ARAy2HP7.js";
3
+ import { t as NarrowContract } from "./contract-CZdT22tB.js";
4
4
  import { t as WithBatchRecorder } from "./batch-Qa4B4-Yp.js";
5
5
  import { o as WithFilesUpload } from "./upload-DKZzz5kW.js";
6
6
  import { ContractRouterClient } from "@orpc/contract";
@@ -1,5 +1,5 @@
1
1
  import { n as fetchWithOrgAuth } from "./workspace-D0dnnlxL.js";
2
- import { t as loadAppletConfig } from "./load-config-xEdTXs0y.js";
2
+ import { t as loadAppletConfig } from "./load-config-BeQZ2yOa.js";
3
3
  import { t as question } from "./prompt-ChS-grYO.js";
4
4
  import { z } from "zod";
5
5
  //#region src/variables.ts
package/dist/vite.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { o as RegisteredAppletSourceDefinition } from "./manifest-C6_F4bL8.js";
1
+ import { o as RegisteredAppletSourceDefinition } from "./manifest-ARAy2HP7.js";
2
2
  import { PluginOption } from "vite";
3
3
  //#region src/vite.d.ts
4
4
  declare function applet<const M extends RegisteredAppletSourceDefinition>(sourceDefinition: M): PluginOption[];
package/dist/vite.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import { n as meSchema } from "./me-BW7Paary.js";
2
- import { i as APPLET_CODE_PATTERN, n as appletManifestSchema, r as appletSourceDefinitionSchema } from "./manifest-CJSL9GuC.js";
2
+ import { i as APPLET_CODE_PATTERN, n as appletManifestSchema, r as appletSourceDefinitionSchema } from "./manifest-CuY3ICpN.js";
3
3
  import { a as openQueryCacheDatabase } from "./query-cache-CXmAyLv3.js";
4
4
  import { d as HITCH_USER_HEADER, u as HITCH_SESSION_HEADER } from "./headers-DkNr9MLJ.js";
5
5
  import { a as workflowOutcomeSchema, n as runWorkflowJournal } from "./workflow-engine-BOTzURKM.js";
6
6
  import { c as bearerToken, d as resolveAuthForOrg, f as resolveInstanceUrl, l as organizationInstanceUrl, t as resolveWorkspaceOrg, u as rejectEnvironmentKey } from "./workspace-D0dnnlxL.js";
7
- import { c as writeClientEntry, i as writeRegisterDeclaration, l as writeManifestGen, r as syncContract, s as writeAppletRoot, u as writeServerEntry } from "./generate-BEIYs17x.js";
7
+ import { c as writeClientEntry, i as writeRegisterDeclaration, l as writeManifestGen, r as syncContract, s as writeAppletRoot, u as writeServerEntry } from "./generate-CORu1X2X.js";
8
8
  import { randomUUID } from "node:crypto";
9
9
  import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
10
10
  import { appendFile, readdir, rm, writeFile } from "node:fs/promises";
@@ -475,6 +475,7 @@ function applet(sourceDefinition) {
475
475
  const hasClient = existsSync(routesDirectory);
476
476
  const hasServer = existsSync(resolve(resolvedRoot, "src/server/main.ts"));
477
477
  if (!hasServer && parsedDefinition.data.telephony?.events?.length) throw new Error("An applet with telephony events must have src/server/main.ts.");
478
+ if (!hasServer && parsedDefinition.data.email?.events.length) throw new Error("An applet with email events must have src/server/main.ts.");
478
479
  if (!hasServer && (parsedDefinition.data.schedules?.length ?? 0) > 0) throw new Error("An applet with schedules must have src/server/main.ts.");
479
480
  const legacyMain = resolve(resolvedRoot, "src/client/main.tsx");
480
481
  const indexHtml = resolve(resolvedRoot, "index.html");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hitch42/applet",
3
- "version": "0.1.1-beta.11",
3
+ "version": "0.1.1-beta.13",
4
4
  "license": "MIT",
5
5
  "bin": {
6
6
  "applet": "./dist/applet.js"
@@ -1,2 +0,0 @@
1
- import { i as runBuild } from "./build-CEfFoIZZ.js";
2
- export { runBuild };
@@ -1,62 +0,0 @@
1
- import { oc } from "@orpc/contract";
2
- import { z } from "zod";
3
- //#region src/hitch/email.ts
4
- const emailTagKeySchema = z.string().regex(/^[A-Za-z][A-Za-z0-9_]{0,63}$/);
5
- const emailTagsSchema = z.record(emailTagKeySchema, z.string().min(1).max(200)).refine((tags) => Object.keys(tags).length <= 10);
6
- const createEmailPixelInputSchema = z.object({ tags: emailTagsSchema.optional() }).strict();
7
- const createEmailPixelOutputSchema = z.object({
8
- id: z.uuid(),
9
- url: z.url()
10
- });
11
- const getEmailTrackerInputSchema = z.object({ id: z.uuid() });
12
- const markEmailTrackerSentInputSchema = z.object({
13
- id: z.uuid(),
14
- sentAt: z.iso.datetime({ offset: true }).optional()
15
- }).strict();
16
- const markEmailTrackerSentBodySchema = z.object({ sentAt: z.iso.datetime({ offset: true }).optional() }).strict();
17
- const emailTrackerSchema = z.object({
18
- id: z.uuid(),
19
- url: z.url(),
20
- tags: emailTagsSchema,
21
- createdAt: z.iso.datetime(),
22
- sentAt: z.iso.datetime().nullable(),
23
- firstHitAt: z.iso.datetime().nullable(),
24
- lastHitAt: z.iso.datetime().nullable()
25
- });
26
- const listEmailTrackersInputSchema = z.object({
27
- filter: emailTagsSchema.optional(),
28
- sentAt: z.object({
29
- $gte: z.iso.datetime({ offset: true }).optional(),
30
- $lt: z.iso.datetime({ offset: true }).optional()
31
- }).strict().optional(),
32
- cursor: z.uuid().optional(),
33
- limit: z.number().int().min(1).max(200).optional()
34
- }).strict();
35
- const listEmailTrackersOutputSchema = z.object({
36
- trackers: z.array(emailTrackerSchema),
37
- nextCursor: z.uuid().nullable()
38
- });
39
- function emailContract(appletCode) {
40
- const path = `/v1/applets/${encodeURIComponent(appletCode)}/email/tracking`;
41
- return { tracking: {
42
- createPixel: oc.route({
43
- method: "POST",
44
- path: `${path}/pixels`,
45
- successStatus: 201
46
- }).input(createEmailPixelInputSchema.optional()).output(createEmailPixelOutputSchema),
47
- markSent: oc.route({
48
- method: "POST",
49
- path: `${path}/{id}/sent`
50
- }).input(markEmailTrackerSentInputSchema).output(emailTrackerSchema),
51
- get: oc.route({
52
- method: "GET",
53
- path: `${path}/{id}`
54
- }).input(getEmailTrackerInputSchema).output(emailTrackerSchema),
55
- list: oc.route({
56
- method: "POST",
57
- path: `${path}/list`
58
- }).input(listEmailTrackersInputSchema.optional()).output(listEmailTrackersOutputSchema)
59
- } };
60
- }
61
- //#endregion
62
- export { emailTagsSchema as a, listEmailTrackersInputSchema as c, markEmailTrackerSentInputSchema as d, emailTagKeySchema as i, listEmailTrackersOutputSchema as l, createEmailPixelOutputSchema as n, emailTrackerSchema as o, emailContract as r, getEmailTrackerInputSchema as s, createEmailPixelInputSchema as t, markEmailTrackerSentBodySchema as u };
@@ -1,2 +0,0 @@
1
- import { n as runGenerate } from "./generate-BEIYs17x.js";
2
- export { runGenerate };
@@ -1,76 +0,0 @@
1
- import { ContractProcedure, Meta } from "@orpc/contract";
2
- import { z } from "zod";
3
- //#region src/hitch/email.d.ts
4
- type EmailTags = Record<string, string>;
5
- type CreateEmailPixelInput = {
6
- tags?: EmailTags;
7
- };
8
- type CreateEmailPixelOutput = {
9
- id: string;
10
- url: string;
11
- };
12
- type GetEmailTrackerInput = {
13
- id: string;
14
- };
15
- type MarkEmailTrackerSentInput = {
16
- id: string;
17
- sentAt?: string;
18
- };
19
- type EmailTracker = {
20
- id: string;
21
- url: string;
22
- tags: EmailTags;
23
- createdAt: string;
24
- sentAt: string | null;
25
- firstHitAt: string | null;
26
- lastHitAt: string | null;
27
- };
28
- type ListEmailTrackersInput = {
29
- filter?: EmailTags;
30
- sentAt?: {
31
- $gte?: string;
32
- $lt?: string;
33
- };
34
- cursor?: string;
35
- limit?: number;
36
- };
37
- type ListEmailTrackersOutput = {
38
- trackers: EmailTracker[];
39
- nextCursor: string | null;
40
- };
41
- declare const emailTagKeySchema: z.ZodType<string, string>;
42
- declare const emailTagsSchema: z.ZodType<EmailTags, EmailTags>;
43
- declare const createEmailPixelInputSchema: z.ZodType<CreateEmailPixelInput, CreateEmailPixelInput>;
44
- declare const createEmailPixelOutputSchema: z.ZodType<CreateEmailPixelOutput, CreateEmailPixelOutput>;
45
- declare const getEmailTrackerInputSchema: z.ZodType<GetEmailTrackerInput, GetEmailTrackerInput>;
46
- declare const markEmailTrackerSentInputSchema: z.ZodType<MarkEmailTrackerSentInput, MarkEmailTrackerSentInput>;
47
- declare const markEmailTrackerSentBodySchema: z.ZodType<{
48
- sentAt?: string;
49
- }, {
50
- sentAt?: string;
51
- }>;
52
- declare const emailTrackerSchema: z.ZodType<EmailTracker, EmailTracker>;
53
- declare const listEmailTrackersInputSchema: z.ZodType<ListEmailTrackersInput, ListEmailTrackersInput>;
54
- declare const listEmailTrackersOutputSchema: z.ZodType<ListEmailTrackersOutput, ListEmailTrackersOutput>;
55
- type EmailContract = {
56
- tracking: {
57
- createPixel: ContractProcedure<z.ZodType<CreateEmailPixelInput | undefined, CreateEmailPixelInput | undefined>, z.ZodType<CreateEmailPixelOutput, CreateEmailPixelOutput>, Record<never, never>, Meta>;
58
- markSent: ContractProcedure<z.ZodType<MarkEmailTrackerSentInput, MarkEmailTrackerSentInput>, z.ZodType<EmailTracker, EmailTracker>, Record<never, never>, Meta>;
59
- get: ContractProcedure<z.ZodType<GetEmailTrackerInput, GetEmailTrackerInput>, z.ZodType<EmailTracker, EmailTracker>, Record<never, never>, Meta>;
60
- list: ContractProcedure<z.ZodType<ListEmailTrackersInput | undefined, ListEmailTrackersInput | undefined>, z.ZodType<ListEmailTrackersOutput, ListEmailTrackersOutput>, Record<never, never>, Meta>;
61
- };
62
- };
63
- declare function emailContract(appletCode: string): EmailContract;
64
- //#endregion
65
- //#region src/server/telephony-protocol.d.ts
66
- /** Handle events at least once and without order. Use eventId for idempotency.
67
- * Read the message with hitch.telephony.messages.get({ id: messageId }). */
68
- type TelephonyMessageReceivedEvent = {
69
- eventId: string;
70
- type: "message.received";
71
- messageId: string;
72
- numberId: string;
73
- occurredAt: string;
74
- };
75
- //#endregion
76
- export { createEmailPixelOutputSchema as a, emailTagsSchema as c, listEmailTrackersInputSchema as d, listEmailTrackersOutputSchema as f, createEmailPixelInputSchema as i, emailTrackerSchema as l, markEmailTrackerSentInputSchema as m, EmailTracker as n, emailContract as o, markEmailTrackerSentBodySchema as p, ListEmailTrackersOutput as r, emailTagKeySchema as s, TelephonyMessageReceivedEvent as t, getEmailTrackerInputSchema as u };