@hitch42/applet 0.1.1-beta.20 → 0.1.1-beta.21

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.
Files changed (94) hide show
  1. package/dist/_internal/client.d.ts +0 -2
  2. package/dist/_internal/client.js +3 -5
  3. package/dist/_internal/log-context.d.ts +0 -2
  4. package/dist/_internal/log-context.js +1 -2
  5. package/dist/_internal/server.d.ts +2 -10
  6. package/dist/_internal/server.js +9 -14
  7. package/dist/applet.js +64 -23
  8. package/dist/auth-DuMRqSGe.js +49 -0
  9. package/dist/{batch-_ZjAg-Kk.js → batch-CiLZ177G.js} +3 -4
  10. package/dist/build-C7hi2yg4.js +1 -0
  11. package/dist/{build-D47vK5aa.js → build-FAQSHJgm.js} +4 -3
  12. package/dist/{ci-BTFTCBgy.js → ci-oWlUJKm9.js} +5 -6
  13. package/dist/client/hitch/client.d.ts +1 -1
  14. package/dist/client/hitch/client.js +1 -2
  15. package/dist/client/hitch/phone.d.ts +1 -1
  16. package/dist/client/hitch/phone.js +1 -2
  17. package/dist/client/hitch.d.ts +2 -2
  18. package/dist/client/hitch.js +2 -2
  19. package/dist/client/react/markdown-editor.d.ts +1 -1
  20. package/dist/client/react/markdown-editor.js +1 -2
  21. package/dist/client/react/markdown.d.ts +1 -1
  22. package/dist/client/react/markdown.js +1 -2
  23. package/dist/client/react.d.ts +2 -2
  24. package/dist/client/react.js +2 -2
  25. package/dist/client.d.ts +2 -4
  26. package/dist/client.js +3 -5
  27. package/dist/{contract-CJv-n1l3.d.ts → contract-CUc0B2rl.d.ts} +1 -3
  28. package/dist/{contract-BeKz1Qcs.js → contract-D9LCNGjD.js} +1 -2
  29. package/dist/{create-C2UrZYSK.d.ts → create-BJqLT8Uq.d.ts} +0 -4
  30. package/dist/{deploy-BbqyK5Ik.js → deploy-BM55ZoSp.js} +160 -152
  31. package/dist/{device-BgIfytaR.js → device-CZWWckCq.js} +54 -34
  32. package/dist/{email-protocol-B9u_dh2p.d.ts → email-protocol-CEqzASSx.d.ts} +0 -6
  33. package/dist/{generate-BLD0DoCk.js → generate-48pqFh5M.js} +31 -37
  34. package/dist/generate-BYK4aNud.js +1 -0
  35. package/dist/generated-agents-BUnJ0FQA.js +215 -0
  36. package/dist/git-credential-CU7-Erzs.js +24 -0
  37. package/dist/git-deploy-C12nMNB6.js +290 -0
  38. package/dist/git-deploy-CNz6mxiF.js +1 -0
  39. package/dist/git-migration-CIq-sN61.js +629 -0
  40. package/dist/git-safety-Ck3X7jvA.js +13 -0
  41. package/dist/{headers-CeRX-Xji.js → headers-BcEMIVCo.js} +1 -2
  42. package/dist/{hitch-client-DtyTZzP5.d.ts → hitch-client-D33JOEOi.d.ts} +5 -7
  43. package/dist/{hitch-client-Cw-WZ_8v.js → hitch-client-Dph_kzDd.js} +5 -7
  44. package/dist/{hitch-file-url-BPKj9zVG.js → hitch-file-url--AMjDOzP.js} +1 -2
  45. package/dist/index.d.ts +8 -15
  46. package/dist/index.js +32 -37
  47. package/dist/{init-BKUBf6i9.js → init-Bb6WT8UB.js} +70 -18
  48. package/dist/{lazy-client-CwIzYAoE.js → lazy-client--QCL0wiu.js} +1 -2
  49. package/dist/{load-config-DGALUExv.js → load-config-Cffvj-aM.js} +24 -26
  50. package/dist/{log-context-DWznGjfz.js → log-context-BepwdjrR.js} +1 -2
  51. package/dist/login-BWZKo7Ui.js +21 -0
  52. package/dist/{logs-Cv5z1e2w.js → logs-glCVHI-8.js} +6 -6
  53. package/dist/{manifest-BBHD_EY9.d.ts → manifest-CpghlaJc.d.ts} +6 -7
  54. package/dist/manifest-patterns-BfxqImlp.js +4 -0
  55. package/dist/{markdown-CwlqzBtP.js → markdown-BA_XzFxq.js} +2 -3
  56. package/dist/{markdown-DSHOQIOb.d.ts → markdown-BXt65dDo.d.ts} +1 -3
  57. package/dist/{markdown-editor-BmEaBzd7.d.ts → markdown-editor-CB_nWLzj.d.ts} +1 -5
  58. package/dist/{markdown-editor-C5mLHGqu.js → markdown-editor-CaUuphfc.js} +3 -5
  59. package/dist/parent-D52Kxp8U.js +1 -0
  60. package/dist/parent-Zx8Eg1Ki.js +75 -0
  61. package/dist/{project-CrxdZR0B.js → project-DZGk765E.js} +63 -54
  62. package/dist/{prompt-ChS-grYO.js → prompt-CW98R-Un.js} +1 -2
  63. package/dist/{query-cache-CXmAyLv3.js → query-cache-DQJy45RT.js} +1 -2
  64. package/dist/{query-utils-zz9pVjgp.d.ts → query-utils-okxIoKM3.d.ts} +0 -2
  65. package/dist/{schedules-Dajgni_z.js → schedules-CSUb84e2.js} +5 -5
  66. package/dist/server.d.ts +5 -13
  67. package/dist/server.js +17 -20
  68. package/dist/source-hash-BbvtRaus.js +107 -0
  69. package/dist/store-E5NhITHl.js +448 -0
  70. package/dist/{upload-D_kkmne_.d.ts → upload-DXZyjZSS.d.ts} +6 -10
  71. package/dist/{upload-DRbVhuDm.js → upload-DtMavo8Q.js} +4 -6
  72. package/dist/{use-phone-ug4B5gQp.js → use-phone-CB_idmrz.js} +9 -13
  73. package/dist/{use-phone-M7c_HsB7.d.ts → use-phone-DBAkasPq.d.ts} +0 -4
  74. package/dist/{variables-B-CLu8cY.js → variables-CgZstC7I.js} +7 -8
  75. package/dist/vite.d.ts +1 -3
  76. package/dist/vite.js +41 -50
  77. package/dist/{workflow-DurM6Fwx.d.ts → workflow-BnBrJIzu.d.ts} +0 -2
  78. package/dist/{workflow-engine-BOTzURKM.js → workflow-engine-CyyaVENo.js} +2 -4
  79. package/dist/{workflow-CTo2kZF1.js → workflow-l2SlVePB.js} +2 -4
  80. package/dist/workspace-CtIKSgMD.js +76 -0
  81. package/package.json +6 -5
  82. package/scaffold/.agents/skills/hitch-applets/SKILL.md +27 -9
  83. package/scaffold/.agents/skills/hitch-applets/references/files.md +2 -2
  84. package/scaffold/.agents/skills/hitch-applets/references/manifest.md +8 -6
  85. package/scaffold/.agents/skills/hitch-applets/references/performance.md +2 -2
  86. package/scaffold/.agents/skills/hitch-applets/references/records.md +8 -8
  87. package/scaffold/.agents/skills/hitch-cli/SKILL.md +52 -43
  88. package/scaffold/AGENTS.md +6 -0
  89. package/dist/auth-D3CrCtZq.js +0 -21
  90. package/dist/build-JtbY8q2p.js +0 -2
  91. package/dist/generate-COCRy1Bs.js +0 -2
  92. package/dist/login-CceGvlMi.js +0 -14
  93. package/dist/store-B8N_8JIN.js +0 -196
  94. package/dist/workspace-8yqXsvce.js +0 -31
@@ -1,18 +1,17 @@
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";
1
+ import { n as withFilesUpload, r as getRegisteredHitchContract } from "./upload-DtMavo8Q.js";
2
+ import { t as withBatchRecorder } from "./batch-CiLZ177G.js";
3
+ import { t as createLazyClientProxy } from "./lazy-client--QCL0wiu.js";
4
4
  import { createORPCClient } from "@orpc/client";
5
5
  import { OpenAPILink } from "@orpc/openapi-client/fetch";
6
6
  import { createTanstackQueryUtils } from "@orpc/tanstack-query";
7
- //#region src/hitch/browser.ts
7
+ // src/hitch/browser.ts
8
8
  function createHitchClient(contract) {
9
9
  return createLazyClientProxy(() => createORPCClient(new OpenAPILink(contract, {
10
10
  url: `${location.origin}/api`,
11
11
  fetch: (request, init) => globalThis.fetch(request, init)
12
12
  })));
13
13
  }
14
- //#endregion
15
- //#region src/author/hitch-client.ts
14
+ // src/author/hitch-client.ts
16
15
  function buildClientHitch() {
17
16
  const contract = getRegisteredHitchContract();
18
17
  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.");
@@ -20,5 +19,4 @@ function buildClientHitch() {
20
19
  }
21
20
  const hitchClient = createLazyClientProxy(buildClientHitch);
22
21
  const hitch = withFilesUpload(createTanstackQueryUtils(hitchClient), () => hitchClient.files);
23
- //#endregion
24
22
  export { hitch as t };
@@ -1,4 +1,4 @@
1
- //#region src/react/hitch-file-url.ts
1
+ // src/react/hitch-file-url.ts
2
2
  const HITCH_FILE_PREFIX = "hitch-file://";
3
3
  const DOWNLOAD_URL_TTL_MS = 3e6;
4
4
  const downloadUrlCache = /* @__PURE__ */ new Map();
@@ -21,5 +21,4 @@ function seedDownloadUrl(id, url) {
21
21
  function invalidateDownloadUrl(id) {
22
22
  downloadUrlCache.delete(id);
23
23
  }
24
- //#endregion
25
24
  export { seedDownloadUrl as i, cachedDownloadUrl as n, invalidateDownloadUrl as r, HITCH_FILE_PREFIX as t };
package/dist/index.d.ts CHANGED
@@ -1,16 +1,13 @@
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
- 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";
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-CpghlaJc.js";
2
+ import { n as pruneContract, t as NarrowContract } from "./contract-CUc0B2rl.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-DXZyjZSS.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-CEqzASSx.js";
5
5
  import { ContractProcedure, Meta, Schema } from "@orpc/contract";
6
- //#region ../shared/auth/src/workspace.d.mts
7
6
  interface HitchConfig {
8
7
  sdk: string;
9
8
  org: string;
10
9
  githubWorkflow?: boolean;
11
10
  }
12
- //#endregion
13
- //#region src/hitch/me.d.ts
14
11
  type HitchPerson = {
15
12
  id: string;
16
13
  firstName: string;
@@ -38,8 +35,6 @@ type MeContract = {
38
35
  get: ContractProcedure<Schema<void, void>, Schema<HitchMe, HitchMe>, Record<never, never>, Meta>;
39
36
  };
40
37
  declare const meContract: MeContract;
41
- //#endregion
42
- //#region src/hitch/telephony.d.ts
43
38
  type HitchPhoneNumber = {
44
39
  id: string;
45
40
  e164: string;
@@ -142,10 +137,9 @@ type TelephonyContract = {
142
137
  };
143
138
  };
144
139
  declare const telephonyContract: TelephonyContract;
145
- //#endregion
146
- //#region src/hitch/teams.d.ts
147
140
  type HitchTeam = {
148
141
  id: string;
142
+ code: string;
149
143
  name: string;
150
144
  };
151
145
  type HitchTeamMember = {
@@ -154,9 +148,9 @@ type HitchTeamMember = {
154
148
  lastName: string;
155
149
  email: string;
156
150
  };
157
- type TeamIdInput = {
151
+ type TeamInput = {
158
152
  params: {
159
- id: string;
153
+ team: string;
160
154
  };
161
155
  };
162
156
  type TeamsOutput = {
@@ -168,9 +162,8 @@ type TeamMembersOutput = {
168
162
  type TeamsContract = {
169
163
  list: ContractProcedure<Schema<void, void>, Schema<TeamsOutput, TeamsOutput>, Record<never, never>, Meta>;
170
164
  members: {
171
- list: ContractProcedure<Schema<TeamIdInput, TeamIdInput>, Schema<TeamMembersOutput, TeamMembersOutput>, Record<never, never>, Meta>;
165
+ list: ContractProcedure<Schema<TeamInput, TeamInput>, Schema<TeamMembersOutput, TeamMembersOutput>, Record<never, never>, Meta>;
172
166
  };
173
167
  };
174
168
  declare const teamsContract: TeamsContract;
175
- //#endregion
176
169
  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,56 +1,56 @@
1
- import { i as registerHitchContract, t as uploadFile } from "./upload-DRbVhuDm.js";
2
- import { t as pruneContract } from "./contract-BeKz1Qcs.js";
1
+ import { i as registerHitchContract, t as uploadFile } from "./upload-DtMavo8Q.js";
2
+ import { t as pruneContract } from "./contract-D9LCNGjD.js";
3
3
  import { oc, type } from "@orpc/contract";
4
- //#region src/hitch/email.ts
4
+ // src/hitch/email.ts
5
5
  function emailContract(appletCode) {
6
- const path = `/v1/applets/${encodeURIComponent(appletCode)}/email/tracking`;
6
+ const path = `/resource/v1/applets/${encodeURIComponent(appletCode)}/email/trackers`;
7
7
  return {
8
8
  mailboxes: { list: oc.route({
9
9
  method: "GET",
10
- path: "/v1/email/mailboxes"
10
+ path: "/resource/v1/email/mailboxes"
11
11
  }).input(type()).output(type()) },
12
12
  threads: {
13
13
  list: oc.route({
14
14
  method: "GET",
15
- path: "/v1/email/threads"
15
+ path: "/resource/v1/email/threads"
16
16
  }).input(type()).output(type()),
17
17
  get: oc.route({
18
18
  method: "GET",
19
- path: "/v1/email/threads/{id}"
19
+ path: "/resource/v1/email/threads/{id}"
20
20
  }).input(type()).output(type())
21
21
  },
22
22
  messages: {
23
23
  list: oc.route({
24
24
  method: "GET",
25
- path: "/v1/email/messages"
25
+ path: "/resource/v1/email/messages"
26
26
  }).input(type()).output(type()),
27
27
  get: oc.route({
28
28
  method: "GET",
29
- path: "/v1/email/messages/{id}"
29
+ path: "/resource/v1/email/messages/{id}"
30
30
  }).input(type()).output(type()),
31
31
  send: oc.route({
32
32
  method: "POST",
33
- path: "/v1/email/messages",
33
+ path: "/resource/v1/email/messages",
34
34
  successStatus: 201
35
35
  }).input(type()).output(type()),
36
36
  raw: oc.route({
37
37
  method: "GET",
38
- path: "/v1/email/messages/{id}/raw"
38
+ path: "/resource/v1/email/messages/{id}/raw"
39
39
  }).input(type()).output(type())
40
40
  },
41
41
  attachments: { get: oc.route({
42
42
  method: "GET",
43
- path: "/v1/email/attachments/{id}"
43
+ path: "/resource/v1/email/attachments/{id}"
44
44
  }).input(type()).output(type()) },
45
45
  tracking: {
46
46
  createPixel: oc.route({
47
47
  method: "POST",
48
- path: `${path}/pixels`,
48
+ path,
49
49
  successStatus: 201
50
50
  }).input(type()).output(type()),
51
51
  markSent: oc.route({
52
- method: "POST",
53
- path: `${path}/{id}/sent`
52
+ method: "PATCH",
53
+ path: `${path}/{id}`
54
54
  }).input(type()).output(type()),
55
55
  get: oc.route({
56
56
  method: "GET",
@@ -58,83 +58,78 @@ function emailContract(appletCode) {
58
58
  }).input(type()).output(type()),
59
59
  list: oc.route({
60
60
  method: "POST",
61
- path: `${path}/list`
61
+ path: `${path}/query`
62
62
  }).input(type()).output(type())
63
63
  }
64
64
  };
65
65
  }
66
- //#endregion
67
- //#region src/hitch/files.ts
66
+ // src/hitch/files.ts
68
67
  const filesContract = {
69
68
  create: oc.route({
70
69
  method: "POST",
71
- path: "/v1/files",
70
+ path: "/resource/v1/files",
72
71
  successStatus: 201,
73
72
  inputStructure: "detailed"
74
73
  }).input(type()).output(type()),
75
74
  confirm: oc.route({
76
75
  method: "POST",
77
- path: "/v1/files/{id}/confirm",
76
+ path: "/resource/v1/files/{file}/confirm",
78
77
  successStatus: 200,
79
78
  inputStructure: "detailed"
80
79
  }).input(type()).output(type()),
81
80
  get: oc.route({
82
81
  method: "GET",
83
- path: "/v1/files/{id}",
82
+ path: "/resource/v1/files/{file}",
84
83
  inputStructure: "detailed"
85
84
  }).input(type()).output(type())
86
85
  };
87
- //#endregion
88
- //#region src/hitch/me.ts
86
+ // src/hitch/me.ts
89
87
  const meContract = { get: oc.route({
90
88
  method: "GET",
91
- path: "/v1/me"
89
+ path: "/me/v1"
92
90
  }).input(type()).output(type()) };
93
- //#endregion
94
- //#region src/hitch/telephony.ts
91
+ // src/hitch/telephony.ts
95
92
  const telephonyContract = {
96
93
  calls: {
97
94
  get: oc.route({
98
95
  method: "GET",
99
- path: "/v1/telephony/calls/{id}"
96
+ path: "/resource/v1/telephony/calls/{id}"
100
97
  }).input(type()).output(type()),
101
98
  list: oc.route({
102
99
  method: "GET",
103
- path: "/v1/telephony/calls"
100
+ path: "/resource/v1/telephony/calls"
104
101
  }).input(type()).output(type())
105
102
  },
106
103
  numbers: { list: oc.route({
107
104
  method: "GET",
108
- path: "/v1/telephony/numbers"
105
+ path: "/resource/v1/telephony/numbers"
109
106
  }).input(type()).output(type()) },
110
107
  messages: {
111
108
  get: oc.route({
112
109
  method: "GET",
113
- path: "/v1/telephony/messages/{id}"
110
+ path: "/resource/v1/telephony/messages/{id}"
114
111
  }).input(type()).output(type()),
115
112
  list: oc.route({
116
113
  method: "GET",
117
- path: "/v1/telephony/messages"
114
+ path: "/resource/v1/telephony/messages"
118
115
  }).input(type()).output(type()),
119
116
  send: oc.route({
120
117
  method: "POST",
121
- path: "/v1/telephony/messages",
118
+ path: "/resource/v1/telephony/messages",
122
119
  successStatus: 201
123
120
  }).input(type()).output(type())
124
121
  }
125
122
  };
126
- //#endregion
127
- //#region src/hitch/teams.ts
123
+ // src/hitch/teams.ts
128
124
  const teamsContract = {
129
125
  list: oc.route({
130
126
  method: "GET",
131
- path: "/v1/teams"
127
+ path: "/resource/v1/teams"
132
128
  }).input(type()).output(type()),
133
129
  members: { list: oc.route({
134
130
  method: "GET",
135
- path: "/v1/teams/{id}/members",
131
+ path: "/resource/v1/teams/{team}/members",
136
132
  inputStructure: "detailed"
137
133
  }).input(type()).output(type()) }
138
134
  };
139
- //#endregion
140
135
  export { emailContract, filesContract, meContract, pruneContract, registerHitchContract, teamsContract, telephonyContract, uploadFile };
@@ -1,12 +1,17 @@
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-BLD0DoCk.js";
4
- import { c as ORG_CODE_PATTERN, n as loadAppletSourceDefinition, s as APPLET_CODE_PATTERN } from "./load-config-DGALUExv.js";
5
- import { n as loadCliManifest, o as writeAppletSupport, s as writeWorkspaceSupport, t as assertWorkspaceCli } from "./project-CrxdZR0B.js";
1
+ import { r as writeGeneratedAgents } from "./generated-agents-BUnJ0FQA.js";
2
+ import { f as resolveAuth, m as resolveInstanceUrl, p as resolveAuthForOrg } from "./store-E5NhITHl.js";
3
+ import { a as findWorkspaceRoot, i as findWorkspaceConfig, o as isRootLayout, r as findParentRoot, s as readWorkspaceConfig } from "./workspace-CtIKSgMD.js";
4
+ import { r as orgUsesHitchGit, t as canCheckHitchGit } from "./auth-DuMRqSGe.js";
5
+ import { n as loadAppletSourceDefinition } from "./load-config-Cffvj-aM.js";
6
+ import { r as runGenerate } from "./generate-48pqFh5M.js";
7
+ import { n as ORG_CODE_PATTERN, t as APPLET_CODE_PATTERN } from "./manifest-patterns-BfxqImlp.js";
8
+ import { l as writeRootSupport, n as loadCliManifest, r as loadPackageManifest, s as writeAppletSupport, t as assertWorkspaceCli, u as writeWorkspaceSupport } from "./project-DZGk765E.js";
9
+ import { n as childApplets } from "./parent-Zx8Eg1Ki.js";
10
+ import { t as migrateIfEnabled } from "./git-migration-CIq-sN61.js";
6
11
  import { access, cp, mkdir, readdir, writeFile } from "node:fs/promises";
7
12
  import { relative, resolve } from "node:path";
8
13
  import { spawn } from "node:child_process";
9
- //#region src/init.ts
14
+ // src/init.ts
10
15
  function isMissingFile(error) {
11
16
  return error instanceof Error && "code" in error && error.code === "ENOENT";
12
17
  }
@@ -151,10 +156,34 @@ export default {
151
156
  const nextSteps = [...installResult === "succeeded" ? [] : ["pnpm install"], "pnpm exec applet new <code>"];
152
157
  console.log(`Workspace created in ${target}.\n\nNext steps:\n${nextSteps.map((step) => ` ${step}`).join("\n")}`);
153
158
  }
159
+ async function bootstrapApplet(root, options) {
160
+ const cli = await loadCliManifest();
161
+ if (cli === void 0) throw new Error("The CLI package manifest is not published.");
162
+ await writeRootSupport(root, await loadAppletSourceDefinition(root), cli);
163
+ if (await installDependencies(root, options.install ?? true) === "failed") throw new Error(`Dependency installation failed in ${root}.`);
164
+ console.log(`Applet files generated in ${root}.`);
165
+ }
154
166
  async function runBootstrap(options = {}) {
155
- const target = process.cwd();
167
+ const cwd = process.cwd();
168
+ const workspace = findWorkspaceRoot(cwd);
169
+ const parent = workspace === void 0 ? findParentRoot(cwd) : void 0;
170
+ if (parent !== void 0) {
171
+ await writeGeneratedAgents(parent);
172
+ for (const child of await childApplets(parent)) await bootstrapApplet(child, options);
173
+ return;
174
+ }
175
+ const target = workspace ?? cwd;
156
176
  const config = readWorkspaceConfig(target);
157
- if (config === void 0) throw new Error(`Not a Hitch workspace root: ${target}. Run applet bootstrap from the directory that contains hitch.config.ts.`);
177
+ if (config === void 0) throw new Error(`Not a Hitch workspace or applet: ${target}.`);
178
+ if (isRootLayout(target)) {
179
+ await bootstrapApplet(target, options);
180
+ return;
181
+ }
182
+ const migration = await migrateIfEnabled(cwd, options.message);
183
+ if (migration !== void 0) {
184
+ for (const child of migration.roots) await bootstrapApplet(child, options);
185
+ return;
186
+ }
158
187
  const cli = await loadCliManifest();
159
188
  if (cli === void 0) throw new Error("The CLI package manifest is not published.");
160
189
  assertWorkspaceCli(config, cli);
@@ -176,19 +205,35 @@ async function runBootstrap(options = {}) {
176
205
  async function runNew(options) {
177
206
  if (!APPLET_CODE_PATTERN.test(options.code)) throw new Error(`Invalid applet code "${options.code}".`);
178
207
  if (options.clientOnly === true && options.serverOnly === true) throw new Error("Use only one of --client-only or --server-only.");
179
- const workspaceRoot = process.cwd();
208
+ const cwd = process.cwd();
209
+ const previousConfig = findWorkspaceConfig(cwd);
210
+ const migration = await migrateIfEnabled(cwd, options.message);
211
+ const workspaceRoot = migration === void 0 ? findWorkspaceRoot(cwd) ?? findParentRoot(cwd) ?? cwd : migration.roots.length === 1 ? migration.roots[0] : migration.root;
180
212
  const name = options.code.replaceAll("_", " ").replace(/^./, (character) => character.toUpperCase());
181
- const config = readWorkspaceConfig(workspaceRoot);
182
- if (config === void 0) throw new Error(`Not a Hitch workspace root: ${workspaceRoot}. Run applet new from the directory that contains hitch.config.ts.`);
213
+ const workspaceConfig = readWorkspaceConfig(workspaceRoot);
214
+ const childOrgs = findParentRoot(workspaceRoot) === workspaceRoot ? [...new Set((await childApplets(workspaceRoot)).map((child) => readWorkspaceConfig(child).org))] : [];
215
+ const org = workspaceConfig?.org ?? previousConfig?.org ?? process.env.HITCH_DEFAULT_ORG ?? (childOrgs.length === 1 ? childOrgs[0] : void 0) ?? (await resolveAuth(await resolveInstanceUrl()))?.orgCode;
216
+ if (org === void 0 || !ORG_CODE_PATTERN.test(org)) throw new Error("Set HITCH_DEFAULT_ORG or log in to one organization before applet new.");
217
+ const hitchGit = await canCheckHitchGit() && await orgUsesHitchGit(org);
218
+ if (!hitchGit && cwd !== workspaceRoot) throw new Error(`Not a Hitch workspace root: ${cwd}. Run applet new from the directory that contains hitch.config.ts.`);
219
+ if (!hitchGit && (workspaceConfig === void 0 || isRootLayout(workspaceRoot))) throw new Error("Hitch git is off. Run applet new in a legacy workspace.");
183
220
  const cli = await loadCliManifest({ allowDevelopment: true });
184
- if (cli !== void 0) assertWorkspaceCli(config, cli);
185
- const appletTarget = resolve(workspaceRoot, "applets", options.code);
221
+ if (cli !== void 0 && !hitchGit) assertWorkspaceCli(workspaceConfig, cli);
222
+ const config = workspaceConfig ?? {
223
+ org,
224
+ sdk: `@hitch42/applet@${cli?.version ?? "0.0.0"}`
225
+ };
226
+ const appletTarget = resolve(workspaceRoot, ...hitchGit ? [] : ["applets"], options.code);
186
227
  await assertTargetIsAvailable([resolve(appletTarget, "applet.manifest.ts"), resolve(appletTarget, "src")], "an applet");
187
228
  const hasClient = options.serverOnly !== true;
188
229
  const hasServer = options.clientOnly !== true;
189
230
  if (hasClient) await cp(new URL("../scaffold/applet", import.meta.url), appletTarget, { recursive: true });
190
231
  await Promise.all([hasClient ? mkdir(resolve(appletTarget, "src/client/routes"), { recursive: true }) : void 0, hasServer ? mkdir(resolve(appletTarget, "src/server"), { recursive: true }) : void 0]);
191
232
  const definition = {
233
+ ...hitchGit ? {
234
+ org,
235
+ sdk: (cli ?? await loadPackageManifest()).version
236
+ } : {},
192
237
  name,
193
238
  code: options.code,
194
239
  objects: [],
@@ -199,7 +244,7 @@ async function runNew(options) {
199
244
  writeFile(resolve(appletTarget, "applet.manifest.ts"), `import type { AppletSourceDefinition } from "@hitch42/applet";
200
245
 
201
246
  export default {
202
- name: "${name}",
247
+ ${hitchGit ? ` org: ${JSON.stringify(org)},\n sdk: ${JSON.stringify(definition.sdk)},\n` : ""} name: "${name}",
203
248
  code: "${options.code}",
204
249
  objects: [],
205
250
  dependencies: {},
@@ -224,16 +269,23 @@ const router = {
224
269
  export default { router };
225
270
  `) : void 0
226
271
  ]);
227
- await Promise.all([writeAppletSupport(appletTarget, definition), cli === void 0 ? void 0 : writeWorkspaceSupport(workspaceRoot, config, cli)]);
228
- const installResult = await installDependencies(workspaceRoot, options.install ?? true);
272
+ if (hitchGit) {
273
+ if (cli === void 0) await writeAppletSupport(appletTarget, definition);
274
+ else await writeRootSupport(appletTarget, definition, cli);
275
+ if (!await runGit(appletTarget, [
276
+ "init",
277
+ "-b",
278
+ "main"
279
+ ])) throw new Error("Could not initialize the applet repo.");
280
+ } else await Promise.all([writeAppletSupport(appletTarget, definition), cli === void 0 ? void 0 : writeWorkspaceSupport(workspaceRoot, config, cli)]);
281
+ const installResult = await installDependencies(hitchGit ? appletTarget : workspaceRoot, options.install ?? true);
229
282
  const generateSucceeded = await generateAppletFiles(appletTarget, config.org, installResult);
230
283
  const relativeTarget = relative(workspaceRoot, appletTarget);
231
284
  const nextSteps = [
232
- ...installResult === "succeeded" ? [`cd ${JSON.stringify(relativeTarget)}`] : ["pnpm install", `cd ${JSON.stringify(relativeTarget)}`],
285
+ ...installResult === "succeeded" ? [`cd ${JSON.stringify(relativeTarget)}`] : hitchGit ? [`cd ${JSON.stringify(relativeTarget)}`, "pnpm install"] : ["pnpm install", `cd ${JSON.stringify(relativeTarget)}`],
233
286
  ...generateSucceeded ? [] : ["pnpm exec applet generate"],
234
287
  "pnpm exec vite"
235
288
  ];
236
289
  console.log(`Applet created in ${relativeTarget}.\n\nNext steps:\n${nextSteps.map((step) => ` ${step}`).join("\n")}`);
237
290
  }
238
- //#endregion
239
291
  export { runBootstrap, runInit, runNew };
@@ -1,4 +1,4 @@
1
- //#region src/lazy-client.ts
1
+ // src/lazy-client.ts
2
2
  function createLazyClientProxy(build) {
3
3
  let client;
4
4
  const at = (path) => new Proxy(() => void 0, {
@@ -10,5 +10,4 @@ function createLazyClientProxy(build) {
10
10
  });
11
11
  return at([]);
12
12
  }
13
- //#endregion
14
13
  export { createLazyClientProxy as t };
@@ -1,14 +1,17 @@
1
- import { n as readWorkspaceConfig } from "./workspace-8yqXsvce.js";
1
+ import { c as validateRootManifest, i as findWorkspaceConfig, n as findAppletRoot, o as isRootLayout } from "./workspace-CtIKSgMD.js";
2
+ import { n as ORG_CODE_PATTERN, t as APPLET_CODE_PATTERN } from "./manifest-patterns-BfxqImlp.js";
2
3
  import { z } from "zod";
3
4
  import { existsSync } from "node:fs";
4
- import { basename, dirname, resolve } from "node:path";
5
+ import { resolve } from "node:path";
5
6
  import { loadConfigFromFile } from "vite";
6
7
  import { Cron } from "croner";
7
- //#region src/manifest-patterns.ts
8
- const APPLET_CODE_PATTERN = /^[a-z][a-z0-9]*(?:_[a-z0-9]+)*$/;
9
- const ORG_CODE_PATTERN = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/;
10
- //#endregion
11
- //#region src/manifest.ts
8
+ // src/workspace.ts
9
+ function resolveWorkspaceOrg(appletRoot) {
10
+ const config = findWorkspaceConfig(appletRoot);
11
+ if (config !== void 0) return config.org;
12
+ throw new Error(`No Hitch workspace found for ${appletRoot}. Expected applet.manifest.ts or hitch.config.ts.`);
13
+ }
14
+ // src/manifest.ts
12
15
  const RESERVED_ATTRIBUTE_CODES = /* @__PURE__ */ new Set([
13
16
  "id",
14
17
  "name",
@@ -124,6 +127,13 @@ const checkPublicFields = (manifest, context) => {
124
127
  }));
125
128
  };
126
129
  const appletManifestSchema = z.strictObject(appletManifestShape).superRefine(checkDuplicateCodes).superRefine(checkPublicFields);
130
+ function appletReleaseManifest(source, org) {
131
+ const { sdk: _sdk, org: _org, dependencies: _dependencies, devDependencies: _devDependencies, ...definition } = source;
132
+ return appletManifestSchema.parse({
133
+ org,
134
+ ...definition
135
+ });
136
+ }
127
137
  z.strictObject({
128
138
  name: appletManifestShape.name,
129
139
  code: appletManifestShape.code,
@@ -202,6 +212,8 @@ const checkSourcePackages = (manifest, context) => {
202
212
  });
203
213
  };
204
214
  const appletSourceDefinitionSchema = z.strictObject({
215
+ org: appletManifestShape.org.optional(),
216
+ sdk: z.string().optional(),
205
217
  name: appletManifestShape.name,
206
218
  code: appletManifestShape.code,
207
219
  requiresChangeset: appletManifestShape.requiresChangeset,
@@ -218,19 +230,9 @@ const appletSourceDefinitionSchema = z.strictObject({
218
230
  checkSourcePackages(manifest, context);
219
231
  checkPublicFields(manifest, context);
220
232
  });
221
- //#endregion
222
- //#region src/workspace.ts
223
- function resolveWorkspaceOrg(appletRoot) {
224
- const appletsDir = dirname(appletRoot);
225
- if (basename(appletsDir) === "applets") {
226
- const config = readWorkspaceConfig(dirname(appletsDir));
227
- if (config !== void 0) return config.org;
228
- }
229
- 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.`);
230
- }
231
- //#endregion
232
- //#region src/typegen/load-config.ts
233
+ // src/typegen/load-config.ts
233
234
  async function loadAppletSourceDefinition(root) {
235
+ root = findAppletRoot(root) ?? root;
234
236
  const path = resolve(root, "applet.manifest.ts");
235
237
  if (!existsSync(path)) throw new Error(`No applet manifest found at ${path}.`);
236
238
  const loaded = await loadConfigFromFile({
@@ -238,16 +240,12 @@ async function loadAppletSourceDefinition(root) {
238
240
  mode: "production"
239
241
  }, path, root);
240
242
  if (loaded === null) throw new Error(`No applet manifest found at ${path}.`);
243
+ if (isRootLayout(root)) validateRootManifest(loaded.config);
241
244
  const parsed = appletSourceDefinitionSchema.safeParse(loaded.config);
242
245
  if (!parsed.success) throw new Error(`Invalid applet manifest at ${loaded.path}: ${parsed.error.message}`);
243
246
  return parsed.data;
244
247
  }
245
248
  async function loadAppletConfig(root) {
246
- const { dependencies: _dependencies, devDependencies: _devDependencies, ...definition } = await loadAppletSourceDefinition(root);
247
- return {
248
- org: resolveWorkspaceOrg(root),
249
- ...definition
250
- };
249
+ return appletReleaseManifest(await loadAppletSourceDefinition(root), resolveWorkspaceOrg(root));
251
250
  }
252
- //#endregion
253
- export { appletMountPath as a, ORG_CODE_PATTERN as c, appletManifestSchema as i, loadAppletSourceDefinition as n, appletSourceDefinitionSchema as o, resolveWorkspaceOrg as r, APPLET_CODE_PATTERN as s, loadAppletConfig as t };
251
+ export { appletSourceDefinitionSchema as a, appletReleaseManifest as i, loadAppletSourceDefinition as n, resolveWorkspaceOrg as o, appletMountPath as r, loadAppletConfig as t };
@@ -1,5 +1,5 @@
1
1
  import { channel } from "node:diagnostics_channel";
2
- //#region src/server/log-context.ts
2
+ // src/server/log-context.ts
3
3
  const REQUEST_CONTEXT_CHANNEL = "hitch.request.context";
4
4
  const APP_CONTEXT_CHANNEL = "hitch.request.app";
5
5
  const isUuid = (value) => typeof value === "string" && /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(value);
@@ -65,5 +65,4 @@ function createNoteLog(initial) {
65
65
  publishNote(initial.requestId, initial);
66
66
  return log;
67
67
  }
68
- //#endregion
69
68
  export { errorNote as a, requestIdFrom as c, createNoteLog as i, REQUEST_CONTEXT_CHANNEL as n, isUuid as o, cloudflareRequestFields as r, publishNote as s, APP_CONTEXT_CHANNEL as t };
@@ -0,0 +1,21 @@
1
+ import { c as normalizeInstanceUrl, h as revokeOAuthCredentials, m as resolveInstanceUrl, s as deleteCredentials, t as AuthenticationError, u as readCredentialStore } from "./store-E5NhITHl.js";
2
+ import { t as loginWithDevice } from "./device-CZWWckCq.js";
3
+ import { i as findWorkspaceConfig } from "./workspace-CtIKSgMD.js";
4
+ // src/login.ts
5
+ async function runLogin(options) {
6
+ if (process.env.HITCH_API_KEY !== void 0) throw new AuthenticationError("HITCH_API_KEY is set — unset it to manage stored logins.");
7
+ const { me, membership } = await loginWithDevice(await resolveInstanceUrl(), {
8
+ expectedOrg: findWorkspaceConfig(process.cwd())?.org,
9
+ noBrowser: options.noBrowser
10
+ });
11
+ console.log(`Signed in as ${me.person.email} to ${membership.name}.`);
12
+ }
13
+ async function runLogout() {
14
+ if (process.env.HITCH_API_KEY !== void 0) throw new AuthenticationError("HITCH_API_KEY is set — unset it to manage stored logins.");
15
+ const instance = await resolveInstanceUrl();
16
+ const credentials = Object.values((await readCredentialStore()).instances[normalizeInstanceUrl(instance)] ?? {});
17
+ await Promise.all(credentials.filter((item) => item.type === "oauth").map((item) => revokeOAuthCredentials(instance, item)));
18
+ await deleteCredentials(instance);
19
+ console.log(`Logged out of ${instance}.`);
20
+ }
21
+ export { runLogin, runLogout };
@@ -1,8 +1,9 @@
1
- import { n as readWorkspaceConfig } from "./workspace-8yqXsvce.js";
2
- import { t as fetchWithOrgAuth } from "./auth-D3CrCtZq.js";
3
- import { r as resolveWorkspaceOrg, s as APPLET_CODE_PATTERN, t as loadAppletConfig } from "./load-config-DGALUExv.js";
1
+ import { s as readWorkspaceConfig } from "./workspace-CtIKSgMD.js";
2
+ import { n as fetchWithOrgAuth } from "./auth-DuMRqSGe.js";
3
+ import { o as resolveWorkspaceOrg, t as loadAppletConfig } from "./load-config-Cffvj-aM.js";
4
+ import { t as APPLET_CODE_PATTERN } from "./manifest-patterns-BfxqImlp.js";
4
5
  import { z } from "zod";
5
- //#region src/logs.ts
6
+ // src/logs.ts
6
7
  const LOG_LEVELS = [
7
8
  "debug",
8
9
  "log",
@@ -128,7 +129,7 @@ async function runLogs(options) {
128
129
  const startedAt = Date.now();
129
130
  const requestLogs = async (from, to) => {
130
131
  const response = await fetchWithOrgAuth(org, (instanceUrl, accessToken) => {
131
- const url = new URL(`/api/v1/applets/${encodeURIComponent(code)}/logs/query`, `${instanceUrl}/`);
132
+ const url = new URL(`/api/manage/v1/applets/${encodeURIComponent(code)}/logs/query`, `${instanceUrl}/`);
132
133
  const levelFilter = level === void 0 ? void 0 : { level: { $in: LOG_LEVELS.slice(LOG_LEVELS.indexOf(level)) } };
133
134
  return fetch(url, {
134
135
  method: "POST",
@@ -177,5 +178,4 @@ async function runLogs(options) {
177
178
  lastTimestamp = Math.max(lastTimestamp, ...logs.map(({ timestamp }) => timestamp));
178
179
  }
179
180
  }
180
- //#endregion
181
181
  export { runLogs };
@@ -1,8 +1,7 @@
1
- import { t as AnyWorkflowDefinition } from "./workflow-DurM6Fwx.js";
1
+ import { t as AnyWorkflowDefinition } from "./workflow-BnBrJIzu.js";
2
2
  import { AnyProcedure, AnyRouter, Lazy } from "@orpc/server";
3
3
  import { AnyContractRouter } from "@orpc/contract";
4
4
  import { z } from "zod";
5
- //#region src/hitch/registry.d.ts
6
5
  interface HitchRegister {}
7
6
  type RegisteredCatalog = HitchRegister extends {
8
7
  catalog: infer C;
@@ -26,8 +25,6 @@ type RegisteredWorkflows = HitchRegister extends {
26
25
  workflows: infer W extends Record<string, AnyWorkflowDefinition>;
27
26
  } ? W : Record<string, AnyWorkflowDefinition>;
28
27
  declare function registerHitchContract(contract: AnyContractRouter): void;
29
- //#endregion
30
- //#region src/manifest.d.ts
31
28
  interface AppletManifest {
32
29
  org: string;
33
30
  name: string;
@@ -69,7 +66,10 @@ interface AppletPackages {
69
66
  dependencies?: Readonly<Record<string, string>>;
70
67
  devDependencies?: Readonly<Record<string, string>>;
71
68
  }
72
- type AppletSourceDefinition = AppletDefinition & AppletPackages;
69
+ type AppletSourceDefinition = AppletDefinition & AppletPackages & {
70
+ org?: string;
71
+ sdk?: string;
72
+ };
73
73
  type RegisteredAppletManifestObject = { [Code in keyof RegisteredCatalog]: Omit<AppletManifestObject, "code" | "readOnly" | "readWrite"> & {
74
74
  code: Code;
75
75
  readOnly: readonly RegisteredCatalog[Code][];
@@ -95,6 +95,5 @@ type RegisteredAppletManifest = (RegisteredAppletManifestFields & {
95
95
  });
96
96
  type DistributiveOmit<T, K extends PropertyKey> = T extends unknown ? Omit<T, K> : never;
97
97
  type RegisteredAppletDefinition = DistributiveOmit<RegisteredAppletManifest, "org">;
98
- type RegisteredAppletSourceDefinition = RegisteredAppletDefinition & AppletPackages;
99
- //#endregion
98
+ type RegisteredAppletSourceDefinition = RegisteredAppletDefinition & AppletPackages & Pick<AppletSourceDefinition, "org" | "sdk">;
100
99
  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 };
@@ -0,0 +1,4 @@
1
+ // src/manifest-patterns.ts
2
+ const APPLET_CODE_PATTERN = /^[a-z][a-z0-9]*(?:_[a-z0-9]+)*$/;
3
+ const ORG_CODE_PATTERN = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/;
4
+ export { ORG_CODE_PATTERN as n, APPLET_CODE_PATTERN as t };