@hitch42/applet 0.1.1-beta.14 → 0.1.1-beta.16
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 +10 -1
- package/dist/_internal/server.js +16 -2
- package/dist/applet.js +12 -12
- package/dist/auth-D3CrCtZq.js +21 -0
- package/dist/{build-CwOM9C0W.js → build-XHoa_sJL.js} +1 -1
- package/dist/build-ueR7XjZT.js +2 -0
- package/dist/{ci-BKw14X2h.js → ci-B5-mH-YW.js} +1 -1
- package/dist/client.d.ts +3 -3
- package/dist/contract-BbOj5EB7.js +23 -0
- package/dist/{contract-CZdT22tB.d.ts → contract-D9wEvxGI.d.ts} +1 -1
- package/dist/{deploy-CaGPhe2h.js → deploy-C5JDIn2Y.js} +4 -3
- package/dist/device-BgIfytaR.js +135 -0
- package/dist/email-protocol-B9u_dh2p.d.ts +202 -0
- package/dist/{generate-CORu1X2X.js → generate-BV_emZgy.js} +39 -13
- package/dist/generate-C9bWqdaB.js +2 -0
- package/dist/hitch-file-url-BPKj9zVG.js +25 -0
- package/dist/index.d.ts +15 -25
- package/dist/index.js +80 -192
- package/dist/{init-CD-xOYWV.js → init-BGQ_bP44.js} +5 -5
- package/dist/{manifest-CuY3ICpN.js → load-config-Dkr2VxZN.js} +37 -2
- package/dist/{login-CUx3TmFQ.js → login-CceGvlMi.js} +3 -1
- package/dist/{logs-BySh9fnH.js → logs-DOkT5ots.js} +3 -3
- package/dist/{manifest-ARAy2HP7.d.ts → manifest-BSUtHbu-.d.ts} +1 -4
- package/dist/markdown-CwlqzBtP.js +88 -0
- package/dist/markdown-DSHOQIOb.d.ts +14 -0
- package/dist/markdown-editor-BmEaBzd7.d.ts +27 -0
- package/dist/markdown-editor-C5mLHGqu.js +428 -0
- package/dist/{project-z7x0omdw.js → project-CCVqCCgU.js} +5 -4
- package/dist/react/markdown-editor.d.ts +2 -0
- package/dist/react/markdown-editor.js +2 -0
- package/dist/react/markdown.d.ts +2 -0
- package/dist/react/markdown.js +2 -0
- package/dist/react.d.ts +2 -37
- package/dist/react.js +2 -534
- package/dist/{schedules-B_p9U-vM.js → schedules-D6-3v-Az.js} +1 -1
- package/dist/server.d.ts +3 -3
- package/dist/store-B8N_8JIN.js +196 -0
- package/dist/{upload-DKZzz5kW.d.ts → upload-D_kkmne_.d.ts} +5 -9
- package/dist/{variables-D9nEFyOK.js → variables-BSFZnLxY.js} +2 -2
- package/dist/vite.d.ts +1 -1
- package/dist/vite.js +165 -35
- package/dist/workspace-8yqXsvce.js +31 -0
- package/fonts/inter/LICENSE.txt +92 -0
- package/fonts/inter/inter-cyrillic-ext.woff2 +0 -0
- package/fonts/inter/inter-cyrillic.woff2 +0 -0
- package/fonts/inter/inter-greek-ext.woff2 +0 -0
- package/fonts/inter/inter-greek.woff2 +0 -0
- package/fonts/inter/inter-latin-ext.woff2 +0 -0
- package/fonts/inter/inter-latin.woff2 +0 -0
- package/fonts/inter/inter-vietnamese.woff2 +0 -0
- package/fonts/inter.css +81 -0
- package/package.json +15 -1
- package/scaffold/.agents/skills/hitch-applets/references/markdown.md +20 -2
- package/scaffold/applet/src/client/styles/globals.css +6 -1
- package/dist/build-CeRZYhM9.js +0 -2
- package/dist/email-WA4jnzZ0.js +0 -211
- package/dist/email-protocol-DqJ6YCiC.d.ts +0 -230
- package/dist/generate-CtbF9Zxd.js +0 -2
- package/dist/load-config-BeQZ2yOa.js +0 -27
- package/dist/me-BW7Paary.js +0 -32
- package/dist/workspace-D0dnnlxL.js +0 -385
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { a as organizationInstanceUrl, c as resolveInstanceUrl } from "./store-B8N_8JIN.js";
|
|
2
|
+
import { t as fetchWithOrgAuth } from "./auth-D3CrCtZq.js";
|
|
3
|
+
import { t as loadAppletConfig } from "./load-config-Dkr2VxZN.js";
|
|
4
|
+
import { i as loadGitHubActionsBuildInputs, n as githubActionsContext } from "./ci-B5-mH-YW.js";
|
|
5
|
+
import { r as prepareAppletProject } from "./project-CCVqCCgU.js";
|
|
5
6
|
import { createRequire } from "node:module";
|
|
7
|
+
import { isContractProcedure, minifyContractRouter } from "@orpc/contract";
|
|
8
|
+
import { randomUUID } from "node:crypto";
|
|
6
9
|
import { existsSync } from "node:fs";
|
|
7
10
|
import { access, mkdir, mkdtemp, readFile, readdir, rename, rm, writeFile } from "node:fs/promises";
|
|
8
11
|
import { dirname, resolve } from "node:path";
|
|
12
|
+
import { pathToFileURL } from "node:url";
|
|
9
13
|
import { execFile } from "node:child_process";
|
|
10
14
|
import { promisify } from "node:util";
|
|
11
15
|
import { createClient } from "@hey-api/openapi-ts";
|
|
@@ -361,6 +365,26 @@ async function writeRegisterDeclaration(outDir, catalog) {
|
|
|
361
365
|
//#region src/typegen/generate.ts
|
|
362
366
|
const execFileAsync = promisify(execFile);
|
|
363
367
|
const require = createRequire(import.meta.url);
|
|
368
|
+
function routesModuleSource(routes) {
|
|
369
|
+
return `// Generated by applet generate — do not edit.\nexport const contract = ${JSON.stringify(routes, null, 2)} as const;\n`;
|
|
370
|
+
}
|
|
371
|
+
function stripRouteData(router) {
|
|
372
|
+
if (isContractProcedure(router)) {
|
|
373
|
+
const { errorMap, meta, route } = router["~orpc"];
|
|
374
|
+
const { method, path, inputStructure, outputStructure } = route;
|
|
375
|
+
return { "~orpc": {
|
|
376
|
+
errorMap,
|
|
377
|
+
meta,
|
|
378
|
+
route: {
|
|
379
|
+
method,
|
|
380
|
+
path,
|
|
381
|
+
inputStructure,
|
|
382
|
+
outputStructure
|
|
383
|
+
}
|
|
384
|
+
} };
|
|
385
|
+
}
|
|
386
|
+
return Object.fromEntries(Object.entries(router).map(([name, child]) => [name, stripRouteData(child)]));
|
|
387
|
+
}
|
|
364
388
|
async function generateRouteTree(root) {
|
|
365
389
|
await execFileAsync(process.execPath, [resolve(dirname(require.resolve("@tanstack/router-cli/package.json")), "bin/tsr.cjs"), "generate"], { cwd: root });
|
|
366
390
|
}
|
|
@@ -447,6 +471,8 @@ async function generateContract(spec, outDir) {
|
|
|
447
471
|
}
|
|
448
472
|
const orpcPath = resolve(outDir, "orpc.gen.ts");
|
|
449
473
|
if (!await fileExists(orpcPath)) await Promise.all([writeFile(orpcPath, "// Generated by applet generate — no operations in spec.\nexport const contract = {} as const;\n"), fileExists(resolve(outDir, "zod.gen.ts")).then((exists) => exists ? void 0 : writeFile(resolve(outDir, "zod.gen.ts"), "// Generated by applet generate — no schemas in spec.\nexport {};\n"))]);
|
|
474
|
+
const { contract } = await import(`${pathToFileURL(orpcPath).href}?${randomUUID()}`);
|
|
475
|
+
await writeFile(resolve(outDir, "routes.gen.ts"), routesModuleSource(stripRouteData(minifyContractRouter(contract))));
|
|
450
476
|
}
|
|
451
477
|
async function writeContractFiles(outDir, manifest, spec) {
|
|
452
478
|
guardManifestForSpec(spec, manifest);
|
|
@@ -455,22 +481,22 @@ async function writeContractFiles(outDir, manifest, spec) {
|
|
|
455
481
|
await generateContract(preparedSpec, outDir);
|
|
456
482
|
await writeManifestGen(outDir, manifest);
|
|
457
483
|
await writeRegisterDeclaration(outDir, catalog);
|
|
484
|
+
const hasBatch = Object.hasOwn(preparedSpec.paths, "/v1/batch");
|
|
458
485
|
await writeFile(resolve(outDir, "index.ts"), `// Generated by applet generate — do not edit.
|
|
459
486
|
import { emailContract, filesContract as files, meContract as me, pruneContract, registerHitchContract, teamsContract as teams, telephonyContract as telephony } from "@hitch42/applet";
|
|
460
487
|
import manifest from "./manifest.gen.ts";
|
|
488
|
+
// The runtime needs only the routes; the zod contract gives the types and stays out of the bundle.
|
|
489
|
+
import type { contract as generated } from "./orpc.gen.ts";
|
|
490
|
+
import { contract as routes } from "./routes.gen.ts";
|
|
461
491
|
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
const { batch, ...records } = generated;
|
|
465
|
-
|
|
466
|
-
export const contract = { records, batch, email: emailContract(manifest.code), files, me, teams, telephony } as const;` : `import { contract as records } from "./orpc.gen.ts";
|
|
492
|
+
const platform = { email: emailContract(manifest.code), files, me, teams, telephony } as const;
|
|
493
|
+
${hasBatch ? `const { batch, ...records } = routes;
|
|
467
494
|
|
|
468
|
-
|
|
469
|
-
registerHitchContract(pruneContract(contract, manifest));
|
|
495
|
+
registerHitchContract(pruneContract({ records, batch, ...platform }, manifest));` : "registerHitchContract(pruneContract({ records: routes, ...platform }, manifest));"}
|
|
470
496
|
|
|
471
497
|
declare module "@hitch42/applet" {
|
|
472
498
|
interface HitchRegister {
|
|
473
|
-
contract: typeof
|
|
499
|
+
contract: ${hasBatch ? "{ records: Omit<typeof generated, \"batch\">; batch: (typeof generated)[\"batch\"] }" : "{ records: typeof generated }"} & typeof platform;
|
|
474
500
|
}
|
|
475
501
|
}
|
|
476
502
|
|
|
@@ -536,4 +562,4 @@ async function runGenerate() {
|
|
|
536
562
|
}
|
|
537
563
|
}
|
|
538
564
|
//#endregion
|
|
539
|
-
export {
|
|
565
|
+
export { writeRegisterDeclaration as a, writeAppletRoot as c, writeServerEntry as d, syncContract as i, writeClientEntry as l, routesModuleSource as n, prepareRecordSpec as o, runGenerate as r, recordOperation as s, generateContract as t, writeManifestGen as u };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
//#region src/react/hitch-file-url.ts
|
|
2
|
+
const HITCH_FILE_PREFIX = "hitch-file://";
|
|
3
|
+
const DOWNLOAD_URL_TTL_MS = 3e6;
|
|
4
|
+
const downloadUrlCache = /* @__PURE__ */ new Map();
|
|
5
|
+
function cachedDownloadUrl(files, id) {
|
|
6
|
+
const cached = downloadUrlCache.get(id);
|
|
7
|
+
if (cached !== void 0 && cached.expiresAt > Date.now()) return cached.request;
|
|
8
|
+
const request = files.download(id).then((file) => file.downloadUrl);
|
|
9
|
+
downloadUrlCache.set(id, {
|
|
10
|
+
request,
|
|
11
|
+
expiresAt: Date.now() + DOWNLOAD_URL_TTL_MS
|
|
12
|
+
});
|
|
13
|
+
return request;
|
|
14
|
+
}
|
|
15
|
+
function seedDownloadUrl(id, url) {
|
|
16
|
+
downloadUrlCache.set(id, {
|
|
17
|
+
request: Promise.resolve(url),
|
|
18
|
+
expiresAt: Date.now() + DOWNLOAD_URL_TTL_MS
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
function invalidateDownloadUrl(id) {
|
|
22
|
+
downloadUrlCache.delete(id);
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
export { seedDownloadUrl as i, cachedDownloadUrl as n, invalidateDownloadUrl as r, HITCH_FILE_PREFIX as t };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as pruneContract, t as NarrowContract } from "./contract-
|
|
3
|
-
import { a as UploadedHitchFile, c as
|
|
4
|
-
import {
|
|
5
|
-
import { ContractProcedure, Meta } from "@orpc/contract";
|
|
6
|
-
import { z } from "zod";
|
|
1
|
+
import { a as AppletSourceDefinition, c as RegisteredCatalog, d as RegisteredRouter, f as RegisteredVariableKeys, h as registerHitchContract, i as AppletPackages, l as RegisteredContract, m as RegisteredWorkflows, n as AppletManifest, o as RegisteredAppletSourceDefinition, p as RegisteredVariables, r as AppletManifestObject, s as HitchRegister, t as AppletDefinition, u as RegisteredManifest } from "./manifest-BSUtHbu-.js";
|
|
2
|
+
import { n as pruneContract, t as NarrowContract } from "./contract-D9wEvxGI.js";
|
|
3
|
+
import { a as UploadedHitchFile, c as filesContract, i as UploadProgress, n as FilesUpload, r as UploadFileOptions, s as uploadFile, t as FilesClient } from "./upload-D_kkmne_.js";
|
|
4
|
+
import { a as EmailTracker, c as HitchEmailMessage, f as ListEmailTrackersOutput, g as emailContract, h as SendHitchEmailInput, i as EmailContract, l as HitchEmailThread, m as ListHitchEmailThreadsInput, n as TelephonyMessageReceivedEvent, o as HitchEmailAddress, p as ListHitchEmailMessagesInput, s as HitchEmailAttachment, t as EmailMessageReceivedEvent, u as HitchMailbox } from "./email-protocol-B9u_dh2p.js";
|
|
5
|
+
import { ContractProcedure, Meta, Schema } from "@orpc/contract";
|
|
7
6
|
//#region ../shared/auth/src/workspace.d.mts
|
|
8
7
|
interface HitchConfig {
|
|
9
8
|
sdk: string;
|
|
@@ -35,9 +34,8 @@ type HitchMe = {
|
|
|
35
34
|
} | null;
|
|
36
35
|
multiOrg: boolean;
|
|
37
36
|
};
|
|
38
|
-
declare const meSchema: z.ZodType<HitchMe, HitchMe>;
|
|
39
37
|
type MeContract = {
|
|
40
|
-
get: ContractProcedure<
|
|
38
|
+
get: ContractProcedure<Schema<void, void>, Schema<HitchMe, HitchMe>, Record<never, never>, Meta>;
|
|
41
39
|
};
|
|
42
40
|
declare const meContract: MeContract;
|
|
43
41
|
//#endregion
|
|
@@ -129,24 +127,18 @@ type CallsOutput = {
|
|
|
129
127
|
data: HitchCall[];
|
|
130
128
|
nextCursor: string | null;
|
|
131
129
|
};
|
|
132
|
-
declare const hitchPhoneNumberSchema: z.ZodType<HitchPhoneNumber, HitchPhoneNumber>;
|
|
133
|
-
declare const hitchMessageSchema: z.ZodType<HitchMessage, HitchMessage>;
|
|
134
|
-
declare const listHitchNumbersOutputSchema: z.ZodType<NumbersOutput, NumbersOutput>;
|
|
135
|
-
declare const listHitchMessagesOutputSchema: z.ZodType<MessagesOutput, MessagesOutput>;
|
|
136
|
-
declare const listHitchMessagesInputSchema: z.ZodType<ListHitchMessagesInput, ListHitchMessagesInput>;
|
|
137
|
-
declare const sendHitchMessageInputSchema: z.ZodType<SendHitchMessageInput, SendHitchMessageInput>;
|
|
138
130
|
type TelephonyContract = {
|
|
139
131
|
calls: {
|
|
140
|
-
get: ContractProcedure<
|
|
141
|
-
list: ContractProcedure<
|
|
132
|
+
get: ContractProcedure<Schema<MessageIdInput, MessageIdInput>, Schema<HitchCall, HitchCall>, Record<never, never>, Meta>;
|
|
133
|
+
list: ContractProcedure<Schema<ListHitchCallsInput, ListHitchCallsInput>, Schema<CallsOutput, CallsOutput>, Record<never, never>, Meta>;
|
|
142
134
|
};
|
|
143
135
|
numbers: {
|
|
144
|
-
list: ContractProcedure<
|
|
136
|
+
list: ContractProcedure<Schema<void, void>, Schema<NumbersOutput, NumbersOutput>, Record<never, never>, Meta>;
|
|
145
137
|
};
|
|
146
138
|
messages: {
|
|
147
|
-
get: ContractProcedure<
|
|
148
|
-
list: ContractProcedure<
|
|
149
|
-
send: ContractProcedure<
|
|
139
|
+
get: ContractProcedure<Schema<MessageIdInput, MessageIdInput>, Schema<HitchMessage, HitchMessage>, Record<never, never>, Meta>;
|
|
140
|
+
list: ContractProcedure<Schema<ListHitchMessagesInput, ListHitchMessagesInput>, Schema<MessagesOutput, MessagesOutput>, Record<never, never>, Meta>;
|
|
141
|
+
send: ContractProcedure<Schema<SendHitchMessageInput, SendHitchMessageInput>, Schema<HitchMessage, HitchMessage>, Record<never, never>, Meta>;
|
|
150
142
|
};
|
|
151
143
|
};
|
|
152
144
|
declare const telephonyContract: TelephonyContract;
|
|
@@ -173,14 +165,12 @@ type TeamsOutput = {
|
|
|
173
165
|
type TeamMembersOutput = {
|
|
174
166
|
data: HitchTeamMember[];
|
|
175
167
|
};
|
|
176
|
-
declare const teamSchema: z.ZodType<HitchTeam, HitchTeam>;
|
|
177
|
-
declare const teamMemberSchema: z.ZodType<HitchTeamMember, HitchTeamMember>;
|
|
178
168
|
type TeamsContract = {
|
|
179
|
-
list: ContractProcedure<
|
|
169
|
+
list: ContractProcedure<Schema<void, void>, Schema<TeamsOutput, TeamsOutput>, Record<never, never>, Meta>;
|
|
180
170
|
members: {
|
|
181
|
-
list: ContractProcedure<
|
|
171
|
+
list: ContractProcedure<Schema<TeamIdInput, TeamIdInput>, Schema<TeamMembersOutput, TeamMembersOutput>, Record<never, never>, Meta>;
|
|
182
172
|
};
|
|
183
173
|
};
|
|
184
174
|
declare const teamsContract: TeamsContract;
|
|
185
175
|
//#endregion
|
|
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,
|
|
176
|
+
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, emailContract, filesContract, meContract, pruneContract, registerHitchContract, teamsContract, telephonyContract, uploadFile };
|
package/dist/index.js
CHANGED
|
@@ -1,252 +1,140 @@
|
|
|
1
1
|
import { i as registerHitchContract, t as uploadFile } from "./upload-DRbVhuDm.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
2
|
+
import { t as pruneContract } from "./contract-BbOj5EB7.js";
|
|
3
|
+
import { oc, type } from "@orpc/contract";
|
|
4
|
+
//#region src/hitch/email.ts
|
|
5
|
+
function emailContract(appletCode) {
|
|
6
|
+
const path = `/v1/applets/${encodeURIComponent(appletCode)}/email/tracking`;
|
|
7
|
+
return {
|
|
8
|
+
mailboxes: { list: oc.route({
|
|
9
|
+
method: "GET",
|
|
10
|
+
path: "/v1/email/mailboxes"
|
|
11
|
+
}).input(type()).output(type()) },
|
|
12
|
+
threads: {
|
|
13
|
+
list: oc.route({
|
|
14
|
+
method: "GET",
|
|
15
|
+
path: "/v1/email/threads"
|
|
16
|
+
}).input(type()).output(type()),
|
|
17
|
+
get: oc.route({
|
|
18
|
+
method: "GET",
|
|
19
|
+
path: "/v1/email/threads/{id}"
|
|
20
|
+
}).input(type()).output(type())
|
|
21
|
+
},
|
|
22
|
+
messages: {
|
|
23
|
+
list: oc.route({
|
|
24
|
+
method: "GET",
|
|
25
|
+
path: "/v1/email/messages"
|
|
26
|
+
}).input(type()).output(type()),
|
|
27
|
+
get: oc.route({
|
|
28
|
+
method: "GET",
|
|
29
|
+
path: "/v1/email/messages/{id}"
|
|
30
|
+
}).input(type()).output(type()),
|
|
31
|
+
send: oc.route({
|
|
32
|
+
method: "POST",
|
|
33
|
+
path: "/v1/email/messages",
|
|
34
|
+
successStatus: 201
|
|
35
|
+
}).input(type()).output(type()),
|
|
36
|
+
raw: oc.route({
|
|
37
|
+
method: "GET",
|
|
38
|
+
path: "/v1/email/messages/{id}/raw"
|
|
39
|
+
}).input(type()).output(type())
|
|
40
|
+
},
|
|
41
|
+
attachments: { get: oc.route({
|
|
42
|
+
method: "GET",
|
|
43
|
+
path: "/v1/email/attachments/{id}"
|
|
44
|
+
}).input(type()).output(type()) },
|
|
45
|
+
tracking: {
|
|
46
|
+
createPixel: oc.route({
|
|
47
|
+
method: "POST",
|
|
48
|
+
path: `${path}/pixels`,
|
|
49
|
+
successStatus: 201
|
|
50
|
+
}).input(type()).output(type()),
|
|
51
|
+
markSent: oc.route({
|
|
52
|
+
method: "POST",
|
|
53
|
+
path: `${path}/{id}/sent`
|
|
54
|
+
}).input(type()).output(type()),
|
|
55
|
+
get: oc.route({
|
|
56
|
+
method: "GET",
|
|
57
|
+
path: `${path}/{id}`
|
|
58
|
+
}).input(type()).output(type()),
|
|
59
|
+
list: oc.route({
|
|
60
|
+
method: "POST",
|
|
61
|
+
path: `${path}/list`
|
|
62
|
+
}).input(type()).output(type())
|
|
23
63
|
}
|
|
24
|
-
|
|
25
|
-
}));
|
|
26
|
-
return Object.assign({}, contract, { records });
|
|
64
|
+
};
|
|
27
65
|
}
|
|
28
66
|
//#endregion
|
|
29
67
|
//#region src/hitch/files.ts
|
|
30
|
-
const fileFields = {
|
|
31
|
-
id: z.string(),
|
|
32
|
-
organizationId: z.string(),
|
|
33
|
-
key: z.string(),
|
|
34
|
-
filename: z.string(),
|
|
35
|
-
contentType: z.string(),
|
|
36
|
-
uploadedBy: z.string().nullable(),
|
|
37
|
-
createdAt: z.string(),
|
|
38
|
-
updatedAt: z.string()
|
|
39
|
-
};
|
|
40
|
-
const fileSchema = z.object({
|
|
41
|
-
...fileFields,
|
|
42
|
-
sizeBytes: z.number(),
|
|
43
|
-
arrivedAt: z.string()
|
|
44
|
-
});
|
|
45
|
-
const pendingFileSchema = z.object({
|
|
46
|
-
...fileFields,
|
|
47
|
-
sizeBytes: z.null(),
|
|
48
|
-
arrivedAt: z.null()
|
|
49
|
-
});
|
|
50
|
-
const createFileInputSchema = z.object({ body: z.object({
|
|
51
|
-
filename: z.string().trim().min(1),
|
|
52
|
-
contentType: z.string().trim().min(1)
|
|
53
|
-
}) });
|
|
54
|
-
const createFileOutputSchema = z.object({
|
|
55
|
-
data: pendingFileSchema,
|
|
56
|
-
uploadUrl: z.string()
|
|
57
|
-
});
|
|
58
|
-
const fileIdInputSchema = z.object({ params: z.object({ id: z.uuid() }) });
|
|
59
|
-
const getFileOutputSchema = z.object({
|
|
60
|
-
data: fileSchema,
|
|
61
|
-
downloadUrl: z.string()
|
|
62
|
-
});
|
|
63
68
|
const filesContract = {
|
|
64
69
|
create: oc.route({
|
|
65
70
|
method: "POST",
|
|
66
71
|
path: "/v1/files",
|
|
67
72
|
successStatus: 201,
|
|
68
73
|
inputStructure: "detailed"
|
|
69
|
-
}).input(
|
|
74
|
+
}).input(type()).output(type()),
|
|
70
75
|
confirm: oc.route({
|
|
71
76
|
method: "POST",
|
|
72
77
|
path: "/v1/files/{id}/confirm",
|
|
73
78
|
successStatus: 200,
|
|
74
79
|
inputStructure: "detailed"
|
|
75
|
-
}).input(
|
|
80
|
+
}).input(type()).output(type()),
|
|
76
81
|
get: oc.route({
|
|
77
82
|
method: "GET",
|
|
78
83
|
path: "/v1/files/{id}",
|
|
79
84
|
inputStructure: "detailed"
|
|
80
|
-
}).input(
|
|
85
|
+
}).input(type()).output(type())
|
|
81
86
|
};
|
|
82
87
|
//#endregion
|
|
88
|
+
//#region src/hitch/me.ts
|
|
89
|
+
const meContract = { get: oc.route({
|
|
90
|
+
method: "GET",
|
|
91
|
+
path: "/v1/me"
|
|
92
|
+
}).input(type()).output(type()) };
|
|
93
|
+
//#endregion
|
|
83
94
|
//#region src/hitch/telephony.ts
|
|
84
|
-
const hitchPhoneNumberSchema = z.object({
|
|
85
|
-
id: z.uuid(),
|
|
86
|
-
e164: z.string(),
|
|
87
|
-
label: z.string(),
|
|
88
|
-
enabled: z.boolean(),
|
|
89
|
-
assignedTo: z.uuid().nullable(),
|
|
90
|
-
canRead: z.boolean(),
|
|
91
|
-
canSend: z.boolean(),
|
|
92
|
-
canCall: z.boolean(),
|
|
93
|
-
voiceEnabled: z.boolean()
|
|
94
|
-
});
|
|
95
|
-
const hitchCallSchema = z.object({
|
|
96
|
-
id: z.uuid(),
|
|
97
|
-
numberId: z.uuid(),
|
|
98
|
-
direction: z.enum(["inbound", "outbound"]),
|
|
99
|
-
status: z.enum([
|
|
100
|
-
"starting",
|
|
101
|
-
"ringing",
|
|
102
|
-
"active",
|
|
103
|
-
"ended",
|
|
104
|
-
"missed",
|
|
105
|
-
"failed"
|
|
106
|
-
]),
|
|
107
|
-
from: z.string(),
|
|
108
|
-
to: z.string(),
|
|
109
|
-
userId: z.uuid().nullable(),
|
|
110
|
-
answeredAt: z.string().nullable(),
|
|
111
|
-
endedAt: z.string().nullable(),
|
|
112
|
-
durationSeconds: z.number().nullable(),
|
|
113
|
-
voicemailSeconds: z.number().nullable(),
|
|
114
|
-
hangupCause: z.string().nullable(),
|
|
115
|
-
record: z.boolean(),
|
|
116
|
-
hasRecording: z.boolean(),
|
|
117
|
-
transcriptStatus: z.enum([
|
|
118
|
-
"pending",
|
|
119
|
-
"done",
|
|
120
|
-
"failed"
|
|
121
|
-
]).nullable(),
|
|
122
|
-
transcript: z.object({ segments: z.array(z.object({
|
|
123
|
-
side: z.enum(["member", "customer"]),
|
|
124
|
-
speaker: z.number(),
|
|
125
|
-
start: z.number(),
|
|
126
|
-
end: z.number(),
|
|
127
|
-
text: z.string()
|
|
128
|
-
})) }).nullable(),
|
|
129
|
-
createdAt: z.string()
|
|
130
|
-
});
|
|
131
|
-
const hitchMessageSchema = z.object({
|
|
132
|
-
id: z.uuid(),
|
|
133
|
-
numberId: z.uuid(),
|
|
134
|
-
direction: z.enum(["inbound", "outbound"]),
|
|
135
|
-
status: z.enum([
|
|
136
|
-
"pending",
|
|
137
|
-
"unknown",
|
|
138
|
-
"accepted",
|
|
139
|
-
"sent",
|
|
140
|
-
"delivered",
|
|
141
|
-
"unconfirmed",
|
|
142
|
-
"failed",
|
|
143
|
-
"received"
|
|
144
|
-
]),
|
|
145
|
-
from: z.string(),
|
|
146
|
-
to: z.string(),
|
|
147
|
-
body: z.string().nullable(),
|
|
148
|
-
redacted: z.boolean(),
|
|
149
|
-
userId: z.uuid().nullable(),
|
|
150
|
-
appletId: z.uuid().nullable(),
|
|
151
|
-
requestId: z.string().nullable(),
|
|
152
|
-
errorCode: z.string().nullable(),
|
|
153
|
-
errorDetail: z.string().nullable(),
|
|
154
|
-
statusAt: z.string().nullable(),
|
|
155
|
-
createdAt: z.string()
|
|
156
|
-
});
|
|
157
|
-
const listHitchNumbersOutputSchema = z.object({ data: z.array(hitchPhoneNumberSchema) });
|
|
158
|
-
const listHitchMessagesOutputSchema = z.object({
|
|
159
|
-
data: z.array(hitchMessageSchema),
|
|
160
|
-
nextCursor: z.string().nullable()
|
|
161
|
-
});
|
|
162
|
-
const listHitchCallsOutputSchema = z.object({
|
|
163
|
-
data: z.array(hitchCallSchema),
|
|
164
|
-
nextCursor: z.string().nullable()
|
|
165
|
-
});
|
|
166
|
-
const idInputSchema = z.object({ id: z.uuid() });
|
|
167
|
-
const listInputFields = {
|
|
168
|
-
numberId: z.uuid().optional(),
|
|
169
|
-
userId: z.uuid().optional(),
|
|
170
|
-
direction: z.enum(["inbound", "outbound"]).optional(),
|
|
171
|
-
since: z.iso.datetime().optional(),
|
|
172
|
-
until: z.iso.datetime().optional(),
|
|
173
|
-
cursor: z.string().optional(),
|
|
174
|
-
limit: z.number().int().min(1).max(200).optional()
|
|
175
|
-
};
|
|
176
|
-
const listHitchMessagesInputSchema = z.object(listInputFields);
|
|
177
|
-
const listHitchCallsInputSchema = z.object({
|
|
178
|
-
...listInputFields,
|
|
179
|
-
status: z.enum([
|
|
180
|
-
"starting",
|
|
181
|
-
"ringing",
|
|
182
|
-
"active",
|
|
183
|
-
"ended",
|
|
184
|
-
"missed",
|
|
185
|
-
"failed"
|
|
186
|
-
]).optional()
|
|
187
|
-
});
|
|
188
|
-
const sendHitchMessageInputSchema = z.object({
|
|
189
|
-
numberId: z.uuid(),
|
|
190
|
-
to: z.string(),
|
|
191
|
-
body: z.string().min(1).max(1600),
|
|
192
|
-
requestId: z.string().min(1).max(200).optional()
|
|
193
|
-
});
|
|
194
95
|
const telephonyContract = {
|
|
195
96
|
calls: {
|
|
196
97
|
get: oc.route({
|
|
197
98
|
method: "GET",
|
|
198
99
|
path: "/v1/telephony/calls/{id}"
|
|
199
|
-
}).input(
|
|
100
|
+
}).input(type()).output(type()),
|
|
200
101
|
list: oc.route({
|
|
201
102
|
method: "GET",
|
|
202
103
|
path: "/v1/telephony/calls"
|
|
203
|
-
}).input(
|
|
104
|
+
}).input(type()).output(type())
|
|
204
105
|
},
|
|
205
106
|
numbers: { list: oc.route({
|
|
206
107
|
method: "GET",
|
|
207
108
|
path: "/v1/telephony/numbers"
|
|
208
|
-
}).input(
|
|
109
|
+
}).input(type()).output(type()) },
|
|
209
110
|
messages: {
|
|
210
111
|
get: oc.route({
|
|
211
112
|
method: "GET",
|
|
212
113
|
path: "/v1/telephony/messages/{id}"
|
|
213
|
-
}).input(
|
|
114
|
+
}).input(type()).output(type()),
|
|
214
115
|
list: oc.route({
|
|
215
116
|
method: "GET",
|
|
216
117
|
path: "/v1/telephony/messages"
|
|
217
|
-
}).input(
|
|
118
|
+
}).input(type()).output(type()),
|
|
218
119
|
send: oc.route({
|
|
219
120
|
method: "POST",
|
|
220
121
|
path: "/v1/telephony/messages",
|
|
221
122
|
successStatus: 201
|
|
222
|
-
}).input(
|
|
123
|
+
}).input(type()).output(type())
|
|
223
124
|
}
|
|
224
125
|
};
|
|
225
126
|
//#endregion
|
|
226
127
|
//#region src/hitch/teams.ts
|
|
227
|
-
const teamSchema = z.object({
|
|
228
|
-
id: z.uuid(),
|
|
229
|
-
name: z.string()
|
|
230
|
-
});
|
|
231
|
-
const teamMemberSchema = z.object({
|
|
232
|
-
userId: z.uuid(),
|
|
233
|
-
firstName: z.string(),
|
|
234
|
-
lastName: z.string(),
|
|
235
|
-
email: z.email()
|
|
236
|
-
});
|
|
237
|
-
const teamsOutputSchema = z.object({ data: z.array(teamSchema) });
|
|
238
|
-
const teamIdInputSchema = z.object({ params: z.object({ id: z.uuid() }) });
|
|
239
|
-
const teamMembersOutputSchema = z.object({ data: z.array(teamMemberSchema) });
|
|
240
128
|
const teamsContract = {
|
|
241
129
|
list: oc.route({
|
|
242
130
|
method: "GET",
|
|
243
131
|
path: "/v1/teams"
|
|
244
|
-
}).input(
|
|
132
|
+
}).input(type()).output(type()),
|
|
245
133
|
members: { list: oc.route({
|
|
246
134
|
method: "GET",
|
|
247
135
|
path: "/v1/teams/{id}/members",
|
|
248
136
|
inputStructure: "detailed"
|
|
249
|
-
}).input(
|
|
137
|
+
}).input(type()).output(type()) }
|
|
250
138
|
};
|
|
251
139
|
//#endregion
|
|
252
|
-
export {
|
|
140
|
+
export { emailContract, filesContract, meContract, pruneContract, registerHitchContract, teamsContract, telephonyContract, uploadFile };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { n as
|
|
1
|
+
import { c as resolveInstanceUrl, s as resolveAuthForOrg } from "./store-B8N_8JIN.js";
|
|
2
|
+
import { n as readWorkspaceConfig } from "./workspace-8yqXsvce.js";
|
|
3
|
+
import { r as runGenerate } from "./generate-BV_emZgy.js";
|
|
4
|
+
import { n as loadAppletSourceDefinition, o as APPLET_CODE_PATTERN, s as ORG_CODE_PATTERN } from "./load-config-Dkr2VxZN.js";
|
|
5
|
+
import { a as writeAppletSupport, n as loadCliManifest, o as writeWorkspaceSupport, t as assertWorkspaceCli } from "./project-CCVqCCgU.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,8 @@
|
|
|
1
|
+
import { n as readWorkspaceConfig } from "./workspace-8yqXsvce.js";
|
|
1
2
|
import { z } from "zod";
|
|
3
|
+
import { existsSync } from "node:fs";
|
|
4
|
+
import { basename, dirname, resolve } from "node:path";
|
|
5
|
+
import { loadConfigFromFile } from "vite";
|
|
2
6
|
import { Cron } from "croner";
|
|
3
7
|
//#region src/manifest-patterns.ts
|
|
4
8
|
const APPLET_CODE_PATTERN = /^[a-z][a-z0-9]*(?:_[a-z0-9]+)*$/;
|
|
@@ -107,7 +111,7 @@ const checkDuplicateCodes = (manifest, context) => {
|
|
|
107
111
|
});
|
|
108
112
|
};
|
|
109
113
|
const appletManifestSchema = z.strictObject(appletManifestShape).superRefine(checkDuplicateCodes);
|
|
110
|
-
|
|
114
|
+
z.strictObject({
|
|
111
115
|
name: appletManifestShape.name,
|
|
112
116
|
code: appletManifestShape.code,
|
|
113
117
|
requiresChangeset: appletManifestShape.requiresChangeset,
|
|
@@ -196,4 +200,35 @@ const appletSourceDefinitionSchema = z.strictObject({
|
|
|
196
200
|
checkSourcePackages(manifest, context);
|
|
197
201
|
});
|
|
198
202
|
//#endregion
|
|
199
|
-
|
|
203
|
+
//#region src/workspace.ts
|
|
204
|
+
function resolveWorkspaceOrg(appletRoot) {
|
|
205
|
+
const appletsDir = dirname(appletRoot);
|
|
206
|
+
if (basename(appletsDir) === "applets") {
|
|
207
|
+
const config = readWorkspaceConfig(dirname(appletsDir));
|
|
208
|
+
if (config !== void 0) return config.org;
|
|
209
|
+
}
|
|
210
|
+
throw new Error(`No Hitch workspace found for ${appletRoot}. An applet must live at <workspace>/applets/<code> with hitch.config.ts in the workspace root.`);
|
|
211
|
+
}
|
|
212
|
+
//#endregion
|
|
213
|
+
//#region src/typegen/load-config.ts
|
|
214
|
+
async function loadAppletSourceDefinition(root) {
|
|
215
|
+
const path = resolve(root, "applet.manifest.ts");
|
|
216
|
+
if (!existsSync(path)) throw new Error(`No applet manifest found at ${path}.`);
|
|
217
|
+
const loaded = await loadConfigFromFile({
|
|
218
|
+
command: "build",
|
|
219
|
+
mode: "production"
|
|
220
|
+
}, path, root);
|
|
221
|
+
if (loaded === null) throw new Error(`No applet manifest found at ${path}.`);
|
|
222
|
+
const parsed = appletSourceDefinitionSchema.safeParse(loaded.config);
|
|
223
|
+
if (!parsed.success) throw new Error(`Invalid applet manifest at ${loaded.path}: ${parsed.error.message}`);
|
|
224
|
+
return parsed.data;
|
|
225
|
+
}
|
|
226
|
+
async function loadAppletConfig(root) {
|
|
227
|
+
const { dependencies: _dependencies, devDependencies: _devDependencies, ...definition } = await loadAppletSourceDefinition(root);
|
|
228
|
+
return {
|
|
229
|
+
org: resolveWorkspaceOrg(root),
|
|
230
|
+
...definition
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
//#endregion
|
|
234
|
+
export { appletSourceDefinitionSchema as a, appletManifestSchema as i, loadAppletSourceDefinition as n, APPLET_CODE_PATTERN as o, resolveWorkspaceOrg as r, ORG_CODE_PATTERN as s, loadAppletConfig as t };
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { c as resolveInstanceUrl, t as AuthenticationError } from "./store-B8N_8JIN.js";
|
|
2
|
+
import { t as loginWithDevice } from "./device-BgIfytaR.js";
|
|
3
|
+
import { t as findWorkspaceConfig } from "./workspace-8yqXsvce.js";
|
|
2
4
|
//#region src/login.ts
|
|
3
5
|
async function runLogin(options) {
|
|
4
6
|
if (process.env.HITCH_API_KEY !== void 0) throw new AuthenticationError("HITCH_API_KEY is set — unset it to manage stored logins.");
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { t as loadAppletConfig } from "./load-config-
|
|
1
|
+
import { n as readWorkspaceConfig } from "./workspace-8yqXsvce.js";
|
|
2
|
+
import { t as fetchWithOrgAuth } from "./auth-D3CrCtZq.js";
|
|
3
|
+
import { o as APPLET_CODE_PATTERN, r as resolveWorkspaceOrg, t as loadAppletConfig } from "./load-config-Dkr2VxZN.js";
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
//#region src/logs.ts
|
|
6
6
|
const LOG_LEVELS = [
|
|
@@ -69,9 +69,6 @@ interface AppletPackages {
|
|
|
69
69
|
devDependencies?: Readonly<Record<string, string>>;
|
|
70
70
|
}
|
|
71
71
|
type AppletSourceDefinition = AppletDefinition & AppletPackages;
|
|
72
|
-
declare const appletManifestSchema: z.ZodType<AppletManifest>;
|
|
73
|
-
declare const appletDefinitionSchema: z.ZodType<AppletDefinition>;
|
|
74
|
-
declare const appletSourceDefinitionSchema: z.ZodType<AppletSourceDefinition>;
|
|
75
72
|
type RegisteredAppletManifestObject = { [Code in keyof RegisteredCatalog]: Omit<AppletManifestObject, "code" | "readOnly" | "readWrite"> & {
|
|
76
73
|
code: Code;
|
|
77
74
|
readOnly: readonly RegisteredCatalog[Code][];
|
|
@@ -90,4 +87,4 @@ type RegisteredAppletManifest = Omit<AppletManifest, "objects" | "schedules"> &
|
|
|
90
87
|
type RegisteredAppletDefinition = Omit<RegisteredAppletManifest, "org">;
|
|
91
88
|
type RegisteredAppletSourceDefinition = RegisteredAppletDefinition & AppletPackages;
|
|
92
89
|
//#endregion
|
|
93
|
-
export {
|
|
90
|
+
export { AppletSourceDefinition as a, RegisteredCatalog as c, RegisteredRouter as d, RegisteredVariableKeys as f, registerHitchContract as h, AppletPackages as i, RegisteredContract as l, RegisteredWorkflows as m, AppletManifest as n, RegisteredAppletSourceDefinition as o, RegisteredVariables as p, AppletManifestObject as r, HitchRegister as s, AppletDefinition as t, RegisteredManifest as u };
|