@hitch42/applet 0.1.1-beta.16 → 0.1.1-beta.18
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/client.js +5 -2
- package/dist/_internal/log-context.d.ts +0 -2
- package/dist/_internal/log-context.js +1 -1
- package/dist/_internal/server.js +6 -4
- package/dist/applet.js +11 -11
- package/dist/{lazy-client-x0DCI98S.js → batch-_ZjAg-Kk.js} +1 -14
- package/dist/{build-XHoa_sJL.js → build-DkKTiIu7.js} +1 -1
- package/dist/build-DpkWOvd2.js +2 -0
- package/dist/client/hitch/client.d.ts +2 -0
- package/dist/client/hitch/client.js +2 -0
- package/dist/client/hitch/phone.d.ts +2 -0
- package/dist/client/hitch/phone.js +2 -0
- package/dist/client/hitch.d.ts +3 -0
- package/dist/client/hitch.js +3 -0
- package/dist/{react → client/react}/markdown-editor.d.ts +1 -1
- package/dist/client/react/markdown-editor.js +2 -0
- package/dist/client/react/markdown.d.ts +2 -0
- package/dist/client/react/markdown.js +2 -0
- package/dist/{react.d.ts → client/react.d.ts} +2 -2
- package/dist/client/react.js +3 -0
- package/dist/client.d.ts +3 -44
- package/dist/client.js +2 -19
- package/dist/{contract-BbOj5EB7.js → contract-BeKz1Qcs.js} +6 -1
- package/dist/{contract-D9wEvxGI.d.ts → contract-CJv-n1l3.d.ts} +4 -2
- package/dist/{deploy-C5JDIn2Y.js → deploy-DODTE8ri.js} +25 -2
- package/dist/{generate-BV_emZgy.js → generate-8yyxKRSz.js} +25 -15
- package/dist/generate-Df29-UJm.js +2 -0
- package/dist/{headers-DkNr9MLJ.js → headers-CeRX-Xji.js} +2 -1
- package/dist/hitch-client--qZVa2KM.d.ts +23 -0
- package/dist/hitch-client-Cw-WZ_8v.js +24 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/{init-BGQ_bP44.js → init-DT0faD-q.js} +3 -3
- package/dist/lazy-client-CwIzYAoE.js +14 -0
- package/dist/{load-config-Dkr2VxZN.js → load-config-BYrBjPlr.js} +18 -2
- package/dist/{log-context-zu8U9Sjm.js → log-context-DWznGjfz.js} +1 -5
- package/dist/{logs-DOkT5ots.js → logs-CEIikWzV.js} +1 -1
- package/dist/{manifest-BSUtHbu-.d.ts → manifest-BBHD_EY9.d.ts} +12 -2
- package/dist/{project-CCVqCCgU.js → project-CWVwic2C.js} +33 -8
- package/dist/query-utils-zz9pVjgp.d.ts +25 -0
- package/dist/{schedules-D6-3v-Az.js → schedules-B7xNl9oy.js} +1 -1
- package/dist/server.d.ts +7 -4
- package/dist/server.js +4 -3
- package/dist/{telephony.d.ts → use-phone-M7c_HsB7.d.ts} +1 -1
- package/dist/{telephony.js → use-phone-ug4B5gQp.js} +1 -1
- package/dist/{variables-BSFZnLxY.js → variables-DCbLJBr0.js} +1 -1
- package/dist/vite.d.ts +1 -1
- package/dist/vite.js +18 -5
- package/package.json +11 -18
- package/scaffold/.agents/skills/hitch-applets/SKILL.md +8 -2
- package/scaffold/.agents/skills/hitch-applets/references/files.md +2 -2
- package/scaffold/.agents/skills/hitch-applets/references/markdown.md +8 -6
- package/scaffold/.agents/skills/hitch-applets/references/records.md +3 -3
- package/scaffold/.github/workflows/hitch.yml +1 -1
- package/types/public-applet-client-hitch.d.ts +2 -0
- package/dist/build-ueR7XjZT.js +0 -2
- package/dist/generate-C9bWqdaB.js +0 -2
- package/dist/react/markdown-editor.js +0 -2
- package/dist/react/markdown.d.ts +0 -2
- package/dist/react/markdown.js +0 -2
- package/dist/react.js +0 -3
|
@@ -77,6 +77,7 @@ const appletManifestShape = {
|
|
|
77
77
|
name: nameSchema,
|
|
78
78
|
code: codeSchema,
|
|
79
79
|
requiresChangeset: z.uuid().optional(),
|
|
80
|
+
public: z.boolean().optional(),
|
|
80
81
|
telephony: z.strictObject({
|
|
81
82
|
read: z.boolean().optional(),
|
|
82
83
|
send: z.boolean().optional(),
|
|
@@ -110,17 +111,30 @@ const checkDuplicateCodes = (manifest, context) => {
|
|
|
110
111
|
]
|
|
111
112
|
});
|
|
112
113
|
};
|
|
113
|
-
const
|
|
114
|
+
const checkPublicFields = (manifest, context) => {
|
|
115
|
+
if (!manifest.public) return;
|
|
116
|
+
[
|
|
117
|
+
"schedules",
|
|
118
|
+
"email",
|
|
119
|
+
"telephony"
|
|
120
|
+
].filter((field) => manifest[field] !== void 0).forEach((field) => context.addIssue({
|
|
121
|
+
code: "custom",
|
|
122
|
+
message: `Public applets cannot declare ${field}.`,
|
|
123
|
+
path: [field]
|
|
124
|
+
}));
|
|
125
|
+
};
|
|
126
|
+
const appletManifestSchema = z.strictObject(appletManifestShape).superRefine(checkDuplicateCodes).superRefine(checkPublicFields);
|
|
114
127
|
z.strictObject({
|
|
115
128
|
name: appletManifestShape.name,
|
|
116
129
|
code: appletManifestShape.code,
|
|
117
130
|
requiresChangeset: appletManifestShape.requiresChangeset,
|
|
131
|
+
public: appletManifestShape.public,
|
|
118
132
|
telephony: appletManifestShape.telephony,
|
|
119
133
|
email: appletManifestShape.email,
|
|
120
134
|
schedules: appletManifestShape.schedules,
|
|
121
135
|
variables: appletManifestShape.variables,
|
|
122
136
|
objects: appletManifestShape.objects
|
|
123
|
-
}).superRefine(checkDuplicateCodes);
|
|
137
|
+
}).superRefine(checkDuplicateCodes).superRefine(checkPublicFields);
|
|
124
138
|
const packageVersionsSchema = z.record(z.string().min(1), z.string().min(1)).readonly();
|
|
125
139
|
const RESERVED_APPLET_PACKAGES = /* @__PURE__ */ new Set([
|
|
126
140
|
"@fontsource-variable/geist-mono",
|
|
@@ -188,6 +202,7 @@ const appletSourceDefinitionSchema = z.strictObject({
|
|
|
188
202
|
name: appletManifestShape.name,
|
|
189
203
|
code: appletManifestShape.code,
|
|
190
204
|
requiresChangeset: appletManifestShape.requiresChangeset,
|
|
205
|
+
public: appletManifestShape.public,
|
|
191
206
|
telephony: appletManifestShape.telephony,
|
|
192
207
|
email: appletManifestShape.email,
|
|
193
208
|
schedules: appletManifestShape.schedules,
|
|
@@ -198,6 +213,7 @@ const appletSourceDefinitionSchema = z.strictObject({
|
|
|
198
213
|
}).superRefine((manifest, context) => {
|
|
199
214
|
checkDuplicateCodes(manifest, context);
|
|
200
215
|
checkSourcePackages(manifest, context);
|
|
216
|
+
checkPublicFields(manifest, context);
|
|
201
217
|
});
|
|
202
218
|
//#endregion
|
|
203
219
|
//#region src/workspace.ts
|
|
@@ -42,14 +42,10 @@ function cloudflareRequestFields(request) {
|
|
|
42
42
|
const cf = Reflect.get(request, "cf");
|
|
43
43
|
const field = (key) => typeof cf === "object" && cf !== null && key in cf ? Reflect.get(cf, key) : void 0;
|
|
44
44
|
const colo = field("colo");
|
|
45
|
-
const country = field("country");
|
|
46
|
-
const asn = field("asn");
|
|
47
45
|
return {
|
|
48
46
|
cfRay: request.headers.get("cf-ray") ?? void 0,
|
|
49
47
|
traceparent: request.headers.get("traceparent") ?? void 0,
|
|
50
|
-
colo: typeof colo === "string" ? colo : void 0
|
|
51
|
-
country: typeof country === "string" ? country : void 0,
|
|
52
|
-
asn: typeof asn === "number" ? asn : void 0
|
|
48
|
+
colo: typeof colo === "string" ? colo : void 0
|
|
53
49
|
};
|
|
54
50
|
}
|
|
55
51
|
function createNoteLog(initial) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { n as readWorkspaceConfig } from "./workspace-8yqXsvce.js";
|
|
2
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-
|
|
3
|
+
import { o as APPLET_CODE_PATTERN, r as resolveWorkspaceOrg, t as loadAppletConfig } from "./load-config-BYrBjPlr.js";
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
//#region src/logs.ts
|
|
6
6
|
const LOG_LEVELS = [
|
|
@@ -34,6 +34,7 @@ interface AppletManifest {
|
|
|
34
34
|
code: string;
|
|
35
35
|
/** This code needs the schema as of this changeset. */
|
|
36
36
|
requiresChangeset?: string;
|
|
37
|
+
public?: boolean;
|
|
37
38
|
telephony?: {
|
|
38
39
|
read?: boolean;
|
|
39
40
|
send?: boolean;
|
|
@@ -78,13 +79,22 @@ type RouterSchedulePaths<R, Prefix extends string = ""> = R extends AnyProcedure
|
|
|
78
79
|
type RegisteredSchedulePath = HitchRegister extends {
|
|
79
80
|
router: infer R extends AnyRouter;
|
|
80
81
|
} ? RouterSchedulePaths<R> : string;
|
|
81
|
-
type
|
|
82
|
+
type RegisteredAppletManifestFields = Omit<AppletManifest, "objects" | "schedules"> & {
|
|
82
83
|
schedules?: readonly (Omit<NonNullable<AppletManifest["schedules"]>[number], "path"> & {
|
|
83
84
|
path: RegisteredSchedulePath;
|
|
84
85
|
})[];
|
|
85
86
|
objects: readonly RegisteredAppletManifestObject[];
|
|
86
87
|
};
|
|
87
|
-
type
|
|
88
|
+
type RegisteredAppletManifest = (RegisteredAppletManifestFields & {
|
|
89
|
+
public?: false;
|
|
90
|
+
}) | (Omit<RegisteredAppletManifestFields, "public" | "schedules" | "email" | "telephony"> & {
|
|
91
|
+
public: true;
|
|
92
|
+
schedules?: never;
|
|
93
|
+
email?: never;
|
|
94
|
+
telephony?: never;
|
|
95
|
+
});
|
|
96
|
+
type DistributiveOmit<T, K extends PropertyKey> = T extends unknown ? Omit<T, K> : never;
|
|
97
|
+
type RegisteredAppletDefinition = DistributiveOmit<RegisteredAppletManifest, "org">;
|
|
88
98
|
type RegisteredAppletSourceDefinition = RegisteredAppletDefinition & AppletPackages;
|
|
89
99
|
//#endregion
|
|
90
100
|
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 };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { a as organizationInstanceUrl, n as DEFAULT_INSTANCE_URL } from "./store-B8N_8JIN.js";
|
|
2
2
|
import { n as readWorkspaceConfig } from "./workspace-8yqXsvce.js";
|
|
3
|
-
import { n as loadAppletSourceDefinition } from "./load-config-
|
|
3
|
+
import { n as loadAppletSourceDefinition } from "./load-config-BYrBjPlr.js";
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
import { existsSync } from "node:fs";
|
|
6
6
|
import { cp, mkdir, readFile, readdir, rm, symlink, writeFile } from "node:fs/promises";
|
|
@@ -204,7 +204,7 @@ minimumReleaseAgeExclude:
|
|
|
204
204
|
- "@hitch42/*"
|
|
205
205
|
`;
|
|
206
206
|
}
|
|
207
|
-
const
|
|
207
|
+
const oxlintConfigFile = (publicOverrides = "") => `{
|
|
208
208
|
"$schema": "./node_modules/oxlint/configuration_schema.json",
|
|
209
209
|
"plugins": ["eslint", "typescript", "unicorn", "import", "node"],
|
|
210
210
|
"options": { "typeAware": true, "typeCheck": true },
|
|
@@ -248,18 +248,42 @@ const OXLINT_CONFIG = `{
|
|
|
248
248
|
{ "assertFunctionNames": ["expect", "expect*", "assert", "assert.*", "assert*"] }
|
|
249
249
|
]
|
|
250
250
|
}
|
|
251
|
-
}
|
|
251
|
+
}${publicOverrides}
|
|
252
252
|
]
|
|
253
253
|
}
|
|
254
254
|
`;
|
|
255
|
+
async function oxlintConfig(root) {
|
|
256
|
+
const appletsRoot = resolve(root, "applets");
|
|
257
|
+
const applets = existsSync(appletsRoot) ? await readdir(appletsRoot, { withFileTypes: true }) : [];
|
|
258
|
+
const publicApplets = (await Promise.all(applets.filter((applet) => applet.isDirectory() && existsSync(resolve(appletsRoot, applet.name, "applet.manifest.ts"))).map(async (applet) => {
|
|
259
|
+
return (await loadAppletSourceDefinition(resolve(appletsRoot, applet.name))).public === true ? applet.name : null;
|
|
260
|
+
}))).filter((code) => code !== null).sort();
|
|
261
|
+
return oxlintConfigFile(publicApplets.map((name) => `,
|
|
262
|
+
{
|
|
263
|
+
"files": [${JSON.stringify(`applets/${name}/**`)}],
|
|
264
|
+
"rules": {
|
|
265
|
+
"eslint/no-restricted-imports": [
|
|
266
|
+
"error",
|
|
267
|
+
{
|
|
268
|
+
"paths": [
|
|
269
|
+
{
|
|
270
|
+
"name": "@hitch42/applet/client/hitch",
|
|
271
|
+
"message": "Public applets have no Hitch client SDK. Call your server procedures with api from @hitch42/applet/client."
|
|
272
|
+
}
|
|
273
|
+
]
|
|
274
|
+
}
|
|
275
|
+
]
|
|
276
|
+
}
|
|
277
|
+
}`).join(""));
|
|
278
|
+
}
|
|
255
279
|
async function oxfmtConfig(root) {
|
|
256
280
|
const appletsRoot = resolve(root, "applets");
|
|
257
281
|
const overrides = (existsSync(appletsRoot) ? await readdir(appletsRoot) : []).filter((code) => existsSync(resolve(appletsRoot, code, "src/client/styles/globals.css"))).sort().map((code) => `
|
|
258
282
|
{
|
|
259
|
-
"files": [
|
|
283
|
+
"files": [${JSON.stringify(`applets/${code}/**`)}],
|
|
260
284
|
"options": {
|
|
261
285
|
"sortTailwindcss": {
|
|
262
|
-
"stylesheet":
|
|
286
|
+
"stylesheet": ${JSON.stringify(`applets/${code}/src/client/styles/globals.css`)},
|
|
263
287
|
"functions": ["cn", "cva"]
|
|
264
288
|
}
|
|
265
289
|
}
|
|
@@ -331,6 +355,7 @@ async function writeWorkspaceSupport(root, config, cli) {
|
|
|
331
355
|
await ensureAgentConfigs(root, config.org);
|
|
332
356
|
const deployWorkflowTarget = resolve(root, ".github/workflows/hitch.yml");
|
|
333
357
|
const agents = await readFile(new URL("../scaffold/AGENTS.md", import.meta.url), "utf8");
|
|
358
|
+
const [lintConfig, formatConfig] = await Promise.all([oxlintConfig(root), oxfmtConfig(root)]);
|
|
334
359
|
await Promise.all([
|
|
335
360
|
mkdir(resolve(root, ".agents/skills"), { recursive: true }),
|
|
336
361
|
mkdir(resolve(root, ".claude/skills"), { recursive: true }),
|
|
@@ -346,8 +371,8 @@ async function writeWorkspaceSupport(root, config, cli) {
|
|
|
346
371
|
writeFile(resolve(root, "pnpm-workspace.yaml"), workspaceFile(resolvedCli)),
|
|
347
372
|
config.githubWorkflow === false || existsSync(deployWorkflowTarget) ? void 0 : cp(new URL("../scaffold/.github/workflows/hitch.yml", import.meta.url), deployWorkflowTarget),
|
|
348
373
|
writeFile(resolve(root, ".node-version"), "24\n"),
|
|
349
|
-
writeFile(resolve(root, ".oxlintrc.json"),
|
|
350
|
-
|
|
374
|
+
writeFile(resolve(root, ".oxlintrc.json"), lintConfig),
|
|
375
|
+
writeFile(resolve(root, ".oxfmtrc.json"), formatConfig),
|
|
351
376
|
writeGitignore(root),
|
|
352
377
|
writeFile(resolve(root, "AGENTS.md"), agents)
|
|
353
378
|
]);
|
|
@@ -506,7 +531,7 @@ export default defineConfig({
|
|
|
506
531
|
"jsx": "react-jsx",
|
|
507
532
|
"types": ["vite/client", "node"],
|
|
508
533
|
"paths": {
|
|
509
|
-
"@/*": ["./src/*"]
|
|
534
|
+
"@/*": ["./src/*"]${definition.public === true ? ",\n \"@hitch42/applet/client/hitch\": [\"./node_modules/@hitch42/applet/types/public-applet-client-hitch.d.ts\"]" : ""}
|
|
510
535
|
}
|
|
511
536
|
},
|
|
512
537
|
"include": [
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { NestedClient } from "@orpc/client";
|
|
2
|
+
import { RouterUtils } from "@orpc/tanstack-query";
|
|
3
|
+
//#region src/query-utils.d.ts
|
|
4
|
+
type Exact<Expected, Actual> = Actual extends symbol ? Actual : Actual extends Expected ? Actual extends readonly unknown[] ? Actual : Actual extends object ? NonNullable<Expected> extends object ? { [Key in keyof Actual]: Key extends keyof NonNullable<Expected> ? Exact<NonNullable<Expected>[Key], Actual[Key]> : never; } : Actual : Actual : never;
|
|
5
|
+
type QueryOptionsFunction<Utils> = Extract<Utils extends {
|
|
6
|
+
queryOptions: infer Function;
|
|
7
|
+
} ? Function : never, (...args: never[]) => unknown>;
|
|
8
|
+
type QueryOptionsArgument<Utils> = NonNullable<Parameters<QueryOptionsFunction<Utils>>[0]>;
|
|
9
|
+
type ExactOptions<Input, Options> = Options extends {
|
|
10
|
+
input: infer Actual;
|
|
11
|
+
} ? Options & {
|
|
12
|
+
input: Exact<Input, Actual>;
|
|
13
|
+
} : Options extends {
|
|
14
|
+
input?: infer Actual;
|
|
15
|
+
} ? Options & {
|
|
16
|
+
input?: Exact<Input, Actual>;
|
|
17
|
+
} : Options;
|
|
18
|
+
type QueryOptionsResult<Utils, Options> = Options & Omit<ReturnType<QueryOptionsFunction<Utils>>, keyof Options>;
|
|
19
|
+
type ExactQueryOptions<Utils, Input> = <Options extends QueryOptionsArgument<Utils> = QueryOptionsArgument<Utils>>(...rest: undefined extends Input ? [options?: ExactOptions<Input, Options>] : [options: ExactOptions<Input, Options>]) => QueryOptionsResult<Utils, Options>;
|
|
20
|
+
type ClientTree = NestedClient<Record<never, never>>;
|
|
21
|
+
type ExactRouterUtils<Client extends ClientTree> = Client extends ((...args: infer Arguments) => unknown) ? Omit<RouterUtils<Client>, "queryOptions"> & {
|
|
22
|
+
queryOptions: ExactQueryOptions<RouterUtils<Client>, Arguments[0]>;
|
|
23
|
+
} : Omit<RouterUtils<Client>, keyof Client> & { [Key in keyof Client]: Client[Key] extends ClientTree ? ExactRouterUtils<Client[Key]> : never; };
|
|
24
|
+
//#endregion
|
|
25
|
+
export { ExactRouterUtils as t };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as loadAppletConfig } from "./load-config-
|
|
1
|
+
import { t as loadAppletConfig } from "./load-config-BYrBjPlr.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 { l as RegisteredContract, m as RegisteredWorkflows, p as RegisteredVariables, u as RegisteredManifest } from "./manifest-
|
|
3
|
-
import { t as NarrowContract } from "./contract-
|
|
2
|
+
import { l as RegisteredContract, m as RegisteredWorkflows, p as RegisteredVariables, u as RegisteredManifest } from "./manifest-BBHD_EY9.js";
|
|
3
|
+
import { t as NarrowContract } from "./contract-CJv-n1l3.js";
|
|
4
4
|
import { t as WithBatchRecorder } from "./batch-Qa4B4-Yp.js";
|
|
5
5
|
import { o as WithFilesUpload } from "./upload-D_kkmne_.js";
|
|
6
6
|
import { ContractRouterClient } from "@orpc/contract";
|
|
@@ -44,8 +44,11 @@ declare const log: {
|
|
|
44
44
|
//#region src/author/server.d.ts
|
|
45
45
|
type AuthorContract = NarrowContract<RegisteredContract, RegisteredManifest>;
|
|
46
46
|
type AuthorHitchClient = WithBatchRecorder<ContractRouterClient<AuthorContract>>;
|
|
47
|
-
|
|
47
|
+
type AuthorHitch = WithFilesUpload<AuthorHitchClient> & (RegisteredManifest extends {
|
|
48
|
+
public: true;
|
|
49
|
+
} ? {} : {
|
|
48
50
|
workflows: WorkflowsClient<RegisteredWorkflows>;
|
|
49
|
-
};
|
|
51
|
+
});
|
|
52
|
+
declare const hitch: AuthorHitch;
|
|
50
53
|
//#endregion
|
|
51
54
|
export { type AppletEnv, type WorkflowDefinition, type WorkflowDuration, type WorkflowStep, createWorkflow, env, hitch, log };
|
package/dist/server.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { n as withFilesUpload, r as getRegisteredHitchContract } from "./upload-DRbVhuDm.js";
|
|
2
|
-
import { t as HITCH_APPLET_CODE_HEADER } from "./headers-
|
|
2
|
+
import { t as HITCH_APPLET_CODE_HEADER } from "./headers-CeRX-Xji.js";
|
|
3
3
|
import { a as getRequestContext, i as getIdentityBearer, n as createWorkflow, s as tryGetRequestContext } from "./workflow-CTo2kZF1.js";
|
|
4
|
-
import { s as publishNote, t as APP_CONTEXT_CHANNEL } from "./log-context-
|
|
5
|
-
import {
|
|
4
|
+
import { s as publishNote, t as APP_CONTEXT_CHANNEL } from "./log-context-DWznGjfz.js";
|
|
5
|
+
import { t as withBatchRecorder } from "./batch-_ZjAg-Kk.js";
|
|
6
|
+
import { t as createLazyClientProxy } from "./lazy-client-CwIzYAoE.js";
|
|
6
7
|
import { createORPCClient } from "@orpc/client";
|
|
7
8
|
import { OpenAPILink } from "@orpc/openapi-client/fetch";
|
|
8
9
|
//#region src/hitch/server.ts
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as fetchWithOrgAuth } from "./auth-D3CrCtZq.js";
|
|
2
|
-
import { t as loadAppletConfig } from "./load-config-
|
|
2
|
+
import { t as loadAppletConfig } from "./load-config-BYrBjPlr.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-
|
|
1
|
+
import { o as RegisteredAppletSourceDefinition } from "./manifest-BBHD_EY9.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
|
-
import { t as pruneContract } from "./contract-
|
|
1
|
+
import { t as pruneContract } from "./contract-BeKz1Qcs.js";
|
|
2
2
|
import { a as openQueryCacheDatabase } from "./query-cache-CXmAyLv3.js";
|
|
3
|
-
import { d as
|
|
3
|
+
import { d as HITCH_SESSION_HEADER, f as HITCH_USER_HEADER } from "./headers-CeRX-Xji.js";
|
|
4
4
|
import { a as workflowOutcomeSchema, n as runWorkflowJournal } from "./workflow-engine-BOTzURKM.js";
|
|
5
5
|
import { a as organizationInstanceUrl, c as resolveInstanceUrl, o as rejectEnvironmentKey, r as bearerToken, s as resolveAuthForOrg } from "./store-B8N_8JIN.js";
|
|
6
|
-
import { a as writeRegisterDeclaration, c as writeAppletRoot, d as writeServerEntry, i as syncContract, l as writeClientEntry, n as routesModuleSource, u as writeManifestGen } from "./generate-
|
|
7
|
-
import { a as appletSourceDefinitionSchema, i as appletManifestSchema, o as APPLET_CODE_PATTERN, r as resolveWorkspaceOrg } from "./load-config-
|
|
6
|
+
import { a as writeRegisterDeclaration, c as writeAppletRoot, d as writeServerEntry, i as syncContract, l as writeClientEntry, n as routesModuleSource, u as writeManifestGen } from "./generate-8yyxKRSz.js";
|
|
7
|
+
import { a as appletSourceDefinitionSchema, i as appletManifestSchema, o as APPLET_CODE_PATTERN, r as resolveWorkspaceOrg } from "./load-config-BYrBjPlr.js";
|
|
8
8
|
import { z } from "zod";
|
|
9
9
|
import { randomUUID } from "node:crypto";
|
|
10
10
|
import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
@@ -296,6 +296,18 @@ function createDevWorkflows(options) {
|
|
|
296
296
|
};
|
|
297
297
|
}
|
|
298
298
|
//#endregion
|
|
299
|
+
//#region src/lazy-client-react.ts
|
|
300
|
+
const CLIENT_REACT = "@hitch42/applet/client/react";
|
|
301
|
+
const lazyClientReact = {
|
|
302
|
+
name: "hitch-lazy-client-react",
|
|
303
|
+
enforce: "pre",
|
|
304
|
+
apply: "build",
|
|
305
|
+
resolveId(source, importer, options) {
|
|
306
|
+
if (source !== CLIENT_REACT || options.kind !== "dynamic-import") return;
|
|
307
|
+
return this.resolve(`${CLIENT_REACT}?lazy`, importer, { skipSelf: true });
|
|
308
|
+
}
|
|
309
|
+
};
|
|
310
|
+
//#endregion
|
|
299
311
|
//#region src/hitch/me-schemas.ts
|
|
300
312
|
const personSchema = z.object({
|
|
301
313
|
id: z.uuid(),
|
|
@@ -661,7 +673,7 @@ function applet(sourceDefinition) {
|
|
|
661
673
|
}) : void 0,
|
|
662
674
|
hasClient && !hasAuthorRoot ? writeAppletRoot(root) : void 0,
|
|
663
675
|
hasServer ? writeServerEntry(root, hasHitchGen, manifest.code) : void 0,
|
|
664
|
-
hasHitchGen ? void 0 : writeRegisterDeclaration(resolve(root, ".hitch"))
|
|
676
|
+
hasHitchGen ? void 0 : writeRegisterDeclaration(resolve(root, ".hitch"), void 0, manifest.public === true)
|
|
665
677
|
]);
|
|
666
678
|
if (environment.command === "serve" && environment.mode !== "test" && environment.isPreview !== true) {
|
|
667
679
|
const instanceUrl = await resolveInstanceUrl();
|
|
@@ -923,6 +935,7 @@ function applet(sourceDefinition) {
|
|
|
923
935
|
...clsxFromCn,
|
|
924
936
|
enforce: "pre"
|
|
925
937
|
},
|
|
938
|
+
lazyClientReact,
|
|
926
939
|
...hasClientSource ? [
|
|
927
940
|
tanstackRouter({
|
|
928
941
|
generatedRouteTree: ".hitch/routeTree.gen.ts",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hitch42/applet",
|
|
3
|
-
"version": "0.1.1-beta.
|
|
3
|
+
"version": "0.1.1-beta.18",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"bin": {
|
|
6
6
|
"applet": "./dist/applet.js"
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
"files": [
|
|
9
9
|
"dist",
|
|
10
10
|
"fonts",
|
|
11
|
-
"scaffold"
|
|
11
|
+
"scaffold",
|
|
12
|
+
"types"
|
|
12
13
|
],
|
|
13
14
|
"type": "module",
|
|
14
15
|
"sideEffects": [
|
|
@@ -27,22 +28,6 @@
|
|
|
27
28
|
"source": "./src/author/client.ts",
|
|
28
29
|
"default": "./dist/client.js"
|
|
29
30
|
},
|
|
30
|
-
"./react": {
|
|
31
|
-
"source": "./src/react/index.ts",
|
|
32
|
-
"default": "./dist/react.js"
|
|
33
|
-
},
|
|
34
|
-
"./react/markdown": {
|
|
35
|
-
"source": "./src/react/markdown.tsx",
|
|
36
|
-
"default": "./dist/react/markdown.js"
|
|
37
|
-
},
|
|
38
|
-
"./react/markdown-editor": {
|
|
39
|
-
"source": "./src/react/markdown-editor.tsx",
|
|
40
|
-
"default": "./dist/react/markdown-editor.js"
|
|
41
|
-
},
|
|
42
|
-
"./telephony": {
|
|
43
|
-
"source": "./src/telephony/index.ts",
|
|
44
|
-
"default": "./dist/telephony.js"
|
|
45
|
-
},
|
|
46
31
|
"./vite": {
|
|
47
32
|
"source": "./src/vite.ts",
|
|
48
33
|
"default": "./dist/vite.js"
|
|
@@ -59,6 +44,14 @@
|
|
|
59
44
|
"./_internal/log-context": {
|
|
60
45
|
"source": "./src/server/log-context.ts",
|
|
61
46
|
"default": "./dist/_internal/log-context.js"
|
|
47
|
+
},
|
|
48
|
+
"./client/hitch": {
|
|
49
|
+
"source": "./src/author/client-hitch.ts",
|
|
50
|
+
"default": "./dist/client/hitch.js"
|
|
51
|
+
},
|
|
52
|
+
"./client/react": {
|
|
53
|
+
"source": "./src/react/index.ts",
|
|
54
|
+
"default": "./dist/client/react.js"
|
|
62
55
|
}
|
|
63
56
|
},
|
|
64
57
|
"dependencies": {
|
|
@@ -9,6 +9,12 @@ Build small applets against an organization's Hitch data. Keep each applet focus
|
|
|
9
9
|
|
|
10
10
|
Treat each applet as an isolated microfrontend. Keep it separate from the data storage layer, and access Hitch data through the SDK.
|
|
11
11
|
|
|
12
|
+
## Public applets
|
|
13
|
+
|
|
14
|
+
Set `public: true` for an applet that anonymous visitors can use. It runs as the applet identity. Its manifest grants cap its access.
|
|
15
|
+
|
|
16
|
+
A public applet cannot use schedules, email, telephony, workflows, or `@hitch42/applet/client/hitch`. Client code calls its server procedures with `api` from `@hitch42/applet/client`.
|
|
17
|
+
|
|
12
18
|
## Go deeper
|
|
13
19
|
|
|
14
20
|
This file holds the common rules. Read each matching reference before you edit an applet. Paths are relative to this file.
|
|
@@ -75,7 +81,7 @@ Use the client SDK unless the task needs a secret or an external service:
|
|
|
75
81
|
|
|
76
82
|
```ts
|
|
77
83
|
import { useQuery } from "@tanstack/react-query";
|
|
78
|
-
import { hitch } from "@hitch42/applet/client";
|
|
84
|
+
import { hitch } from "@hitch42/applet/client/hitch";
|
|
79
85
|
|
|
80
86
|
const deals = useQuery(
|
|
81
87
|
hitch.records.deals.list.queryOptions({
|
|
@@ -122,7 +128,7 @@ Do not invent fields or silence type errors with casts. Ask the user when genera
|
|
|
122
128
|
Upload a file with one call. The SDK creates the file record and sends the bytes directly to storage:
|
|
123
129
|
|
|
124
130
|
```ts
|
|
125
|
-
import { hitch } from "@hitch42/applet/client";
|
|
131
|
+
import { hitch } from "@hitch42/applet/client/hitch";
|
|
126
132
|
|
|
127
133
|
const uploaded = await hitch.files.upload(file); // file is a web File
|
|
128
134
|
```
|
|
@@ -11,7 +11,7 @@ Use the file API to upload bytes, read file metadata, and link files to records.
|
|
|
11
11
|
- A failed upload throws an `Error` and leaves no usable id. Call `upload(file)` again to retry — the abandoned row is harmless.
|
|
12
12
|
|
|
13
13
|
```ts
|
|
14
|
-
import { hitch } from "@hitch42/applet/client";
|
|
14
|
+
import { hitch } from "@hitch42/applet/client/hitch";
|
|
15
15
|
|
|
16
16
|
const uploaded = await hitch.files.upload(file);
|
|
17
17
|
```
|
|
@@ -34,7 +34,7 @@ Use a TanStack mutation in a React component:
|
|
|
34
34
|
|
|
35
35
|
```ts
|
|
36
36
|
import { useMutation } from "@tanstack/react-query";
|
|
37
|
-
import { hitch } from "@hitch42/applet/client";
|
|
37
|
+
import { hitch } from "@hitch42/applet/client/hitch";
|
|
38
38
|
|
|
39
39
|
const upload = useMutation({
|
|
40
40
|
mutationFn: (file: File) => hitch.files.upload(file),
|
|
@@ -9,8 +9,8 @@ Use the SDK components to edit and render markdown with Hitch file images.
|
|
|
9
9
|
The editor supports GFM tables and task lists. A plain table serializes as GFM. A table with block content in a cell (for example a list) serializes as inline HTML, which the `Markdown` renderer also renders.
|
|
10
10
|
|
|
11
11
|
```tsx
|
|
12
|
-
import { hitch } from "@hitch42/applet/client";
|
|
13
|
-
import { MarkdownEditor } from "@hitch42/applet/react
|
|
12
|
+
import { hitch } from "@hitch42/applet/client/hitch";
|
|
13
|
+
import { MarkdownEditor } from "@hitch42/applet/client/react";
|
|
14
14
|
|
|
15
15
|
<MarkdownEditor value={value} onChange={setValue} files={hitch.files} />;
|
|
16
16
|
```
|
|
@@ -31,7 +31,9 @@ The editor uses Tiptap and is large (about 166 KB gzip). Load it lazily when it
|
|
|
31
31
|
import { lazy, Suspense } from "react";
|
|
32
32
|
|
|
33
33
|
const MarkdownEditor = lazy(() =>
|
|
34
|
-
import("@hitch42/applet/react
|
|
34
|
+
import("@hitch42/applet/client/react").then((m) => ({
|
|
35
|
+
default: m.MarkdownEditor,
|
|
36
|
+
})),
|
|
35
37
|
);
|
|
36
38
|
|
|
37
39
|
<Suspense fallback={<div className="min-h-32" />}>
|
|
@@ -39,15 +41,15 @@ const MarkdownEditor = lazy(() =>
|
|
|
39
41
|
</Suspense>;
|
|
40
42
|
```
|
|
41
43
|
|
|
42
|
-
|
|
44
|
+
The lazy import splits the editor out even when the page also imports `Markdown` statically: the `applet()` Vite plugin gives the dynamic import its own module.
|
|
43
45
|
|
|
44
46
|
## Render markdown
|
|
45
47
|
|
|
46
48
|
Pass the same files surface to `Markdown`:
|
|
47
49
|
|
|
48
50
|
```tsx
|
|
49
|
-
import { hitch } from "@hitch42/applet/client";
|
|
50
|
-
import { Markdown } from "@hitch42/applet/react
|
|
51
|
+
import { hitch } from "@hitch42/applet/client/hitch";
|
|
52
|
+
import { Markdown } from "@hitch42/applet/client/react";
|
|
51
53
|
|
|
52
54
|
<Markdown files={hitch.files}>{value}</Markdown>;
|
|
53
55
|
```
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Use the generated Hitch contract as the typed data plane.
|
|
4
4
|
|
|
5
|
-
- Import `hitch` from `@hitch42/applet/client` in client code.
|
|
5
|
+
- Import `hitch` from `@hitch42/applet/client/hitch` in client code. A public applet has no client `hitch`: it calls its own server procedures with `api` from `@hitch42/applet/client`.
|
|
6
6
|
- Import `hitch` from `@hitch42/applet/server` in server code.
|
|
7
7
|
- Read object codes, attribute codes, inputs, and outputs from the generated types.
|
|
8
8
|
- Use only the target applet's `.hitch` types as schema evidence.
|
|
@@ -33,7 +33,7 @@ Use TanStack Query options from each generated procedure.
|
|
|
33
33
|
|
|
34
34
|
```ts
|
|
35
35
|
import { useQuery } from "@tanstack/react-query";
|
|
36
|
-
import { hitch } from "@hitch42/applet/client";
|
|
36
|
+
import { hitch } from "@hitch42/applet/client/hitch";
|
|
37
37
|
|
|
38
38
|
const deals = useQuery(
|
|
39
39
|
hitch.records.deals.query.queryOptions({
|
|
@@ -46,7 +46,7 @@ const deals = useQuery(
|
|
|
46
46
|
|
|
47
47
|
```ts
|
|
48
48
|
import { useMutation } from "@tanstack/react-query";
|
|
49
|
-
import { hitch } from "@hitch42/applet/client";
|
|
49
|
+
import { hitch } from "@hitch42/applet/client/hitch";
|
|
50
50
|
|
|
51
51
|
const createDeal = useMutation(hitch.records.deals.create.mutationOptions());
|
|
52
52
|
|
|
@@ -12,4 +12,4 @@ jobs:
|
|
|
12
12
|
contents: read
|
|
13
13
|
id-token: write
|
|
14
14
|
# Hitch verifies the called workflow's commit SHA from the OIDC token.
|
|
15
|
-
uses: hitch-42/actions/.github/workflows/deploy.yml@
|
|
15
|
+
uses: hitch-42/actions/.github/workflows/deploy.yml@01e0cfa0a58c6186d678d425e96d8da330226e55
|
package/dist/build-ueR7XjZT.js
DELETED
package/dist/react/markdown.d.ts
DELETED
package/dist/react/markdown.js
DELETED
package/dist/react.js
DELETED