@hitch42/applet 0.1.1-beta.7 → 0.1.1-beta.8
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/dist/_internal/server.d.ts +14 -1
- package/dist/_internal/server.js +23 -74
- package/dist/applet.js +22 -11
- package/dist/build-CFCKKMn7.js +2 -0
- package/dist/{build-DauirTcY.js → build-DANx9Hgg.js} +1 -1
- package/dist/{ci-gPrwo6C0.js → ci-5qWl7lT3.js} +1 -1
- package/dist/client.d.ts +2 -2
- package/dist/{contract-DB9QQhD9.d.ts → contract-rP_eV9PK.d.ts} +1 -1
- package/dist/{deploy-CqrtNJ1x.js → deploy-MQWLG2EA.js} +3 -3
- package/dist/email-DBTVhNB_.js +62 -0
- package/dist/{generate-BIifT6PK.js → generate-BxYHdoAQ.js} +9 -8
- package/dist/generate-CQ07Hdpo.js +2 -0
- package/dist/index.d.ts +114 -3
- package/dist/index.js +141 -26
- package/dist/{init-Wu6XmyVc.js → init-jDEgYIXg.js} +5 -5
- package/dist/{load-config-BknBkdRs.js → load-config-BYSxDVAl.js} +2 -2
- package/dist/{login-iT9MRuaw.js → login-C7RKmmTe.js} +1 -1
- package/dist/{logs-B-qZGXSK.js → logs-DgjgAxj2.js} +3 -3
- package/dist/{manifest-Bd04cWhu.js → manifest-Bp87Uz0a.js} +3 -0
- package/dist/{manifest-C489nYUy.d.ts → manifest-DD_SGkS6.d.ts} +3 -0
- package/dist/me-BW7Paary.js +32 -0
- package/dist/{project-C_rtpjp8.js → project-CbYPtpPq.js} +6 -5
- package/dist/prompt-ChS-grYO.js +29 -0
- package/dist/schedules-dhU1yyFr.js +42 -0
- package/dist/server.d.ts +2 -2
- package/dist/telephony-protocol-DRgiYjqQ.d.ts +74 -0
- package/dist/telephony.d.ts +77 -0
- package/dist/telephony.js +607 -0
- package/dist/{variables-DcwMeIau.js → variables-Bwnr7oxf.js} +3 -28
- package/dist/vite.d.ts +1 -1
- package/dist/vite.js +457 -22
- package/dist/workflow-engine-MogejNfF.js +117 -0
- package/dist/{workspace-B6lenAS5.js → workspace-XVtM12ZC.js} +5 -2
- package/package.json +6 -1
- package/scaffold/.agents/skills/hitch-applets/SKILL.md +24 -18
- package/scaffold/.agents/skills/hitch-applets/references/email-tracking.md +49 -0
- package/scaffold/.agents/skills/hitch-applets/references/files.md +3 -3
- package/scaffold/.agents/skills/hitch-applets/references/manifest.md +4 -2
- package/scaffold/.agents/skills/hitch-applets/references/performance.md +1 -1
- package/scaffold/.agents/skills/hitch-applets/references/records.md +4 -3
- package/scaffold/.agents/skills/hitch-applets/references/schedules.md +7 -2
- package/scaffold/.agents/skills/hitch-applets/references/server.md +0 -3
- package/scaffold/.agents/skills/hitch-applets/references/workflows.md +11 -3
- package/scaffold/.agents/skills/hitch-cli/SKILL.md +20 -20
- package/scaffold/.agents/skills/hitch-data/SKILL.md +1 -1
- package/scaffold/.agents/skills/hitch-data/references/limits.md +10 -10
- package/scaffold/.agents/skills/hitch-theory/SKILL.md +150 -0
- package/dist/build-DhNDp7ji.js +0 -2
- package/dist/generate-DSk8ihsC.js +0 -2
|
@@ -1,9 +1,13 @@
|
|
|
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-DRgiYjqQ.js";
|
|
2
3
|
import { z } from "zod";
|
|
3
4
|
//#region src/server/entry.d.ts
|
|
4
5
|
declare function createWorkerEntry(server: {
|
|
5
6
|
router: object;
|
|
6
7
|
workflows?: Record<string, AnyWorkflowDefinition>;
|
|
8
|
+
telephony?: {
|
|
9
|
+
onMessageReceived?: (event: TelephonyMessageReceivedEvent) => void | Promise<void>;
|
|
10
|
+
};
|
|
7
11
|
}, options: {
|
|
8
12
|
code: string;
|
|
9
13
|
}): {
|
|
@@ -76,4 +80,13 @@ type ErrorOutcome = {
|
|
|
76
80
|
declare const workflowOutcomeSchema: z.ZodType<StepOutcome | SleepOutcome | StepErrorOutcome | DoneOutcome | ErrorOutcome>;
|
|
77
81
|
type WorkflowOutcome = z.infer<typeof workflowOutcomeSchema>;
|
|
78
82
|
//#endregion
|
|
79
|
-
|
|
83
|
+
//#region src/server/workflow-engine.d.ts
|
|
84
|
+
type Engine = {
|
|
85
|
+
invoke<T>(name: string, fn: () => Promise<T>): Promise<T>;
|
|
86
|
+
sleepUntil(name: string, until: Date): Promise<void>;
|
|
87
|
+
sleep(name: string, milliseconds: number): Promise<void>;
|
|
88
|
+
};
|
|
89
|
+
declare class WorkflowFailedError extends Error {}
|
|
90
|
+
declare function runWorkflowJournal(engine: Engine, invoke: (journal: JournalEntry[]) => Promise<WorkflowOutcome>): Promise<unknown>;
|
|
91
|
+
//#endregion
|
|
92
|
+
export { type Engine, type JournalEntry, WorkflowFailedError, type WorkflowInvocationRequest, type WorkflowOutcome, createEmailPixelInputSchema, createWorkerEntry, journalEntrySchema, listEmailTrackersInputSchema, markEmailTrackerSentBodySchema, runWorkflowJournal, workflowInvocationRequestSchema, workflowOutcomeSchema };
|
package/dist/_internal/server.js
CHANGED
|
@@ -1,80 +1,16 @@
|
|
|
1
|
+
import { c as listEmailTrackersInputSchema, t as createEmailPixelInputSchema, u as markEmailTrackerSentBodySchema } from "../email-DBTVhNB_.js";
|
|
2
|
+
import { a as workflowOutcomeSchema, c as HITCH_SESSION_HEADER, i as workflowInvocationRequestSchema, l as HITCH_USER_HEADER, n as runWorkflowJournal, o as HITCH_APPLET_HEADER, r as journalEntrySchema, s as HITCH_APPLET_TOKEN_HEADER, t as WorkflowFailedError } from "../workflow-engine-MogejNfF.js";
|
|
1
3
|
import { o as runWithRequestContext, r as toMilliseconds, t as MAX_DURATION_MS } from "../workflow-CTo2kZF1.js";
|
|
2
4
|
import { z } from "zod";
|
|
3
5
|
import { RPCHandler } from "@orpc/server/fetch";
|
|
4
|
-
//#region src/
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const journalEntrySchema = z.discriminatedUnion("kind", [
|
|
12
|
-
z.object({
|
|
13
|
-
kind: z.literal("step"),
|
|
14
|
-
id: z.string(),
|
|
15
|
-
name: z.string(),
|
|
16
|
-
result: z.unknown()
|
|
17
|
-
}),
|
|
18
|
-
z.object({
|
|
19
|
-
kind: z.literal("sleep"),
|
|
20
|
-
id: z.string(),
|
|
21
|
-
name: z.string(),
|
|
22
|
-
until: z.number()
|
|
23
|
-
}),
|
|
24
|
-
z.object({
|
|
25
|
-
kind: z.literal("attempt"),
|
|
26
|
-
id: z.string(),
|
|
27
|
-
name: z.string(),
|
|
28
|
-
error: z.string()
|
|
29
|
-
}),
|
|
30
|
-
z.object({
|
|
31
|
-
kind: z.literal("failed"),
|
|
32
|
-
id: z.string(),
|
|
33
|
-
name: z.string(),
|
|
34
|
-
error: z.string()
|
|
35
|
-
})
|
|
36
|
-
]);
|
|
37
|
-
const workflowInvocationRequestSchema = z.object({
|
|
38
|
-
payload: z.unknown(),
|
|
39
|
-
journal: z.array(journalEntrySchema)
|
|
6
|
+
//#region src/server/telephony-protocol.ts
|
|
7
|
+
const telephonyMessageReceivedEventSchema = z.object({
|
|
8
|
+
eventId: z.string(),
|
|
9
|
+
type: z.literal("message.received"),
|
|
10
|
+
messageId: z.string(),
|
|
11
|
+
numberId: z.string(),
|
|
12
|
+
occurredAt: z.iso.datetime()
|
|
40
13
|
});
|
|
41
|
-
const workflowOutcomeSchema = z.discriminatedUnion("kind", [
|
|
42
|
-
z.object({
|
|
43
|
-
kind: z.literal("step"),
|
|
44
|
-
id: z.string(),
|
|
45
|
-
name: z.string(),
|
|
46
|
-
result: z.unknown()
|
|
47
|
-
}),
|
|
48
|
-
z.object({
|
|
49
|
-
kind: z.literal("sleep"),
|
|
50
|
-
id: z.string(),
|
|
51
|
-
name: z.string(),
|
|
52
|
-
until: z.number()
|
|
53
|
-
}),
|
|
54
|
-
z.object({
|
|
55
|
-
kind: z.literal("step_error"),
|
|
56
|
-
id: z.string(),
|
|
57
|
-
name: z.string(),
|
|
58
|
-
message: z.string(),
|
|
59
|
-
retries: z.object({
|
|
60
|
-
limit: z.number(),
|
|
61
|
-
delayMs: z.number(),
|
|
62
|
-
backoff: z.enum([
|
|
63
|
-
"constant",
|
|
64
|
-
"linear",
|
|
65
|
-
"exponential"
|
|
66
|
-
])
|
|
67
|
-
})
|
|
68
|
-
}),
|
|
69
|
-
z.object({
|
|
70
|
-
kind: z.literal("done"),
|
|
71
|
-
result: z.unknown()
|
|
72
|
-
}),
|
|
73
|
-
z.object({
|
|
74
|
-
kind: z.literal("error"),
|
|
75
|
-
message: z.string()
|
|
76
|
-
})
|
|
77
|
-
]);
|
|
78
14
|
//#endregion
|
|
79
15
|
//#region src/server/workflow-run.ts
|
|
80
16
|
const MAX_RESULT_SIZE = 1048576;
|
|
@@ -209,6 +145,19 @@ function createWorkerEntry(server, options) {
|
|
|
209
145
|
}
|
|
210
146
|
}, async () => {
|
|
211
147
|
const pathname = new URL(request.url).pathname;
|
|
148
|
+
if (pathname === "/api/__hitch/telephony/message-received" && request.method === "POST") {
|
|
149
|
+
if (identity.kind !== "applet") return jsonError(403, "applet_identity_required");
|
|
150
|
+
const parsed = await request.json().then((body) => telephonyMessageReceivedEventSchema.safeParse(body)).catch(() => void 0);
|
|
151
|
+
if (!parsed?.success) return jsonError(400, "malformed_request");
|
|
152
|
+
const onMessageReceived = server.telephony?.onMessageReceived;
|
|
153
|
+
if (!onMessageReceived) return jsonError(404, "no_telephony_handler");
|
|
154
|
+
try {
|
|
155
|
+
await onMessageReceived(parsed.data);
|
|
156
|
+
return Response.json({ ok: true });
|
|
157
|
+
} catch (error) {
|
|
158
|
+
return jsonError(500, error instanceof Error ? error.message : String(error));
|
|
159
|
+
}
|
|
160
|
+
}
|
|
212
161
|
if (pathname.startsWith(WORKFLOW_PATH_PREFIX)) {
|
|
213
162
|
const parsed = await request.json().then((body) => workflowInvocationRequestSchema.safeParse(body)).catch(() => void 0);
|
|
214
163
|
if (parsed === void 0 || !parsed.success) return jsonError(400, "malformed_request");
|
|
@@ -229,4 +178,4 @@ function createWorkerEntry(server, options) {
|
|
|
229
178
|
} };
|
|
230
179
|
}
|
|
231
180
|
//#endregion
|
|
232
|
-
export { createWorkerEntry, journalEntrySchema, workflowInvocationRequestSchema, workflowOutcomeSchema };
|
|
181
|
+
export { WorkflowFailedError, createEmailPixelInputSchema, createWorkerEntry, journalEntrySchema, listEmailTrackersInputSchema, markEmailTrackerSentBodySchema, runWorkflowJournal, workflowInvocationRequestSchema, workflowOutcomeSchema };
|
package/dist/applet.js
CHANGED
|
@@ -14,6 +14,7 @@ const usage = `Usage:
|
|
|
14
14
|
applet variables set <KEY> [value] [--secret] [-y | --yes]
|
|
15
15
|
applet variables list
|
|
16
16
|
applet variables delete <KEY> [-y | --yes]
|
|
17
|
+
applet schedules run <code> [-y | --yes]
|
|
17
18
|
|
|
18
19
|
Login options:
|
|
19
20
|
--no-browser Print the sign-in URL without opening a browser.
|
|
@@ -55,6 +56,9 @@ Variables options:
|
|
|
55
56
|
--secret Store the value as a secret.
|
|
56
57
|
-y, --yes Skip the live applet confirmation.
|
|
57
58
|
|
|
59
|
+
Schedules options:
|
|
60
|
+
-y, --yes Skip the schedule confirmation.
|
|
61
|
+
|
|
58
62
|
Login: applet login selects the organization from hitch.config.ts and shares
|
|
59
63
|
credentials with hitch login.
|
|
60
64
|
CI: set HITCH_API_KEY (and HITCH_API_URL for a non-default instance).
|
|
@@ -86,7 +90,7 @@ async function main() {
|
|
|
86
90
|
strict: true
|
|
87
91
|
});
|
|
88
92
|
if (positionals.length === 1 && positionals[0] === "login" && Object.keys(values).every((key) => key === "no-browser")) {
|
|
89
|
-
await (await import("./login-
|
|
93
|
+
await (await import("./login-C7RKmmTe.js")).runLogin({ noBrowser: values["no-browser"] });
|
|
90
94
|
return;
|
|
91
95
|
}
|
|
92
96
|
if (values["no-browser"] !== void 0) throw new Error(usage);
|
|
@@ -95,23 +99,23 @@ async function main() {
|
|
|
95
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;
|
|
96
100
|
const noModeFlags = values["client-only"] === void 0 && values["server-only"] === void 0;
|
|
97
101
|
if (positionals.length === 1 && positionals[0] === "bootstrap" && noModeFlags && noGitFlags && noVariableFlags && noLogFlags) {
|
|
98
|
-
await (await import("./init-
|
|
102
|
+
await (await import("./init-jDEgYIXg.js")).runBootstrap({ install: values["no-install"] !== true });
|
|
99
103
|
return;
|
|
100
104
|
}
|
|
101
105
|
if (positionals.length === 1 && positionals[0] === "generate" && values["no-install"] === void 0 && noModeFlags && noGitFlags && noVariableFlags && noLogFlags) {
|
|
102
|
-
await (await import("./generate-
|
|
106
|
+
await (await import("./generate-CQ07Hdpo.js")).runGenerate({});
|
|
103
107
|
return;
|
|
104
108
|
}
|
|
105
109
|
if (positionals.length === 1 && positionals[0] === "build" && values["no-install"] === void 0 && noModeFlags && noGitFlags && noVariableFlags && noLogFlags) {
|
|
106
|
-
await (await import("./build-
|
|
110
|
+
await (await import("./build-CFCKKMn7.js")).runBuild();
|
|
107
111
|
return;
|
|
108
112
|
}
|
|
109
113
|
if (positionals.length === 1 && positionals[0] === "deploy" && values["no-install"] === void 0 && noModeFlags && noGitFlags && noVariableFlags && noLogFlags) {
|
|
110
|
-
await (await import("./deploy-
|
|
114
|
+
await (await import("./deploy-MQWLG2EA.js")).runDeploy({});
|
|
111
115
|
return;
|
|
112
116
|
}
|
|
113
117
|
if (positionals.length === 2 && positionals[0] === "init" && noModeFlags && noVariableFlags && noLogFlags) {
|
|
114
|
-
await (await import("./init-
|
|
118
|
+
await (await import("./init-jDEgYIXg.js")).runInit(positionals[1], {
|
|
115
119
|
commit: values["no-commit"] !== true,
|
|
116
120
|
git: values["no-git"] !== true,
|
|
117
121
|
install: values["no-install"] !== true
|
|
@@ -119,7 +123,7 @@ async function main() {
|
|
|
119
123
|
return;
|
|
120
124
|
}
|
|
121
125
|
if (positionals.length === 2 && positionals[0] === "new" && noGitFlags && noVariableFlags && noLogFlags) {
|
|
122
|
-
await (await import("./init-
|
|
126
|
+
await (await import("./init-jDEgYIXg.js")).runNew({
|
|
123
127
|
code: positionals[1],
|
|
124
128
|
clientOnly: values["client-only"],
|
|
125
129
|
install: values["no-install"] !== true,
|
|
@@ -128,7 +132,7 @@ async function main() {
|
|
|
128
132
|
return;
|
|
129
133
|
}
|
|
130
134
|
if ((positionals.length === 1 || positionals.length === 2) && positionals[0] === "logs" && values["no-install"] === void 0 && noModeFlags && noGitFlags && noVariableFlags) {
|
|
131
|
-
await (await import("./logs-
|
|
135
|
+
await (await import("./logs-DgjgAxj2.js")).runLogs({
|
|
132
136
|
code: positionals[1],
|
|
133
137
|
filter: values.filter,
|
|
134
138
|
run: values.run,
|
|
@@ -140,8 +144,15 @@ async function main() {
|
|
|
140
144
|
});
|
|
141
145
|
return;
|
|
142
146
|
}
|
|
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-dhU1yyFr.js")).runSchedule({
|
|
149
|
+
code: positionals[2],
|
|
150
|
+
yes: values.yes
|
|
151
|
+
});
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
143
154
|
if ((positionals.length === 3 || positionals.length === 4) && positionals[0] === "variables" && positionals[1] === "set" && values["no-install"] === void 0 && noModeFlags && noGitFlags && noLogFlags) {
|
|
144
|
-
await (await import("./variables-
|
|
155
|
+
await (await import("./variables-Bwnr7oxf.js")).runVariablesSet({
|
|
145
156
|
key: positionals[2],
|
|
146
157
|
secret: values.secret,
|
|
147
158
|
value: positionals[3],
|
|
@@ -150,11 +161,11 @@ async function main() {
|
|
|
150
161
|
return;
|
|
151
162
|
}
|
|
152
163
|
if (positionals.length === 2 && positionals[0] === "variables" && positionals[1] === "list" && values["no-install"] === void 0 && noModeFlags && noGitFlags && noVariableFlags && noLogFlags) {
|
|
153
|
-
await (await import("./variables-
|
|
164
|
+
await (await import("./variables-Bwnr7oxf.js")).runVariablesList({});
|
|
154
165
|
return;
|
|
155
166
|
}
|
|
156
167
|
if (positionals.length === 3 && positionals[0] === "variables" && positionals[1] === "delete" && values["no-install"] === void 0 && noModeFlags && noGitFlags && values.secret === void 0 && noLogFlags) {
|
|
157
|
-
await (await import("./variables-
|
|
168
|
+
await (await import("./variables-Bwnr7oxf.js")).runVariablesDelete({
|
|
158
169
|
key: positionals[2],
|
|
159
170
|
yes: values.yes
|
|
160
171
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as prepareAppletProjects, r as prepareAppletProject } from "./project-
|
|
1
|
+
import { i as prepareAppletProjects, r as prepareAppletProject } from "./project-CbYPtpPq.js";
|
|
2
2
|
import { rm } from "node:fs/promises";
|
|
3
3
|
import { resolve } from "node:path";
|
|
4
4
|
import { spawn } from "node:child_process";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { d as resolveInstanceUrl } from "./workspace-XVtM12ZC.js";
|
|
2
2
|
//#region src/ci.ts
|
|
3
3
|
function githubActionsContext(env = process.env) {
|
|
4
4
|
if (env.GITHUB_ACTIONS !== "true" || env.HITCH_API_KEY) return void 0;
|
package/dist/client.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { f as RegisteredContract, m as RegisteredRouter, p as RegisteredManifest } from "./manifest-
|
|
2
|
-
import { t as NarrowContract } from "./contract-
|
|
1
|
+
import { f as RegisteredContract, m as RegisteredRouter, p as RegisteredManifest } from "./manifest-DD_SGkS6.js";
|
|
2
|
+
import { t as NarrowContract } from "./contract-rP_eV9PK.js";
|
|
3
3
|
import { t as WithBatchRecorder } from "./batch-Qa4B4-Yp.js";
|
|
4
4
|
import { o as WithFilesUpload } from "./upload-YbRKEqR6.js";
|
|
5
5
|
import { RouterClient } from "@orpc/server";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as AppletManifest } from "./manifest-
|
|
1
|
+
import { n as AppletManifest } from "./manifest-DD_SGkS6.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
|
-
import { i as readWorkspaceConfig, n as fetchWithOrgAuth } from "./workspace-
|
|
2
|
-
import { a as loadGitHubActionsSources, n as githubActionsContext, r as hitchResponseError, t as fetchWithGitHubActions } from "./ci-
|
|
3
|
-
import { n as buildPreparedApplet, r as prepareWorkspaceBuild, t as buildApplet } from "./build-
|
|
1
|
+
import { i as readWorkspaceConfig, n as fetchWithOrgAuth } from "./workspace-XVtM12ZC.js";
|
|
2
|
+
import { a as loadGitHubActionsSources, n as githubActionsContext, r as hitchResponseError, t as fetchWithGitHubActions } from "./ci-5qWl7lT3.js";
|
|
3
|
+
import { n as buildPreparedApplet, r as prepareWorkspaceBuild, t as buildApplet } from "./build-DANx9Hgg.js";
|
|
4
4
|
import { createRequire } from "node:module";
|
|
5
5
|
import { existsSync } from "node:fs";
|
|
6
6
|
import { readFile, readdir } from "node:fs/promises";
|
|
@@ -0,0 +1,62 @@
|
|
|
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,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { i as loadGitHubActionsBuildInputs, n as githubActionsContext } from "./ci-
|
|
3
|
-
import { t as loadAppletConfig } from "./load-config-
|
|
4
|
-
import { r as prepareAppletProject } from "./project-
|
|
1
|
+
import { c as organizationInstanceUrl, d as resolveInstanceUrl, n as fetchWithOrgAuth } from "./workspace-XVtM12ZC.js";
|
|
2
|
+
import { i as loadGitHubActionsBuildInputs, n as githubActionsContext } from "./ci-5qWl7lT3.js";
|
|
3
|
+
import { t as loadAppletConfig } from "./load-config-BYSxDVAl.js";
|
|
4
|
+
import { r as prepareAppletProject } from "./project-CbYPtpPq.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";
|
|
@@ -274,7 +274,7 @@ ${Object.entries(catalog).map(([objectCode, attributeCodes]) => ` ${JSON.string
|
|
|
274
274
|
};`;
|
|
275
275
|
return `// Generated by @hitch42/applet — do not edit.
|
|
276
276
|
import type manifest from "./manifest.gen.ts";
|
|
277
|
-
${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\";\n" : ""}
|
|
277
|
+
${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" : ""}
|
|
278
278
|
${catalogType}
|
|
279
279
|
|
|
280
280
|
type Expect<T extends true> = T;
|
|
@@ -287,6 +287,7 @@ type _SrcServerMainMustDefaultExportRouterAndValidWorkflows = Expect<
|
|
|
287
287
|
typeof server extends {
|
|
288
288
|
router: AnyRouter;
|
|
289
289
|
workflows?: Record<string, WorkflowDefinition<any, any>>;
|
|
290
|
+
telephony?: { onMessageReceived?: (event: TelephonyMessageReceivedEvent) => void | Promise<void> };
|
|
290
291
|
}
|
|
291
292
|
? true
|
|
292
293
|
: false
|
|
@@ -420,16 +421,16 @@ async function writeContractFiles(outDir, manifest, spec) {
|
|
|
420
421
|
await writeManifestGen(outDir, manifest);
|
|
421
422
|
await writeRegisterDeclaration(outDir, catalog);
|
|
422
423
|
await writeFile(resolve(outDir, "index.ts"), `// Generated by applet generate — do not edit.
|
|
423
|
-
import { filesContract as files, meContract as me, pruneContract, registerHitchContract, teamsContract as teams } from "@hitch42/applet";
|
|
424
|
+
import { emailContract, filesContract as files, meContract as me, pruneContract, registerHitchContract, teamsContract as teams, telephonyContract as telephony } from "@hitch42/applet";
|
|
424
425
|
import manifest from "./manifest.gen.ts";
|
|
425
426
|
|
|
426
427
|
${Object.hasOwn(preparedSpec.paths, "/v1/batch") ? `import { contract as generated } from "./orpc.gen.ts";
|
|
427
428
|
|
|
428
429
|
const { batch, ...records } = generated;
|
|
429
430
|
|
|
430
|
-
export const contract = { records, batch, files, me, teams } as const;` : `import { contract as records } from "./orpc.gen.ts";
|
|
431
|
+
export const contract = { records, batch, email: emailContract(manifest.code), files, me, teams, telephony } as const;` : `import { contract as records } from "./orpc.gen.ts";
|
|
431
432
|
|
|
432
|
-
export const contract = { records, files, me, teams } as const;`}
|
|
433
|
+
export const contract = { records, email: emailContract(manifest.code), files, me, teams, telephony } as const;`}
|
|
433
434
|
registerHitchContract(pruneContract(contract, manifest));
|
|
434
435
|
|
|
435
436
|
declare module "@hitch42/applet" {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
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-
|
|
2
|
-
import { n as pruneContract, t as NarrowContract } from "./contract-
|
|
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-DD_SGkS6.js";
|
|
2
|
+
import { n as pruneContract, t as NarrowContract } from "./contract-rP_eV9PK.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-YbRKEqR6.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-DRgiYjqQ.js";
|
|
4
5
|
import { ContractProcedure, Meta } from "@orpc/contract";
|
|
5
6
|
import { z } from "zod";
|
|
6
7
|
//#region ../shared/auth/src/workspace.d.mts
|
|
7
8
|
interface HitchConfig {
|
|
8
9
|
sdk: string;
|
|
9
10
|
org: string;
|
|
11
|
+
githubWorkflow?: boolean;
|
|
10
12
|
}
|
|
11
13
|
//#endregion
|
|
12
14
|
//#region src/hitch/me.d.ts
|
|
@@ -39,6 +41,115 @@ type MeContract = {
|
|
|
39
41
|
};
|
|
40
42
|
declare const meContract: MeContract;
|
|
41
43
|
//#endregion
|
|
44
|
+
//#region src/hitch/telephony.d.ts
|
|
45
|
+
type HitchPhoneNumber = {
|
|
46
|
+
id: string;
|
|
47
|
+
e164: string;
|
|
48
|
+
label: string;
|
|
49
|
+
enabled: boolean;
|
|
50
|
+
canRead: boolean;
|
|
51
|
+
canSend: boolean;
|
|
52
|
+
canCall: boolean;
|
|
53
|
+
voiceEnabled: boolean;
|
|
54
|
+
};
|
|
55
|
+
type HitchCall = {
|
|
56
|
+
id: string;
|
|
57
|
+
numberId: string;
|
|
58
|
+
direction: "inbound" | "outbound";
|
|
59
|
+
status: "starting" | "ringing" | "active" | "ended" | "missed" | "failed";
|
|
60
|
+
from: string;
|
|
61
|
+
to: string;
|
|
62
|
+
userId: string | null;
|
|
63
|
+
answeredAt: string | null;
|
|
64
|
+
endedAt: string | null;
|
|
65
|
+
durationSeconds: number | null;
|
|
66
|
+
voicemailSeconds: number | null;
|
|
67
|
+
hangupCause: string | null;
|
|
68
|
+
record: boolean;
|
|
69
|
+
hasRecording: boolean;
|
|
70
|
+
transcriptStatus: "pending" | "done" | "failed" | null;
|
|
71
|
+
transcript: {
|
|
72
|
+
segments: {
|
|
73
|
+
side: "member" | "customer";
|
|
74
|
+
speaker: number;
|
|
75
|
+
start: number;
|
|
76
|
+
end: number;
|
|
77
|
+
text: string;
|
|
78
|
+
}[];
|
|
79
|
+
} | null;
|
|
80
|
+
createdAt: string;
|
|
81
|
+
};
|
|
82
|
+
type ListHitchCallsInput = ListHitchMessagesInput & {
|
|
83
|
+
status?: HitchCall["status"];
|
|
84
|
+
};
|
|
85
|
+
type HitchMessage = {
|
|
86
|
+
id: string;
|
|
87
|
+
numberId: string;
|
|
88
|
+
direction: "inbound" | "outbound";
|
|
89
|
+
status: "pending" | "unknown" | "accepted" | "sent" | "delivered" | "unconfirmed" | "failed" | "received";
|
|
90
|
+
from: string;
|
|
91
|
+
to: string;
|
|
92
|
+
body: string | null;
|
|
93
|
+
redacted: boolean;
|
|
94
|
+
userId: string | null;
|
|
95
|
+
appletId: string | null;
|
|
96
|
+
requestId: string | null;
|
|
97
|
+
errorCode: string | null;
|
|
98
|
+
errorDetail: string | null;
|
|
99
|
+
statusAt: string | null;
|
|
100
|
+
createdAt: string;
|
|
101
|
+
};
|
|
102
|
+
type ListHitchMessagesInput = {
|
|
103
|
+
numberId?: string;
|
|
104
|
+
userId?: string;
|
|
105
|
+
direction?: "inbound" | "outbound";
|
|
106
|
+
since?: string;
|
|
107
|
+
until?: string;
|
|
108
|
+
cursor?: string;
|
|
109
|
+
limit?: number;
|
|
110
|
+
};
|
|
111
|
+
type SendHitchMessageInput = {
|
|
112
|
+
numberId: string;
|
|
113
|
+
to: string;
|
|
114
|
+
body: string;
|
|
115
|
+
requestId?: string;
|
|
116
|
+
};
|
|
117
|
+
type MessageIdInput = {
|
|
118
|
+
id: string;
|
|
119
|
+
};
|
|
120
|
+
type NumbersOutput = {
|
|
121
|
+
data: HitchPhoneNumber[];
|
|
122
|
+
};
|
|
123
|
+
type MessagesOutput = {
|
|
124
|
+
data: HitchMessage[];
|
|
125
|
+
nextCursor: string | null;
|
|
126
|
+
};
|
|
127
|
+
type CallsOutput = {
|
|
128
|
+
data: HitchCall[];
|
|
129
|
+
nextCursor: string | null;
|
|
130
|
+
};
|
|
131
|
+
declare const hitchPhoneNumberSchema: z.ZodType<HitchPhoneNumber>;
|
|
132
|
+
declare const hitchMessageSchema: z.ZodType<HitchMessage>;
|
|
133
|
+
declare const listHitchNumbersOutputSchema: z.ZodType<NumbersOutput>;
|
|
134
|
+
declare const listHitchMessagesOutputSchema: z.ZodType<MessagesOutput>;
|
|
135
|
+
declare const listHitchMessagesInputSchema: z.ZodType<ListHitchMessagesInput>;
|
|
136
|
+
declare const sendHitchMessageInputSchema: z.ZodType<SendHitchMessageInput>;
|
|
137
|
+
type TelephonyContract = {
|
|
138
|
+
calls: {
|
|
139
|
+
get: ContractProcedure<z.ZodType<MessageIdInput>, z.ZodType<HitchCall>, Record<never, never>, Meta>;
|
|
140
|
+
list: ContractProcedure<z.ZodType<ListHitchCallsInput>, z.ZodType<CallsOutput>, Record<never, never>, Meta>;
|
|
141
|
+
};
|
|
142
|
+
numbers: {
|
|
143
|
+
list: ContractProcedure<z.ZodType<void>, z.ZodType<NumbersOutput>, Record<never, never>, Meta>;
|
|
144
|
+
};
|
|
145
|
+
messages: {
|
|
146
|
+
get: ContractProcedure<z.ZodType<MessageIdInput>, z.ZodType<HitchMessage>, Record<never, never>, Meta>;
|
|
147
|
+
list: ContractProcedure<z.ZodType<ListHitchMessagesInput>, z.ZodType<MessagesOutput>, Record<never, never>, Meta>;
|
|
148
|
+
send: ContractProcedure<z.ZodType<SendHitchMessageInput>, z.ZodType<HitchMessage>, Record<never, never>, Meta>;
|
|
149
|
+
};
|
|
150
|
+
};
|
|
151
|
+
declare const telephonyContract: TelephonyContract;
|
|
152
|
+
//#endregion
|
|
42
153
|
//#region src/hitch/teams.d.ts
|
|
43
154
|
type HitchTeam = {
|
|
44
155
|
id: string;
|
|
@@ -71,4 +182,4 @@ type TeamsContract = {
|
|
|
71
182
|
};
|
|
72
183
|
declare const teamsContract: TeamsContract;
|
|
73
184
|
//#endregion
|
|
74
|
-
export { type AppletDefinition, type AppletManifest, type AppletManifestObject, type AppletPackages, type AppletSourceDefinition, type FilesClient, type FilesUpload, type HitchConfig, type HitchMe, type HitchRegister, type HitchTeam, type HitchTeamMember, type NarrowContract, type RegisteredAppletSourceDefinition, type RegisteredCatalog, type RegisteredContract, type RegisteredManifest, type RegisteredRouter, type RegisteredVariableKeys, type RegisteredVariables, type RegisteredWorkflows, type UploadFileOptions, type UploadProgress, type UploadedHitchFile, appletDefinitionSchema, appletManifestSchema, appletSourceDefinitionSchema, createFileOutputSchema, fileSchema, filesContract, getFileOutputSchema, meContract, meSchema, pruneContract, registerHitchContract, teamMemberSchema, teamSchema, teamsContract, uploadFile };
|
|
185
|
+
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 };
|