@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
package/dist/_internal/client.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { i as openCacheDatabase, n as clearAppletQueryCaches, o as sweepExpiredQueryCaches, r as indexedDbPersister, t as cacheTabId } from "../query-cache-CXmAyLv3.js";
|
|
2
|
-
import { QueryClientProvider } from "@tanstack/react-query";
|
|
2
|
+
import { QueryClientProvider, useIsRestoring } from "@tanstack/react-query";
|
|
3
3
|
import { PersistQueryClientProvider } from "@tanstack/react-query-persist-client";
|
|
4
4
|
import { RouterProvider } from "@tanstack/react-router";
|
|
5
5
|
import { createElement, useEffect } from "react";
|
|
@@ -130,6 +130,9 @@ async function appletQueryPersistence(appletCode) {
|
|
|
130
130
|
return;
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
|
+
function RestoredRouter({ router }) {
|
|
134
|
+
return useIsRestoring() ? null : createElement(RouterProvider, { router });
|
|
135
|
+
}
|
|
133
136
|
function mountApplet(router, appletCode) {
|
|
134
137
|
const queryClient = router.options.context.queryClient;
|
|
135
138
|
if (!queryClient) throw new Error("getRouter must provide a QueryClient via createRouter({ context: { queryClient } }).");
|
|
@@ -159,7 +162,7 @@ function mountApplet(router, appletCode) {
|
|
|
159
162
|
console.error("Could not restore the applet query cache.");
|
|
160
163
|
sweepWhenIdle();
|
|
161
164
|
}
|
|
162
|
-
},
|
|
165
|
+
}, createElement(RestoredRouter, { router })) : createElement(QueryClientProvider, { client: queryClient }, applet));
|
|
163
166
|
}).catch((error) => {
|
|
164
167
|
console.error("Could not initialize the applet query cache.", error);
|
|
165
168
|
createRoot(root).render(createElement(QueryClientProvider, { client: queryClient }, applet));
|
|
@@ -19,8 +19,6 @@ declare function cloudflareRequestFields(request: Request): {
|
|
|
19
19
|
cfRay: string | undefined;
|
|
20
20
|
traceparent: string | undefined;
|
|
21
21
|
colo: string | undefined;
|
|
22
|
-
country: string | undefined;
|
|
23
|
-
asn: number | undefined;
|
|
24
22
|
};
|
|
25
23
|
type NoteLog = {
|
|
26
24
|
set(fields: Record<string, unknown>): void;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as errorNote, c as requestIdFrom, i as createNoteLog, n as REQUEST_CONTEXT_CHANNEL, o as isUuid, r as cloudflareRequestFields, s as publishNote, t as APP_CONTEXT_CHANNEL } from "../log-context-
|
|
1
|
+
import { a as errorNote, c as requestIdFrom, i as createNoteLog, n as REQUEST_CONTEXT_CHANNEL, o as isUuid, r as cloudflareRequestFields, s as publishNote, t as APP_CONTEXT_CHANNEL } from "../log-context-DWznGjfz.js";
|
|
2
2
|
export { APP_CONTEXT_CHANNEL, REQUEST_CONTEXT_CHANNEL, cloudflareRequestFields, createNoteLog, errorNote, isUuid, publishNote, requestIdFrom };
|
package/dist/_internal/server.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { a as HITCH_ORG_CODE_HEADER,
|
|
1
|
+
import { a as HITCH_ORG_CODE_HEADER, d as HITCH_SESSION_HEADER, f as HITCH_USER_HEADER, h as HITCH_WORKFLOW_RUN_HEADER, i as HITCH_ORGANIZATION_HEADER, l as HITCH_SCHEDULE_HEADER, m as HITCH_WORKFLOW_INVOCATION_HEADER, n as HITCH_APPLET_HEADER, o as HITCH_PUBLIC_HEADER, p as HITCH_WORKFLOW_HEADER, r as HITCH_APPLET_TOKEN_HEADER, s as HITCH_RELEASE_HEADER, u as HITCH_SCHEDULE_RUN_HEADER } from "../headers-CeRX-Xji.js";
|
|
2
2
|
import { a as getRequestContext, o as runWithRequestContext, r as toMilliseconds, t as MAX_DURATION_MS } from "../workflow-CTo2kZF1.js";
|
|
3
|
-
import { a as errorNote, c as requestIdFrom, i as createNoteLog, r as cloudflareRequestFields, s as publishNote, t as APP_CONTEXT_CHANNEL } from "../log-context-
|
|
3
|
+
import { a as errorNote, c as requestIdFrom, i as createNoteLog, r as cloudflareRequestFields, s as publishNote, t as APP_CONTEXT_CHANNEL } from "../log-context-DWznGjfz.js";
|
|
4
4
|
import { a as workflowOutcomeSchema, i as workflowInvocationRequestSchema, n as runWorkflowJournal, r as journalEntrySchema, t as WorkflowFailedError } from "../workflow-engine-BOTzURKM.js";
|
|
5
5
|
import { RPCHandler } from "@orpc/server/fetch";
|
|
6
6
|
import { z } from "zod";
|
|
@@ -174,11 +174,12 @@ function createWorkerEntry(server, options) {
|
|
|
174
174
|
} : appletId !== null && token !== null ? {
|
|
175
175
|
kind: "applet",
|
|
176
176
|
appletId,
|
|
177
|
-
token
|
|
177
|
+
token,
|
|
178
|
+
public: request.headers.get(HITCH_PUBLIC_HEADER) === "1"
|
|
178
179
|
} : void 0;
|
|
179
180
|
if (identity === void 0) return jsonError(401, "missing_identity");
|
|
180
181
|
log.set({
|
|
181
|
-
callerType: identity.kind,
|
|
182
|
+
callerType: identity.kind === "applet" && identity.public ? "public" : identity.kind,
|
|
182
183
|
callerId: identity.kind === "user" ? `user:${identity.userId}` : `applet:${identity.appletId}`
|
|
183
184
|
});
|
|
184
185
|
const bindings = typeof env === "object" && env !== null ? env : {};
|
|
@@ -202,6 +203,7 @@ function createWorkerEntry(server, options) {
|
|
|
202
203
|
requestId
|
|
203
204
|
}, async () => {
|
|
204
205
|
const pathname = new URL(request.url).pathname;
|
|
206
|
+
if (pathname.startsWith("/api/__hitch/") && identity.kind === "applet" && identity.public) return jsonError(403, "platform_identity_required");
|
|
205
207
|
if (pathname === "/api/__hitch/telephony/message-received" && request.method === "POST") {
|
|
206
208
|
log.set({ route: "/api/__hitch/telephony/message-received" });
|
|
207
209
|
if (identity.kind !== "applet") return jsonError(403, "applet_identity_required");
|
package/dist/applet.js
CHANGED
|
@@ -99,23 +99,23 @@ async function main() {
|
|
|
99
99
|
const noLogFlags = values.run === void 0 && values.filter === void 0 && values.level === void 0 && values.limit === void 0 && values.live === void 0 && values.search === void 0 && values.since === void 0;
|
|
100
100
|
const noModeFlags = values["client-only"] === void 0 && values["server-only"] === void 0;
|
|
101
101
|
if (positionals.length === 1 && positionals[0] === "bootstrap" && noModeFlags && noGitFlags && noVariableFlags && noLogFlags) {
|
|
102
|
-
await (await import("./init-
|
|
102
|
+
await (await import("./init-DT0faD-q.js")).runBootstrap({ install: values["no-install"] !== true });
|
|
103
103
|
return;
|
|
104
104
|
}
|
|
105
105
|
if (positionals.length === 1 && positionals[0] === "generate" && values["no-install"] === void 0 && noModeFlags && noGitFlags && noVariableFlags && noLogFlags) {
|
|
106
|
-
await (await import("./generate-
|
|
106
|
+
await (await import("./generate-Df29-UJm.js")).runGenerate();
|
|
107
107
|
return;
|
|
108
108
|
}
|
|
109
109
|
if (positionals.length === 1 && positionals[0] === "build" && values["no-install"] === void 0 && noModeFlags && noGitFlags && noVariableFlags && noLogFlags) {
|
|
110
|
-
await (await import("./build-
|
|
110
|
+
await (await import("./build-DpkWOvd2.js")).runBuild();
|
|
111
111
|
return;
|
|
112
112
|
}
|
|
113
113
|
if (positionals.length === 1 && positionals[0] === "deploy" && values["no-install"] === void 0 && noModeFlags && noGitFlags && noVariableFlags && noLogFlags) {
|
|
114
|
-
await (await import("./deploy-
|
|
114
|
+
await (await import("./deploy-DODTE8ri.js")).runDeploy({});
|
|
115
115
|
return;
|
|
116
116
|
}
|
|
117
117
|
if (positionals.length === 2 && positionals[0] === "init" && noModeFlags && noVariableFlags && noLogFlags) {
|
|
118
|
-
await (await import("./init-
|
|
118
|
+
await (await import("./init-DT0faD-q.js")).runInit(positionals[1], {
|
|
119
119
|
commit: values["no-commit"] !== true,
|
|
120
120
|
git: values["no-git"] !== true,
|
|
121
121
|
install: values["no-install"] !== true
|
|
@@ -123,7 +123,7 @@ async function main() {
|
|
|
123
123
|
return;
|
|
124
124
|
}
|
|
125
125
|
if (positionals.length === 2 && positionals[0] === "new" && noGitFlags && noVariableFlags && noLogFlags) {
|
|
126
|
-
await (await import("./init-
|
|
126
|
+
await (await import("./init-DT0faD-q.js")).runNew({
|
|
127
127
|
code: positionals[1],
|
|
128
128
|
clientOnly: values["client-only"],
|
|
129
129
|
install: values["no-install"] !== true,
|
|
@@ -132,7 +132,7 @@ async function main() {
|
|
|
132
132
|
return;
|
|
133
133
|
}
|
|
134
134
|
if ((positionals.length === 1 || positionals.length === 2) && positionals[0] === "logs" && values["no-install"] === void 0 && noModeFlags && noGitFlags && noVariableFlags) {
|
|
135
|
-
await (await import("./logs-
|
|
135
|
+
await (await import("./logs-CEIikWzV.js")).runLogs({
|
|
136
136
|
code: positionals[1],
|
|
137
137
|
filter: values.filter,
|
|
138
138
|
run: values.run,
|
|
@@ -145,14 +145,14 @@ async function main() {
|
|
|
145
145
|
return;
|
|
146
146
|
}
|
|
147
147
|
if (positionals.length === 3 && positionals[0] === "schedules" && positionals[1] === "run" && values["no-install"] === void 0 && noModeFlags && noGitFlags && noLogFlags && values.secret === void 0) {
|
|
148
|
-
await (await import("./schedules-
|
|
148
|
+
await (await import("./schedules-B7xNl9oy.js")).runSchedule({
|
|
149
149
|
code: positionals[2],
|
|
150
150
|
yes: values.yes
|
|
151
151
|
});
|
|
152
152
|
return;
|
|
153
153
|
}
|
|
154
154
|
if ((positionals.length === 3 || positionals.length === 4) && positionals[0] === "variables" && positionals[1] === "set" && values["no-install"] === void 0 && noModeFlags && noGitFlags && noLogFlags) {
|
|
155
|
-
await (await import("./variables-
|
|
155
|
+
await (await import("./variables-DCbLJBr0.js")).runVariablesSet({
|
|
156
156
|
key: positionals[2],
|
|
157
157
|
secret: values.secret,
|
|
158
158
|
value: positionals[3],
|
|
@@ -161,11 +161,11 @@ async function main() {
|
|
|
161
161
|
return;
|
|
162
162
|
}
|
|
163
163
|
if (positionals.length === 2 && positionals[0] === "variables" && positionals[1] === "list" && values["no-install"] === void 0 && noModeFlags && noGitFlags && noVariableFlags && noLogFlags) {
|
|
164
|
-
await (await import("./variables-
|
|
164
|
+
await (await import("./variables-DCbLJBr0.js")).runVariablesList();
|
|
165
165
|
return;
|
|
166
166
|
}
|
|
167
167
|
if (positionals.length === 3 && positionals[0] === "variables" && positionals[1] === "delete" && values["no-install"] === void 0 && noModeFlags && noGitFlags && values.secret === void 0 && noLogFlags) {
|
|
168
|
-
await (await import("./variables-
|
|
168
|
+
await (await import("./variables-DCbLJBr0.js")).runVariablesDelete({
|
|
169
169
|
key: positionals[2],
|
|
170
170
|
yes: values.yes
|
|
171
171
|
});
|
|
@@ -48,17 +48,4 @@ function withBatchRecorder(target, contract) {
|
|
|
48
48
|
} });
|
|
49
49
|
}
|
|
50
50
|
//#endregion
|
|
51
|
-
|
|
52
|
-
function createLazyClientProxy(build) {
|
|
53
|
-
let client;
|
|
54
|
-
const at = (path) => new Proxy(() => void 0, {
|
|
55
|
-
get: (_target, property) => at([...path, property]),
|
|
56
|
-
apply: (_target, _thisArg, args) => {
|
|
57
|
-
client ??= build();
|
|
58
|
-
return path.reduce((value, property) => value[property], client)(...args);
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
return at([]);
|
|
62
|
-
}
|
|
63
|
-
//#endregion
|
|
64
|
-
export { withBatchRecorder as n, createLazyClientProxy as t };
|
|
51
|
+
export { withBatchRecorder as t };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as prepareAppletProjects, r as prepareAppletProject } from "./project-
|
|
1
|
+
import { i as prepareAppletProjects, r as prepareAppletProject } from "./project-CWVwic2C.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,2 +1,2 @@
|
|
|
1
|
-
import { n as MarkdownEditorProps, r as MarkdownEditorFiles, t as MarkdownEditor } from "
|
|
1
|
+
import { n as MarkdownEditorProps, r as MarkdownEditorFiles, t as MarkdownEditor } from "../../markdown-editor-BmEaBzd7.js";
|
|
2
2
|
export { MarkdownEditor, type MarkdownEditorFiles, MarkdownEditorProps };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { n as MarkdownFiles, r as MarkdownProps, t as Markdown } from "
|
|
2
|
-
import { n as MarkdownEditorProps, r as MarkdownEditorFiles, t as MarkdownEditor } from "
|
|
1
|
+
import { n as MarkdownFiles, r as MarkdownProps, t as Markdown } from "../markdown-DSHOQIOb.js";
|
|
2
|
+
import { n as MarkdownEditorProps, r as MarkdownEditorFiles, t as MarkdownEditor } from "../markdown-editor-BmEaBzd7.js";
|
|
3
3
|
export { Markdown, MarkdownEditor, type MarkdownEditorFiles, type MarkdownEditorProps, type MarkdownFiles, type MarkdownProps };
|
package/dist/client.d.ts
CHANGED
|
@@ -1,48 +1,7 @@
|
|
|
1
|
-
import { d as RegisteredRouter
|
|
2
|
-
import { t as
|
|
3
|
-
import { t as WithBatchRecorder } from "./batch-Qa4B4-Yp.js";
|
|
4
|
-
import { o as WithFilesUpload } from "./upload-D_kkmne_.js";
|
|
1
|
+
import { d as RegisteredRouter } from "./manifest-BBHD_EY9.js";
|
|
2
|
+
import { t as ExactRouterUtils } from "./query-utils-zz9pVjgp.js";
|
|
5
3
|
import { RouterClient } from "@orpc/server";
|
|
6
|
-
import { ContractRouterClient } from "@orpc/contract";
|
|
7
|
-
import { NestedClient } from "@orpc/client";
|
|
8
|
-
import { RouterUtils } from "@orpc/tanstack-query";
|
|
9
|
-
//#region src/query-utils.d.ts
|
|
10
|
-
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;
|
|
11
|
-
type QueryOptionsFunction<Utils> = Extract<Utils extends {
|
|
12
|
-
queryOptions: infer Function;
|
|
13
|
-
} ? Function : never, (...args: never[]) => unknown>;
|
|
14
|
-
type QueryOptionsArgument<Utils> = NonNullable<Parameters<QueryOptionsFunction<Utils>>[0]>;
|
|
15
|
-
type ExactOptions<Input, Options> = Options extends {
|
|
16
|
-
input: infer Actual;
|
|
17
|
-
} ? Options & {
|
|
18
|
-
input: Exact<Input, Actual>;
|
|
19
|
-
} : Options extends {
|
|
20
|
-
input?: infer Actual;
|
|
21
|
-
} ? Options & {
|
|
22
|
-
input?: Exact<Input, Actual>;
|
|
23
|
-
} : Options;
|
|
24
|
-
type QueryOptionsResult<Utils, Options> = Options & Omit<ReturnType<QueryOptionsFunction<Utils>>, keyof Options>;
|
|
25
|
-
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>;
|
|
26
|
-
type ClientTree = NestedClient<Record<never, never>>;
|
|
27
|
-
type ExactRouterUtils<Client extends ClientTree> = Client extends ((...args: infer Arguments) => unknown) ? Omit<RouterUtils<Client>, "queryOptions"> & {
|
|
28
|
-
queryOptions: ExactQueryOptions<RouterUtils<Client>, Arguments[0]>;
|
|
29
|
-
} : Omit<RouterUtils<Client>, keyof Client> & { [Key in keyof Client]: Client[Key] extends ClientTree ? ExactRouterUtils<Client[Key]> : never; };
|
|
30
|
-
//#endregion
|
|
31
4
|
//#region src/author/client.d.ts
|
|
32
|
-
type AuthorContract = NarrowContract<RegisteredContract, RegisteredManifest>;
|
|
33
|
-
type BaseHitchClient = ContractRouterClient<AuthorContract>;
|
|
34
|
-
type AuthorHitchClient = WithBatchRecorder<BaseHitchClient>;
|
|
35
|
-
type BaseHitchUtils = ExactRouterUtils<BaseHitchClient>;
|
|
36
|
-
type AuthorHitchUtils = AuthorHitchClient extends {
|
|
37
|
-
batch: infer Batch;
|
|
38
|
-
} ? BaseHitchUtils extends {
|
|
39
|
-
batch: infer BatchUtils;
|
|
40
|
-
} ? Omit<BaseHitchUtils, "batch"> & {
|
|
41
|
-
batch: Omit<BatchUtils, "call"> & {
|
|
42
|
-
call: Batch;
|
|
43
|
-
};
|
|
44
|
-
} : BaseHitchUtils : BaseHitchUtils;
|
|
45
|
-
declare const hitch: WithFilesUpload<AuthorHitchUtils>;
|
|
46
5
|
declare const api: ExactRouterUtils<RouterClient<RegisteredRouter>>;
|
|
47
6
|
//#endregion
|
|
48
|
-
export { api
|
|
7
|
+
export { api };
|
package/dist/client.js
CHANGED
|
@@ -1,17 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as withBatchRecorder, t as createLazyClientProxy } from "./lazy-client-x0DCI98S.js";
|
|
1
|
+
import { t as createLazyClientProxy } from "./lazy-client-CwIzYAoE.js";
|
|
3
2
|
import { createORPCClient } from "@orpc/client";
|
|
4
|
-
import { OpenAPILink } from "@orpc/openapi-client/fetch";
|
|
5
3
|
import { createTanstackQueryUtils } from "@orpc/tanstack-query";
|
|
6
4
|
import { RPCLink } from "@orpc/client/fetch";
|
|
7
|
-
//#region src/hitch/browser.ts
|
|
8
|
-
function createHitchClient(contract) {
|
|
9
|
-
return createLazyClientProxy(() => createORPCClient(new OpenAPILink(contract, {
|
|
10
|
-
url: `${location.origin}/api`,
|
|
11
|
-
fetch: (request, init) => globalThis.fetch(request, init)
|
|
12
|
-
})));
|
|
13
|
-
}
|
|
14
|
-
//#endregion
|
|
15
5
|
//#region src/client.ts
|
|
16
6
|
function createClient(...[options]) {
|
|
17
7
|
const clientOptions = options;
|
|
@@ -26,13 +16,6 @@ function createClient(...[options]) {
|
|
|
26
16
|
}
|
|
27
17
|
//#endregion
|
|
28
18
|
//#region src/author/client.ts
|
|
29
|
-
function buildClientHitch() {
|
|
30
|
-
const contract = getRegisteredHitchContract();
|
|
31
|
-
if (contract === void 0) throw new Error("`hitch` is unavailable: run `applet generate` first. The framework imports your .hitch automatically at build; in plain node import your .hitch once before calling hitch.");
|
|
32
|
-
return withBatchRecorder(createHitchClient(contract), contract);
|
|
33
|
-
}
|
|
34
|
-
const hitchClient = createLazyClientProxy(buildClientHitch);
|
|
35
|
-
const hitch = withFilesUpload(createTanstackQueryUtils(hitchClient), () => hitchClient.files);
|
|
36
19
|
const api = createTanstackQueryUtils(createClient());
|
|
37
20
|
//#endregion
|
|
38
|
-
export { api
|
|
21
|
+
export { api };
|
|
@@ -17,7 +17,12 @@ function pruneContract(contract, manifest) {
|
|
|
17
17
|
}
|
|
18
18
|
return [manifestObject.code, pruned];
|
|
19
19
|
}));
|
|
20
|
-
|
|
20
|
+
const platform = Object.assign({}, contract);
|
|
21
|
+
if (manifest.public === true) {
|
|
22
|
+
delete platform.email;
|
|
23
|
+
delete platform.telephony;
|
|
24
|
+
}
|
|
25
|
+
return Object.assign(platform, { records });
|
|
21
26
|
}
|
|
22
27
|
//#endregion
|
|
23
28
|
export { pruneContract as t };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as AppletManifest } from "./manifest-
|
|
1
|
+
import { n as AppletManifest } from "./manifest-BBHD_EY9.js";
|
|
2
2
|
import { AnyContractRouter } from "@orpc/contract";
|
|
3
3
|
//#region src/hitch/contract.d.ts
|
|
4
4
|
type ManifestObjectFor<Manifest, Code> = Manifest extends {
|
|
@@ -15,7 +15,9 @@ type Capability<ManifestObject, Key extends "canCreate" | "canDelete" | "readWri
|
|
|
15
15
|
type NarrowProcedures<Procedures, ManifestObject> = Omit<Procedures, (true extends Capability<ManifestObject, "canCreate"> ? never : "create") | (true extends Capability<ManifestObject, "canDelete"> ? never : "delete") | (Capability<ManifestObject, "readWrite"> extends readonly [] ? "update" | "updateWhere" : never)>;
|
|
16
16
|
type NarrowContract<Contract, Manifest> = Contract extends {
|
|
17
17
|
records: infer Records;
|
|
18
|
-
} ? Omit<Contract, "records"
|
|
18
|
+
} ? Omit<Contract, "records" | (Manifest extends {
|
|
19
|
+
public: true;
|
|
20
|
+
} ? "email" | "telephony" : never)> & {
|
|
19
21
|
records: { [Code in keyof Records & ManifestObjectCodes<Manifest>]: NarrowProcedures<Records[Code], ManifestObjectFor<Manifest, Code>>; };
|
|
20
22
|
} : Contract;
|
|
21
23
|
declare function pruneContract<const Contract extends AnyContractRouter, const Manifest extends AppletManifest>(contract: Contract, manifest: Manifest): NarrowContract<Contract, Manifest>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { n as readWorkspaceConfig } from "./workspace-8yqXsvce.js";
|
|
2
2
|
import { t as fetchWithOrgAuth } from "./auth-D3CrCtZq.js";
|
|
3
3
|
import { a as loadGitHubActionsSources, n as githubActionsContext, r as hitchResponseError, t as fetchWithGitHubActions } from "./ci-B5-mH-YW.js";
|
|
4
|
-
import { n as buildPreparedApplet, r as prepareWorkspaceBuild, t as buildApplet } from "./build-
|
|
4
|
+
import { n as buildPreparedApplet, r as prepareWorkspaceBuild, t as buildApplet } from "./build-DkKTiIu7.js";
|
|
5
5
|
import { createRequire } from "node:module";
|
|
6
6
|
import { createHash } from "node:crypto";
|
|
7
7
|
import { existsSync } from "node:fs";
|
|
@@ -2546,6 +2546,28 @@ async function deployApplet(appletRoot, options, logPrefix = "", sourceHash) {
|
|
|
2546
2546
|
if (result.unset_variables?.length) console.warn(`${logPrefix}Warning: declared variables not set: ${result.unset_variables.join(", ")}. Set them with applet variables set.`);
|
|
2547
2547
|
return result;
|
|
2548
2548
|
}
|
|
2549
|
+
function buildConcurrency() {
|
|
2550
|
+
const value = process.env.APPLET_BUILD_CONCURRENCY;
|
|
2551
|
+
if (value === void 0) return Infinity;
|
|
2552
|
+
if (/^[1-9]\d*$/.test(value)) return Number(value);
|
|
2553
|
+
console.warn(`Ignoring APPLET_BUILD_CONCURRENCY=${JSON.stringify(value)}: it must be a positive integer. Building every applet at once.`);
|
|
2554
|
+
return Infinity;
|
|
2555
|
+
}
|
|
2556
|
+
function semaphore(limit) {
|
|
2557
|
+
let active = 0;
|
|
2558
|
+
const waiting = [];
|
|
2559
|
+
return async (task) => {
|
|
2560
|
+
if (active < limit) active++;
|
|
2561
|
+
else await new Promise((resolve) => waiting.push(resolve));
|
|
2562
|
+
try {
|
|
2563
|
+
return await task();
|
|
2564
|
+
} finally {
|
|
2565
|
+
const next = waiting.shift();
|
|
2566
|
+
if (next === void 0) active--;
|
|
2567
|
+
else next();
|
|
2568
|
+
}
|
|
2569
|
+
};
|
|
2570
|
+
}
|
|
2549
2571
|
async function workspaceAppletRoots(workspaceRoot) {
|
|
2550
2572
|
const appletsDir = resolve(workspaceRoot, "applets");
|
|
2551
2573
|
const roots = (await readdir(appletsDir, { withFileTypes: true }).catch((error) => {
|
|
@@ -2607,9 +2629,10 @@ async function runDeploy(options) {
|
|
|
2607
2629
|
if (selectedRoots.length === 0) return;
|
|
2608
2630
|
if (options.dist === void 0) await prepareWorkspaceBuild(root, appletRoots);
|
|
2609
2631
|
const interactive = github === void 0 && process.stdin.isTTY === true;
|
|
2632
|
+
const buildSlot = semaphore(buildConcurrency());
|
|
2610
2633
|
const deploy = async (appletRoot) => {
|
|
2611
2634
|
const logPrefix = `[${relative(root, appletRoot)}] `;
|
|
2612
|
-
if (options.dist === void 0) await buildPreparedApplet(appletRoot, ".hitch/dist", interactive ? "" : logPrefix);
|
|
2635
|
+
if (options.dist === void 0) await buildSlot(() => buildPreparedApplet(appletRoot, ".hitch/dist", interactive ? "" : logPrefix));
|
|
2613
2636
|
await deployApplet(appletRoot, {
|
|
2614
2637
|
...options,
|
|
2615
2638
|
dist: options.dist ?? ".hitch/dist"
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { a as organizationInstanceUrl, c as resolveInstanceUrl } from "./store-B8N_8JIN.js";
|
|
2
2
|
import { t as fetchWithOrgAuth } from "./auth-D3CrCtZq.js";
|
|
3
|
-
import { t as loadAppletConfig } from "./load-config-
|
|
3
|
+
import { t as loadAppletConfig } from "./load-config-BYrBjPlr.js";
|
|
4
4
|
import { i as loadGitHubActionsBuildInputs, n as githubActionsContext } from "./ci-B5-mH-YW.js";
|
|
5
|
-
import { r as prepareAppletProject } from "./project-
|
|
5
|
+
import { r as prepareAppletProject } from "./project-CWVwic2C.js";
|
|
6
6
|
import { createRequire } from "node:module";
|
|
7
7
|
import { isContractProcedure, minifyContractRouter } from "@orpc/contract";
|
|
8
8
|
import { randomUUID } from "node:crypto";
|
|
@@ -308,17 +308,16 @@ function guardManifestForSpec(spec, manifest) {
|
|
|
308
308
|
}
|
|
309
309
|
//#endregion
|
|
310
310
|
//#region src/typegen/register.ts
|
|
311
|
-
function registerFile(catalog, options) {
|
|
311
|
+
function registerFile(catalog, options, publicApplet) {
|
|
312
312
|
const catalogType = catalog === void 0 ? "type Catalog = Record<string, string>;" : `type Catalog = {
|
|
313
313
|
${Object.entries(catalog).map(([objectCode, attributeCodes]) => ` ${JSON.stringify(objectCode)}: ${attributeCodes.map((code) => JSON.stringify(code)).join(" | ") || "never"};`).join("\n")}
|
|
314
314
|
};`;
|
|
315
|
-
|
|
316
|
-
import type
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
${options.hasServer ? `type ServerWorkflows = typeof serverModule extends {
|
|
315
|
+
const serverSourceImport = options.hasServer ? "import type server from \"../src/server/main.ts\";\nimport type * as serverModule from \"../src/server/main.ts\";\n" : "";
|
|
316
|
+
const clientSourceImport = options.hasClient ? "import type { Route as indexRoute } from \"../src/client/routes/index.tsx\";\n" : "";
|
|
317
|
+
const serverTypeImports = options.hasServer ? "import type { AnyRouter } from \"@orpc/server\";\n" : "";
|
|
318
|
+
const clientTypeImports = options.hasClient ? "import type { AnyRoute } from \"@tanstack/react-router\";\n" : "";
|
|
319
|
+
const workflowImport = options.hasServer ? "import type { WorkflowDefinition } from \"@hitch42/applet/server\";\nimport type { TelephonyMessageReceivedEvent, EmailMessageReceivedEvent } from \"@hitch42/applet\";\n" : "";
|
|
320
|
+
const serverCheck = options.hasServer ? `type ServerWorkflows = typeof serverModule extends {
|
|
322
321
|
workflows: infer Workflows extends Record<string, WorkflowDefinition<any, any>>;
|
|
323
322
|
}
|
|
324
323
|
? Workflows
|
|
@@ -340,10 +339,21 @@ type _SrcServerWorkflowsMustBeNamedExport = Expect<
|
|
|
340
339
|
: false
|
|
341
340
|
: true
|
|
342
341
|
>;
|
|
343
|
-
` : ""
|
|
342
|
+
` : "";
|
|
343
|
+
const clientCheck = options.hasClient ? `type _SrcClientRoutesIndexMustExportARoute = Expect<
|
|
344
344
|
typeof indexRoute extends AnyRoute ? true : false
|
|
345
345
|
>;
|
|
346
|
-
` : ""
|
|
346
|
+
` : "";
|
|
347
|
+
return `// Generated by @hitch42/applet — do not edit.
|
|
348
|
+
import type manifest from "./manifest.gen.ts";
|
|
349
|
+
${serverSourceImport}${clientSourceImport}${serverTypeImports}${clientTypeImports}${workflowImport}
|
|
350
|
+
${catalogType}
|
|
351
|
+
|
|
352
|
+
type Expect<T extends true> = T;
|
|
353
|
+
${serverCheck}${publicApplet && options.hasServer ? `type _PublicAppletsCannotDefineWorkflows = Expect<keyof ServerWorkflows extends never ? true : false>;
|
|
354
|
+
type _PublicAppletsCannotHandleEmail = Expect<"email" extends keyof typeof server ? false : true>;
|
|
355
|
+
type _PublicAppletsCannotHandleTelephony = Expect<"telephony" extends keyof typeof server ? false : true>;
|
|
356
|
+
` : ""}${clientCheck}
|
|
347
357
|
declare module "@hitch42/applet" {
|
|
348
358
|
interface HitchRegister {
|
|
349
359
|
catalog: Catalog;
|
|
@@ -354,12 +364,12 @@ ${options.hasServer ? ` router: (typeof server)["router"];
|
|
|
354
364
|
}
|
|
355
365
|
`;
|
|
356
366
|
}
|
|
357
|
-
async function writeRegisterDeclaration(outDir, catalog) {
|
|
367
|
+
async function writeRegisterDeclaration(outDir, catalog, publicApplet = false) {
|
|
358
368
|
await mkdir(resolve(outDir), { recursive: true });
|
|
359
369
|
await writeFile(resolve(outDir, "register.ts"), registerFile(catalog, {
|
|
360
370
|
hasClient: existsSync(resolve(outDir, "../src/client/routes/index.tsx")),
|
|
361
371
|
hasServer: existsSync(resolve(outDir, "../src/server/main.ts"))
|
|
362
|
-
}));
|
|
372
|
+
}, publicApplet));
|
|
363
373
|
}
|
|
364
374
|
//#endregion
|
|
365
375
|
//#region src/typegen/generate.ts
|
|
@@ -480,7 +490,7 @@ async function writeContractFiles(outDir, manifest, spec) {
|
|
|
480
490
|
const preparedSpec = prepareRecordSpec(spec, manifest);
|
|
481
491
|
await generateContract(preparedSpec, outDir);
|
|
482
492
|
await writeManifestGen(outDir, manifest);
|
|
483
|
-
await writeRegisterDeclaration(outDir, catalog);
|
|
493
|
+
await writeRegisterDeclaration(outDir, catalog, manifest.public === true);
|
|
484
494
|
const hasBatch = Object.hasOwn(preparedSpec.paths, "/v1/batch");
|
|
485
495
|
await writeFile(resolve(outDir, "index.ts"), `// Generated by applet generate — do not edit.
|
|
486
496
|
import { emailContract, filesContract as files, meContract as me, pruneContract, registerHitchContract, teamsContract as teams, telephonyContract as telephony } from "@hitch42/applet";
|
|
@@ -4,6 +4,7 @@ const HITCH_SESSION_HEADER = "x-hitch-session";
|
|
|
4
4
|
const HITCH_APPLET_HEADER = "x-hitch-applet";
|
|
5
5
|
const HITCH_APPLET_CODE_HEADER = "x-hitch-applet-code";
|
|
6
6
|
const HITCH_APPLET_TOKEN_HEADER = "x-hitch-applet-token";
|
|
7
|
+
const HITCH_PUBLIC_HEADER = "x-hitch-public";
|
|
7
8
|
const HITCH_SCHEDULE_RUN_HEADER = "x-hitch-schedule-run";
|
|
8
9
|
const HITCH_SCHEDULE_HEADER = "x-hitch-schedule";
|
|
9
10
|
const HITCH_ORG_CODE_HEADER = "x-hitch-org-code";
|
|
@@ -14,4 +15,4 @@ const HITCH_WORKFLOW_RUN_HEADER = "x-hitch-workflow-run";
|
|
|
14
15
|
const HITCH_WORKFLOW_HEADER = "x-hitch-workflow";
|
|
15
16
|
const HITCH_WORKFLOW_INVOCATION_HEADER = "x-hitch-workflow-invocation";
|
|
16
17
|
//#endregion
|
|
17
|
-
export { HITCH_ORG_CODE_HEADER as a,
|
|
18
|
+
export { HITCH_ORG_CODE_HEADER as a, HITCH_REQUEST_HOST_HEADER as c, HITCH_SESSION_HEADER as d, HITCH_USER_HEADER as f, HITCH_WORKFLOW_RUN_HEADER as h, HITCH_ORGANIZATION_HEADER as i, HITCH_SCHEDULE_HEADER as l, HITCH_WORKFLOW_INVOCATION_HEADER as m, HITCH_APPLET_HEADER as n, HITCH_PUBLIC_HEADER as o, HITCH_WORKFLOW_HEADER as p, HITCH_APPLET_TOKEN_HEADER as r, HITCH_RELEASE_HEADER as s, HITCH_APPLET_CODE_HEADER as t, HITCH_SCHEDULE_RUN_HEADER as u };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { l as RegisteredContract, u as RegisteredManifest } from "./manifest-BBHD_EY9.js";
|
|
2
|
+
import { t as NarrowContract } from "./contract-CJv-n1l3.js";
|
|
3
|
+
import { t as WithBatchRecorder } from "./batch-Qa4B4-Yp.js";
|
|
4
|
+
import { o as WithFilesUpload } from "./upload-D_kkmne_.js";
|
|
5
|
+
import { t as ExactRouterUtils } from "./query-utils-zz9pVjgp.js";
|
|
6
|
+
import { ContractRouterClient } from "@orpc/contract";
|
|
7
|
+
//#region src/author/hitch-client.d.ts
|
|
8
|
+
type AuthorContract = NarrowContract<RegisteredContract, RegisteredManifest>;
|
|
9
|
+
type BaseHitchClient = ContractRouterClient<AuthorContract>;
|
|
10
|
+
type AuthorHitchClient = WithBatchRecorder<BaseHitchClient>;
|
|
11
|
+
type BaseHitchUtils = ExactRouterUtils<BaseHitchClient>;
|
|
12
|
+
type AuthorHitchUtils = AuthorHitchClient extends {
|
|
13
|
+
batch: infer Batch;
|
|
14
|
+
} ? BaseHitchUtils extends {
|
|
15
|
+
batch: infer BatchUtils;
|
|
16
|
+
} ? Omit<BaseHitchUtils, "batch"> & {
|
|
17
|
+
batch: Omit<BatchUtils, "call"> & {
|
|
18
|
+
call: Batch;
|
|
19
|
+
};
|
|
20
|
+
} : BaseHitchUtils : BaseHitchUtils;
|
|
21
|
+
declare const hitch: WithFilesUpload<AuthorHitchUtils>;
|
|
22
|
+
//#endregion
|
|
23
|
+
export { hitch as t };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { n as withFilesUpload, r as getRegisteredHitchContract } from "./upload-DRbVhuDm.js";
|
|
2
|
+
import { t as withBatchRecorder } from "./batch-_ZjAg-Kk.js";
|
|
3
|
+
import { t as createLazyClientProxy } from "./lazy-client-CwIzYAoE.js";
|
|
4
|
+
import { createORPCClient } from "@orpc/client";
|
|
5
|
+
import { OpenAPILink } from "@orpc/openapi-client/fetch";
|
|
6
|
+
import { createTanstackQueryUtils } from "@orpc/tanstack-query";
|
|
7
|
+
//#region src/hitch/browser.ts
|
|
8
|
+
function createHitchClient(contract) {
|
|
9
|
+
return createLazyClientProxy(() => createORPCClient(new OpenAPILink(contract, {
|
|
10
|
+
url: `${location.origin}/api`,
|
|
11
|
+
fetch: (request, init) => globalThis.fetch(request, init)
|
|
12
|
+
})));
|
|
13
|
+
}
|
|
14
|
+
//#endregion
|
|
15
|
+
//#region src/author/hitch-client.ts
|
|
16
|
+
function buildClientHitch() {
|
|
17
|
+
const contract = getRegisteredHitchContract();
|
|
18
|
+
if (contract === void 0) throw new Error("`hitch` is unavailable: run `applet generate` first. The framework imports your .hitch automatically at build; in plain node import your .hitch once before calling hitch.");
|
|
19
|
+
return withBatchRecorder(createHitchClient(contract), contract);
|
|
20
|
+
}
|
|
21
|
+
const hitchClient = createLazyClientProxy(buildClientHitch);
|
|
22
|
+
const hitch = withFilesUpload(createTanstackQueryUtils(hitchClient), () => hitchClient.files);
|
|
23
|
+
//#endregion
|
|
24
|
+
export { hitch as t };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
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-
|
|
2
|
-
import { n as pruneContract, t as NarrowContract } from "./contract-
|
|
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-BBHD_EY9.js";
|
|
2
|
+
import { n as pruneContract, t as NarrowContract } from "./contract-CJv-n1l3.js";
|
|
3
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
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
5
|
import { ContractProcedure, Meta, Schema } from "@orpc/contract";
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { i as registerHitchContract, t as uploadFile } from "./upload-DRbVhuDm.js";
|
|
2
|
-
import { t as pruneContract } from "./contract-
|
|
2
|
+
import { t as pruneContract } from "./contract-BeKz1Qcs.js";
|
|
3
3
|
import { oc, type } from "@orpc/contract";
|
|
4
4
|
//#region src/hitch/email.ts
|
|
5
5
|
function emailContract(appletCode) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { c as resolveInstanceUrl, s as resolveAuthForOrg } from "./store-B8N_8JIN.js";
|
|
2
2
|
import { n as readWorkspaceConfig } from "./workspace-8yqXsvce.js";
|
|
3
|
-
import { r as runGenerate } from "./generate-
|
|
4
|
-
import { n as loadAppletSourceDefinition, o as APPLET_CODE_PATTERN, s as ORG_CODE_PATTERN } from "./load-config-
|
|
5
|
-
import { a as writeAppletSupport, n as loadCliManifest, o as writeWorkspaceSupport, t as assertWorkspaceCli } from "./project-
|
|
3
|
+
import { r as runGenerate } from "./generate-8yyxKRSz.js";
|
|
4
|
+
import { n as loadAppletSourceDefinition, o as APPLET_CODE_PATTERN, s as ORG_CODE_PATTERN } from "./load-config-BYrBjPlr.js";
|
|
5
|
+
import { a as writeAppletSupport, n as loadCliManifest, o as writeWorkspaceSupport, t as assertWorkspaceCli } from "./project-CWVwic2C.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";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//#region src/lazy-client.ts
|
|
2
|
+
function createLazyClientProxy(build) {
|
|
3
|
+
let client;
|
|
4
|
+
const at = (path) => new Proxy(() => void 0, {
|
|
5
|
+
get: (_target, property) => at([...path, property]),
|
|
6
|
+
apply: (_target, _thisArg, args) => {
|
|
7
|
+
client ??= build();
|
|
8
|
+
return path.reduce((value, property) => value[property], client)(...args);
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
return at([]);
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
export { createLazyClientProxy as t };
|