@vite-hub/workflow 0.0.3 → 0.1.0

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 (47) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +187 -56
  3. package/dist/{_app-DgwN4ulW.d.ts → app-BojnC_yf.d.ts} +1 -4
  4. package/dist/{app-BZpq2cwC.js → app-CzPoP84f.js} +2 -1
  5. package/dist/client-DsGM3M4U.js +389 -0
  6. package/dist/cloudflare-env-BNrYo29x.js +113 -0
  7. package/dist/cloudflare-nF4abPd4.js +59 -0
  8. package/dist/cloudflare-shared-CaxrMD1A.d.ts +1 -0
  9. package/dist/{cloudflare-vite-B0zel2Do.js → cloudflare-vite-B3IabBsv.js} +18 -10
  10. package/dist/{config-BDqB6I4E.js → config-IJMb0eeZ.js} +39 -25
  11. package/dist/error-diagnostics-A_8Kp-48.js +116 -0
  12. package/dist/error-diagnostics-pwNFvAHP.js +67 -0
  13. package/dist/index.d.ts +24 -20
  14. package/dist/index.js +25 -334
  15. package/dist/inspect-B72iFyj-.js +70 -0
  16. package/dist/operations-B_rYG71W.js +230 -0
  17. package/dist/operations-tNUdj3G4.d.ts +212 -0
  18. package/dist/operations.d.ts +37 -0
  19. package/dist/operations.js +887 -0
  20. package/dist/out-CsaJxg8m.js +21755 -0
  21. package/dist/{provider-operation-CWIV4k42.js → provider-operation-CW2cYfVy.js} +13 -10
  22. package/dist/rolldown-runtime-CMFfr-1z.js +26 -0
  23. package/dist/runtime/cloudflare-runner.d.ts +8 -14
  24. package/dist/runtime/cloudflare-runner.js +77 -14
  25. package/dist/runtime/cloudflare-shared.d.ts +1 -0
  26. package/dist/runtime/cloudflare-shared.js +1 -1
  27. package/dist/runtime/cloudflare-vite.d.ts +8 -9
  28. package/dist/runtime/cloudflare-vite.js +2 -2
  29. package/dist/runtime/execute.d.ts +8 -7
  30. package/dist/runtime/execute.js +28 -5
  31. package/dist/runtime/openworkflow-worker.d.ts +6 -8
  32. package/dist/runtime/openworkflow-worker.js +43 -6
  33. package/dist/runtime/openworkflow.d.ts +8 -10
  34. package/dist/runtime/openworkflow.js +50 -32
  35. package/dist/runtime/state.d.ts +20 -21
  36. package/dist/runtime/state.js +90 -20
  37. package/dist/runtime/vercel-vite.d.ts +10 -11
  38. package/dist/runtime/vercel-vite.js +11 -8
  39. package/dist/runtime-type-DBCvIh5x.js +7 -0
  40. package/dist/{types-BUlYBZwH.d.ts → types-D82WmfZa.d.ts} +35 -18
  41. package/dist/{vercel-D2_J5D_Y.js → vercel-D-ZNtB_u.js} +59 -26
  42. package/dist/vite.d.ts +365 -6
  43. package/dist/vite.js +4667 -910
  44. package/package.json +78 -28
  45. package/dist/cloudflare-Cds1VIWa.js +0 -42
  46. package/dist/cloudflare-env-mFp2Uj6Z.js +0 -53
  47. package/dist/cloudflare-shared-BVVgDSdq.d.ts +0 -1
package/dist/vite.d.ts CHANGED
@@ -1,13 +1,372 @@
1
- import { y as WorkflowModuleOptions } from "./types-BUlYBZwH.js";
2
- import { Plugin } from "vite";
3
-
1
+ import { i as DiscoveredWorkflowDefinition, y as WorkflowModuleOptions } from "./types-D82WmfZa.js";
2
+ import { n as OperationContributionEntry } from "./operations-tNUdj3G4.js";
3
+ import { Plugin } from "esbuild";
4
+ import { Plugin as Plugin$1, ResolvedConfig } from "vite";
5
+ //#region ../internal/src/inspect.d.ts
6
+ interface ViteHubDefinitionField {
7
+ label: string;
8
+ value: string;
9
+ }
10
+ /** Serializable summary of one discovered Definition. Files are relative to the project root. */
11
+ interface ViteHubDefinitionSummary {
12
+ fields: readonly ViteHubDefinitionField[];
13
+ file: string;
14
+ name: string;
15
+ source: string;
16
+ }
17
+ /** Lists the Definitions that one owner package discovered for the resolved Vite config. */
18
+ interface ViteHubDefinitionInspector {
19
+ /** Stable singular kind, for example `queue` or `rate-limit`. */
20
+ kind: string;
21
+ label: string;
22
+ list: () => Promise<readonly ViteHubDefinitionSummary[]> | readonly ViteHubDefinitionSummary[];
23
+ }
24
+ /** One generated Provider Output file or directory that an owner package can write. */
25
+ interface ViteHubProviderOutputEntry {
26
+ description: string;
27
+ owner: string;
28
+ /** Absolute path. */
29
+ path: string;
30
+ }
31
+ interface ViteHubInspectionContributor {
32
+ definitions?: readonly ViteHubDefinitionInspector[];
33
+ providerOutput?: readonly ViteHubProviderOutputEntry[];
34
+ }
35
+ type ViteHubInspectionContributorFactory = () => ViteHubInspectionContributor | undefined | Promise<ViteHubInspectionContributor | undefined>;
36
+ interface ViteHubInspectionPluginMetadata {
37
+ inspect?: ViteHubInspectionContributor | ViteHubInspectionContributorFactory;
38
+ }
39
+ //#endregion
40
+ //#region src/discovery.d.ts
41
+ export declare function discoverWorkflowDefinitions(options: {
42
+ mode?: "vite-suffix";
43
+ rootDir: string;
44
+ scanDirs?: string[];
45
+ serverDirs?: string[];
46
+ } | {
47
+ mode: "server-workflows";
48
+ scanDirs: string[];
49
+ }): DiscoveredWorkflowDefinition[];
50
+ //#endregion
51
+ //#region ../internal/src/console.d.ts
52
+ type MaybePromise<T> = T | Promise<T>;
53
+ /** Lists discovered Definitions in a sidebar and shows the selected Definition's fields. */
54
+ interface ViteHubConsoleDefinitionCatalogView {
55
+ kind: "definition-catalog";
56
+ /** States which runtime data this catalog does not include. */
57
+ notice: string;
58
+ }
59
+ interface ViteHubConsoleRecordColumn {
60
+ /** Key in `ViteHubConsoleRecord.cells`. */
61
+ key: string;
62
+ label: string;
63
+ }
64
+ /** Shows records in a table and the selected record's fields in a detail panel. */
65
+ interface ViteHubConsoleRecordTableView {
66
+ columns: readonly ViteHubConsoleRecordColumn[];
67
+ kind: "record-table";
68
+ /** States the source and limits of the records. */
69
+ notice: string;
70
+ }
71
+ /**
72
+ * Lists the collections and documents of an owner runtime and edits them with owner actions: a form generated from each
73
+ * collection's JSON Schema, a Markdown body, save, publish, and revision history.
74
+ */
75
+ interface ViteHubConsoleDocumentEditorView {
76
+ kind: "document-editor";
77
+ /** States where documents are stored and what the editor does not do. */
78
+ notice: string;
79
+ }
80
+ interface ViteHubConsoleOperationColumn {
81
+ /** Dot path into each item of the result, such as `author.name` or `messages.0.body`. */
82
+ key: string;
83
+ label: string;
84
+ /** `datetime` shows a time in milliseconds since the epoch as a date. `excerpt` cuts a long text. */
85
+ format?: "datetime" | "excerpt";
86
+ }
87
+ /** A chip above the list. Choosing it merges `input` into the operation input. The first chip is the default. */
88
+ interface ViteHubConsoleOperationFilter {
89
+ id: string;
90
+ label: string;
91
+ input: Readonly<Record<string, unknown>>;
92
+ }
93
+ /**
94
+ * Lists the items that an operation returns, called over the Console RPC with the signed-in Console user. The operation
95
+ * checks the access of that user for each item, so the view shows only what the user may read. `operation` must return an
96
+ * array of objects with an `id`. A failure of the operation, with its `fix`, shows where the list would be.
97
+ */
98
+ interface ViteHubConsoleOperationView {
99
+ columns: readonly ViteHubConsoleOperationColumn[];
100
+ filters?: readonly ViteHubConsoleOperationFilter[];
101
+ kind: "operation-view";
102
+ /**
103
+ * Makes each row a link: `{path}` placeholders take values from the item and are URL-encoded, and `{path:path}` takes an
104
+ * app path and encodes each segment (a value that is not an app path, such as `//evil.com/x`, gives no link). Rows where
105
+ * `when.path` is not `when.equals` get none.
106
+ */
107
+ link?: {
108
+ label?: string;
109
+ template: string;
110
+ when?: {
111
+ equals: string;
112
+ path: string;
113
+ };
114
+ };
115
+ notice: string;
116
+ /** Operation name, such as `comments.list`. */
117
+ operation: string;
118
+ /** Fetch every page with `limit` and a `before` object whose keys read these dot paths from the last item. */
119
+ pagination?: {
120
+ limit: number;
121
+ cursor: Readonly<Record<string, string>>;
122
+ };
123
+ }
124
+ interface ViteHubConsoleAuthView {
125
+ kind: "auth-management";
126
+ notice: string;
127
+ }
128
+ interface ViteHubConsoleAuthSection extends ViteHubConsoleSectionDescriptor<ViteHubConsoleAuthView> {}
129
+ type ViteHubConsoleSectionView = ViteHubConsoleOperationView | ViteHubConsoleAuthView | ViteHubConsoleDefinitionCatalogView | ViteHubConsoleRecordTableView | ViteHubConsoleDocumentEditorView;
130
+ /**
131
+ * The overview of a document editor section: document counts by state, the changes that wait for a publish, recent
132
+ * activity, and a New button per collection. It reads the owner `overview` action.
133
+ */
134
+ interface ViteHubConsoleDocumentDashboardView {
135
+ kind: "document-dashboard";
136
+ }
137
+ /**
138
+ * The media library of a document editor section: folders, uploads, alt text, focal points, and crops of the Blob Store
139
+ * that `blob.serve` serves. The owner decides who may use it with `mediaAccess`, and finds the documents that use a file
140
+ * with `references`. The page needs the Blob section, so declare it with `requires: ["blob"]`.
141
+ */
142
+ interface ViteHubConsoleMediaLibraryView {
143
+ kind: "media-library";
144
+ }
145
+ /**
146
+ * The singletons of a document editor section, such as site settings: one row per singleton that opens it in the
147
+ * editor. Singletons appear here instead of among the collections, and the Console hides the page when the section has
148
+ * none.
149
+ */
150
+ interface ViteHubConsoleDocumentSettingsView {
151
+ kind: "document-settings";
152
+ }
153
+ /** A view that the Console UI in `vite-hub` renders for a section page. */
154
+ type ViteHubConsoleSectionPageView = ViteHubConsoleDocumentDashboardView | ViteHubConsoleDocumentSettingsView | ViteHubConsoleMediaLibraryView;
155
+ /**
156
+ * A page of a section next to its main view, such as the Content dashboard or media library. The section sidebar lists
157
+ * the pages, and each page has its own URL:
158
+ *
159
+ * - `/_vitehub/<section>` serves the `index` page, or the main view when the section has none.
160
+ * - `/_vitehub/<section>/-/<page>` serves every other page. The `-` segment keeps page URLs apart from the main view's
161
+ * own segments, such as a collection name.
162
+ *
163
+ * Pages share the access of their section: `console.authorize` that allows the section allows every page of it.
164
+ */
165
+ interface ViteHubConsoleSectionPage {
166
+ /** Lowercase route segment, for example `media`. */
167
+ id: string;
168
+ /** Display name, for example `Media`. */
169
+ label: string;
170
+ /** Iconify class name, for example `i-lucide-image`. */
171
+ icon: string;
172
+ view: ViteHubConsoleSectionPageView;
173
+ /**
174
+ * Serve this page at the section root. At most one page sets it, and `/_vitehub/<section>/-/<id>` then redirects to
175
+ * the root.
176
+ */
177
+ index?: boolean;
178
+ /**
179
+ * Sidebar heading, for example `Assets`. Pages without a group lead the sidebar, above the main view's navigation.
180
+ * Grouped pages follow it, in the order their group first appears.
181
+ */
182
+ group?: string;
183
+ /** Section ids that the project must enable, such as `["blob"]`. The Console leaves the page out otherwise. */
184
+ requires?: readonly string[];
185
+ }
186
+ /** One entry of a record's activity, such as a comment in a thread. `at` is an ISO 8601 timestamp. */
187
+ interface ViteHubConsoleRecordActivity {
188
+ author: string;
189
+ at: string;
190
+ text: string;
191
+ }
192
+ /** One serializable record row. Values are display strings. Do not put credentials in records. */
193
+ interface ViteHubConsoleRecord {
194
+ cells: Readonly<Record<string, string>>;
195
+ fields: readonly ViteHubDefinitionField[];
196
+ id: string;
197
+ /** The Console can run this record when it represents a runnable Schedule Definition. */
198
+ runnable?: boolean;
199
+ /**
200
+ * Where the record lives in the app, such as the page of a comment thread. `href` is an app path that starts with one
201
+ * `/`, or an `https:` URL. The Console opens it in a new tab.
202
+ */
203
+ link?: {
204
+ href: string;
205
+ label: string;
206
+ };
207
+ /** Entries in time order, such as the comments of a thread. The Console shows them as a conversation. */
208
+ activity?: readonly ViteHubConsoleRecordActivity[];
209
+ }
210
+ /** Serializable description of a Console section. The Console UI in `vite-hub` renders the view. */
211
+ interface ViteHubConsoleSectionDescriptor<TView extends ViteHubConsoleSectionView = ViteHubConsoleSectionView> {
212
+ description: string;
213
+ /**
214
+ * Iconify class name, for example `i-lucide-inbox`. The Console draws with Lucide; `ph` also resolves. The
215
+ * Console build bundles the icon of every section in the `vite-hub` Console registry and fails if it cannot resolve one.
216
+ */
217
+ icon: string;
218
+ /** Lowercase route segment, for example `queues`. The Console serves the section at `/_vitehub/<id>`. */
219
+ id: string;
220
+ /** Plural display name, for example `Queues`. */
221
+ label: string;
222
+ view: TView;
223
+ /** Pages next to the main view, in sidebar order. Only document editor sections render pages today. */
224
+ pages?: readonly ViteHubConsoleSectionPage[];
225
+ }
226
+ interface ViteHubConsoleDefinitionCatalogSection<TOptions = void> extends ViteHubConsoleSectionDescriptor<ViteHubConsoleDefinitionCatalogView> {
227
+ /** Reads the section data on the server. The Console never runs it in the browser. */
228
+ read: (options: TOptions) => MaybePromise<readonly ViteHubDefinitionSummary[]>;
229
+ }
230
+ interface ViteHubConsoleRecordTableSection<TOptions = void> extends ViteHubConsoleSectionDescriptor<ViteHubConsoleRecordTableView> {
231
+ /** Reads the section data on the server. The Console never runs it in the browser. */
232
+ read: (options: TOptions) => MaybePromise<readonly ViteHubConsoleRecord[]>;
233
+ }
234
+ /** A named export of an owner package server module that the host imports in its generated server code. */
235
+ interface ViteHubConsoleServerExport {
236
+ /** Named export of `module`. */
237
+ export: string;
238
+ /**
239
+ * Owner package module specifier, for example `@vite-hub/email/runtime/console`. The host maps it to the module
240
+ * path that the application can import.
241
+ */
242
+ module: string;
243
+ }
244
+ /**
245
+ * Server module export that returns records on each Console request. The export must be a
246
+ * {@link ViteHubConsoleRuntimeRecordReader}.
247
+ */
248
+ interface ViteHubConsoleRuntimeReader extends ViteHubConsoleServerExport {}
249
+ /**
250
+ * A record table that also reads records at request time. The Console shows the build-time records of `read` first,
251
+ * then the records of the `runtime` reader. A runtime record replaces a build-time record with the same id.
252
+ */
253
+ interface ViteHubConsoleRuntimeRecordTableSection<TOptions = void> extends ViteHubConsoleSectionDescriptor<ViteHubConsoleRecordTableView> {
254
+ /** Reads build-time records on the server. When omitted, the section has only runtime records. */
255
+ read?: (options: TOptions) => MaybePromise<readonly ViteHubConsoleRecord[]>;
256
+ runtime: ViteHubConsoleRuntimeReader;
257
+ /**
258
+ * Returns the absolute path of the application module that turns the section on, such as `server/comments.ts`, or
259
+ * `undefined` when the project has none. With it, the host shows the section only when the module exists; without
260
+ * it, a Vite option enables the section.
261
+ */
262
+ entry?: (options: TOptions) => MaybePromise<string | undefined>;
263
+ }
264
+ /** A section whose list comes from an operation, called with the Console user on each visit. It has no build-time data. */
265
+ interface ViteHubConsoleOperationSection extends ViteHubConsoleSectionDescriptor<ViteHubConsoleOperationView> {}
266
+ /**
267
+ * A document editor section. The owner finds the application module that holds its runtime, such as `server/content.ts`,
268
+ * and names the server export that turns that module into {@link ViteHubConsoleDocumentActions}. The host shows the
269
+ * section only when `entry` finds a module, imports the module on the first Console request, and checks the Console
270
+ * section before it calls an action. The owner actions check their own access policy for the signed-in user.
271
+ */
272
+ interface ViteHubConsoleDocumentEditorSection<TOptions = void> extends ViteHubConsoleSectionDescriptor<ViteHubConsoleDocumentEditorView> {
273
+ /** Returns the absolute path of the application module, or `undefined` when the project has none. */
274
+ entry: (options: TOptions) => MaybePromise<string | undefined>;
275
+ /**
276
+ * Reads, at build time and without running the application, what the project lacks for some editor features, such as
277
+ * a runner for scheduled publishes. The Console merges it with the owner `setup` action on each request.
278
+ */
279
+ inspect?: (options: TOptions, entry: string) => MaybePromise<ViteHubConsoleDocumentSetup>;
280
+ /** Owner export that must be a {@link ViteHubConsoleDocumentActionsFactory}. */
281
+ actions: ViteHubConsoleServerExport;
282
+ }
283
+ /**
284
+ * A Console section that an owner package contributes. The owner defines the label, icon, view, and data reader.
285
+ * `TOptions` is the discovery context that the host passes to `read`.
286
+ */
287
+ type ViteHubConsoleSectionContribution<TOptions = void> = ViteHubConsoleAuthSection | ViteHubConsoleDefinitionCatalogSection<TOptions> | ViteHubConsoleRecordTableSection<TOptions> | ViteHubConsoleRuntimeRecordTableSection<TOptions> | ViteHubConsoleDocumentEditorSection<TOptions> | ViteHubConsoleOperationSection;
288
+ /** A fix that the owner names for a feature the project lacks, such as `Add authorize to defineContent().` */
289
+ interface ViteHubConsoleDocumentHint {
290
+ /** One sentence that names the fix. Text in backticks shows as code. */
291
+ message: string;
292
+ /** Absolute URL of the documentation for the fix. */
293
+ docs?: string;
294
+ }
295
+ /**
296
+ * What the project lacks for some editor features. The editor names each fix where the feature would be, instead of
297
+ * failing without a reason.
298
+ */
299
+ interface ViteHubConsoleDocumentSetup {
300
+ /** Present when no user can read anything because the owner has no access policy. */
301
+ access?: ViteHubConsoleDocumentHint;
302
+ /**
303
+ * Live co-editing. `definition` names the Realtime Definition whose rooms are `<collection>/<id>`; the editor joins
304
+ * the room of a Markdown document instead of taking the edit lease. `unavailable` names why the owner wanted live
305
+ * editing and the host cannot run it, such as a host without a Realtime authority. Absent when live editing is off.
306
+ */
307
+ live?: {
308
+ definition: string;
309
+ } | {
310
+ unavailable: string;
311
+ };
312
+ /**
313
+ * Present when nothing runs scheduled publishes. The editor disables Schedule, and overdue schedules name the fix.
314
+ */
315
+ schedule?: ViteHubConsoleDocumentHint;
316
+ }
317
+ //#endregion
318
+ //#region src/inspect.d.ts
319
+ interface WorkflowInspectionOptions {
320
+ projectRoot: string;
321
+ rootDir: string;
322
+ serverDirs?: string[];
323
+ }
324
+ /** Lists user-facing Workflow Definitions. Generated Agent recovery Workflows are internal and stay hidden. */
325
+ export declare function inspectWorkflowDefinitions(options: WorkflowInspectionOptions): ViteHubDefinitionSummary[];
326
+ /** Console section that lists discovered Workflow Definitions. `vitehub inspect definitions` reads the same data. */
327
+ export declare const workflowConsoleSection: ViteHubConsoleSectionContribution<WorkflowInspectionOptions>;
328
+ //#endregion
4
329
  //#region src/vite.d.ts
5
- type WorkflowVitePlugin = Plugin;
6
- declare function hubWorkflow(options?: WorkflowModuleOptions): WorkflowVitePlugin;
330
+ interface WorkflowNitroConfigOptions {
331
+ nitro: Record<string, unknown>;
332
+ projectRoot: string;
333
+ serverDirs?: string[];
334
+ transformRegistry?: (code: string, id: string) => string | Promise<string>;
335
+ }
336
+ export type WorkflowVitePlugin = Plugin$1 & {
337
+ vitehub?: ViteHubInspectionPluginMetadata & {
338
+ operations?: readonly OperationContributionEntry[];
339
+ workflow?: {
340
+ createNitroConfig?: (options: WorkflowNitroConfigOptions) => Promise<Record<string, unknown>>;
341
+ prepareScheduleRuntime?: (artifactDir?: string, config?: ResolvedConfig) => Promise<{
342
+ bundleAlias: Record<string, string>;
343
+ bundlePlugins?: Plugin[];
344
+ importBase: string;
345
+ native: boolean;
346
+ registryFile: string;
347
+ } | undefined>;
348
+ };
349
+ };
350
+ };
351
+ interface InternalWorkflowModuleOptions {
352
+ agentImportBase?: string;
353
+ hosting?: string;
354
+ implicitlyEnabled?: boolean;
355
+ importBase?: string;
356
+ providerImportAliases?: Record<string, string>;
357
+ includeUserAppEntry?: boolean;
358
+ workspaceDependencyRuntimeImports?: {
359
+ sandboxTask?: string;
360
+ sandboxTaskRuntimeState?: string;
361
+ shellWorkspace?: string;
362
+ };
363
+ workspaceImportBase?: string;
364
+ }
365
+ export declare function hubWorkflow(options?: WorkflowModuleOptions, internalOptions?: InternalWorkflowModuleOptions): WorkflowVitePlugin;
7
366
  declare module "vite" {
8
367
  interface UserConfig {
9
368
  workflow?: WorkflowModuleOptions;
10
369
  }
11
370
  }
12
371
  //#endregion
13
- export { WorkflowVitePlugin, hubWorkflow };
372
+ export type { WorkflowInspectionOptions };