@protobase/server 0.67.8 → 0.67.10

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 (44) hide show
  1. package/dist/config-exports.d.ts +2 -1
  2. package/dist/config-exports.js +2 -1
  3. package/dist/create-admin.d.ts +4 -1
  4. package/dist/create-admin.js +11 -2
  5. package/dist/index.d.ts +7 -1
  6. package/dist/index.js +6 -1
  7. package/dist/internal.d.ts +2 -1
  8. package/dist/internal.js +2 -1
  9. package/dist/mcp/mcp-tools.d.ts +8 -2
  10. package/dist/mcp/mcp-tools.js +10 -3
  11. package/dist/package.js +1 -1
  12. package/dist/webhooks/attempt.js +2 -2
  13. package/dist/webhooks/table/webhook-table.js +1 -1
  14. package/dist/workflows/http-step.js +103 -0
  15. package/dist/workflows/input-limits.js +22 -0
  16. package/dist/workflows/mail-step.js +58 -0
  17. package/dist/workflows/mcp/merge-patch.js +15 -0
  18. package/dist/workflows/mcp/type-catalog.js +144 -0
  19. package/dist/workflows/mcp/workflow-instructions.d.ts +7 -0
  20. package/dist/workflows/mcp/workflow-instructions.js +77 -0
  21. package/dist/workflows/mcp/workflow-read-tools.d.ts +6 -0
  22. package/dist/workflows/mcp/workflow-read-tools.js +209 -0
  23. package/dist/workflows/mcp/workflow-tool-args.js +35 -0
  24. package/dist/workflows/mcp/workflow-write-tools.d.ts +7 -0
  25. package/dist/workflows/mcp/workflow-write-tools.js +149 -0
  26. package/dist/workflows/options.d.ts +27 -0
  27. package/dist/workflows/options.js +19 -0
  28. package/dist/workflows/piece-step.js +11 -0
  29. package/dist/workflows/records-step.js +114 -0
  30. package/dist/workflows/run-files.js +70 -0
  31. package/dist/workflows/save-hook.js +20 -0
  32. package/dist/workflows/schema-sql.js +147 -0
  33. package/dist/workflows/schema.d.ts +11 -0
  34. package/dist/workflows/schema.js +41 -0
  35. package/dist/workflows/segment-job.js +51 -0
  36. package/dist/workflows/start-hook.js +26 -0
  37. package/dist/workflows/start-workflow.d.ts +26 -0
  38. package/dist/workflows/start-workflow.js +28 -0
  39. package/dist/workflows/step-types.js +34 -0
  40. package/dist/workflows/store.js +42 -0
  41. package/dist/workflows/workflow-engine.js +37 -0
  42. package/dist/workflows/workflows-module.d.ts +124 -0
  43. package/dist/workflows/workflows-module.js +11 -0
  44. package/package.json +5 -4
@@ -0,0 +1,37 @@
1
+ import { stepTypeNames, stepTypes } from "./step-types.js";
2
+ import { betterAuthOwnerRoles } from "../webhooks/table/owner-roles.js";
3
+ import { runInputCheck } from "./input-limits.js";
4
+ import { workflowSecrets, workflowsSchema } from "./options.js";
5
+ import { workflowSaveHook } from "./save-hook.js";
6
+ import { workflowsRunner } from "./segment-job.js";
7
+ import { runStartHook } from "./start-hook.js";
8
+ //#region src/workflows/workflow-engine.ts
9
+ /**
10
+ * What `createAdmin` needs for `workflows`: the hooks that check saves and start runs, the check of a run's input before
11
+ * it is validated, and the segment job, whose step
12
+ * types act on records as each workflow's last editor (from Better Auth unless the options say otherwise).
13
+ */
14
+ const workflowEngine = (options, deps, auth) => {
15
+ const schema = workflowsSchema(options);
16
+ const roles = options.savedByRoles ?? (auth && betterAuthOwnerRoles(auth));
17
+ if (!roles) throw new Error("workflows act on records as each workflow's last editor, with their current roles: give the config `auth` (Better Auth), or `workflows.savedByRoles`");
18
+ const input = {
19
+ deps,
20
+ schema,
21
+ roles,
22
+ allowPrivateAddresses: Boolean(options.allowPrivateAddresses)
23
+ };
24
+ const secrets = workflowSecrets(options, globalThis.process?.env ?? {});
25
+ const { runner, job } = workflowsRunner({
26
+ schema,
27
+ tasks: (context) => stepTypes(input, context.mail),
28
+ secrets
29
+ });
30
+ return {
31
+ hooks: [workflowSaveHook(schema, stepTypeNames), runStartHook(runner, deps)],
32
+ writeChecks: [runInputCheck],
33
+ job
34
+ };
35
+ };
36
+ //#endregion
37
+ export { workflowEngine };
@@ -0,0 +1,124 @@
1
+ import { WorkflowsOptions } from "./options.js";
2
+ //#region src/workflows/workflows-module.d.ts
3
+ /**
4
+ * What `workflows` in `protobase.config.ts` adds to the app's resources: Workflows, their versions, runs and steps,
5
+ * over a `workflows` schema that `protobase migration` writes. Who may make, change and run them and read their runs
6
+ * is the resources' access (`workflows.create`, `workflow_runs.create`, `workflow_steps.read`, ...).
7
+ */
8
+ export declare const workflowsModule: (options?: WorkflowsOptions) => {
9
+ workflows: import("@protobase/schema").ResourceBuilder<{
10
+ readonly id: import("@protobase/schema").Field<string>;
11
+ readonly name: import("@protobase/schema").Field<string>;
12
+ readonly description: import("@protobase/schema").Field<string | null>;
13
+ readonly definition: import("@protobase/schema").Field<import("zod").JSONType>;
14
+ readonly version: import("@protobase/schema").Field<number | null>;
15
+ readonly tenant_id: import("@protobase/schema").Field<string | null>;
16
+ readonly created_at: import("@protobase/schema").Field<string>;
17
+ readonly updated_at: import("@protobase/schema").Field<string>;
18
+ }, import("@protobase/schema").Ref<"id", string>>;
19
+ workflowsView: import("@protobase/schema").ViewBuilder<import("@protobase/schema").ResourceBuilder<{
20
+ readonly id: import("@protobase/schema").Field<string>;
21
+ readonly name: import("@protobase/schema").Field<string>;
22
+ readonly description: import("@protobase/schema").Field<string | null>;
23
+ readonly definition: import("@protobase/schema").Field<import("zod").JSONType>;
24
+ readonly version: import("@protobase/schema").Field<number | null>;
25
+ readonly tenant_id: import("@protobase/schema").Field<string | null>;
26
+ readonly created_at: import("@protobase/schema").Field<string>;
27
+ readonly updated_at: import("@protobase/schema").Field<string>;
28
+ }, import("@protobase/schema").Ref<"id", string>>>;
29
+ workflowVersions: import("@protobase/schema").ResourceBuilder<{
30
+ readonly workflow_id: import("@protobase/schema").Field<string | number>;
31
+ readonly version: import("@protobase/schema").Field<number>;
32
+ readonly definition: import("@protobase/schema").Field<import("zod").JSONType>;
33
+ readonly saved_by: import("@protobase/schema").Field<string | null>;
34
+ readonly tenant_id: import("@protobase/schema").Field<string | null>;
35
+ readonly saved_at: import("@protobase/schema").Field<string>;
36
+ }, readonly [import("@protobase/schema").Ref<"workflow_id", string | number>, import("@protobase/schema").Ref<"version", number>]>;
37
+ workflowVersionsView: import("@protobase/schema").ViewBuilder<import("@protobase/schema").ResourceBuilder<{
38
+ readonly workflow_id: import("@protobase/schema").Field<string | number>;
39
+ readonly version: import("@protobase/schema").Field<number>;
40
+ readonly definition: import("@protobase/schema").Field<import("zod").JSONType>;
41
+ readonly saved_by: import("@protobase/schema").Field<string | null>;
42
+ readonly tenant_id: import("@protobase/schema").Field<string | null>;
43
+ readonly saved_at: import("@protobase/schema").Field<string>;
44
+ }, readonly [import("@protobase/schema").Ref<"workflow_id", string | number>, import("@protobase/schema").Ref<"version", number>]>>;
45
+ workflowRuns: import("@protobase/schema").ResourceBuilder<{
46
+ readonly id: import("@protobase/schema").Field<string>;
47
+ readonly workflow_id: import("@protobase/schema").Field<string | number>;
48
+ readonly version: import("@protobase/schema").Field<number | null>;
49
+ readonly input: import("@protobase/schema").Field<import("zod").JSONType>;
50
+ readonly key: import("@protobase/schema").Field<string | null>;
51
+ readonly status: import("@protobase/schema").Field<"waiting" | "failed" | "queued" | "running" | "succeeded">;
52
+ readonly output: import("@protobase/schema").Field<import("zod").JSONType>;
53
+ readonly error: import("@protobase/schema").Field<string | null>;
54
+ readonly cause: import("@protobase/schema").Field<string | null>;
55
+ readonly resume_at: import("@protobase/schema").Field<string | null>;
56
+ readonly started_by: import("@protobase/schema").Field<string | null>;
57
+ readonly tenant_id: import("@protobase/schema").Field<string | null>;
58
+ readonly created_at: import("@protobase/schema").Field<string>;
59
+ readonly finished_at: import("@protobase/schema").Field<string | null>;
60
+ readonly duration_ms: import("@protobase/schema").Field<string | null>;
61
+ }, import("@protobase/schema").Ref<"id", string>>;
62
+ workflowRunsView: import("@protobase/schema").ViewBuilder<import("@protobase/schema").ResourceBuilder<{
63
+ readonly id: import("@protobase/schema").Field<string>;
64
+ readonly workflow_id: import("@protobase/schema").Field<string | number>;
65
+ readonly version: import("@protobase/schema").Field<number | null>;
66
+ readonly input: import("@protobase/schema").Field<import("zod").JSONType>;
67
+ readonly key: import("@protobase/schema").Field<string | null>;
68
+ readonly status: import("@protobase/schema").Field<"waiting" | "failed" | "queued" | "running" | "succeeded">;
69
+ readonly output: import("@protobase/schema").Field<import("zod").JSONType>;
70
+ readonly error: import("@protobase/schema").Field<string | null>;
71
+ readonly cause: import("@protobase/schema").Field<string | null>;
72
+ readonly resume_at: import("@protobase/schema").Field<string | null>;
73
+ readonly started_by: import("@protobase/schema").Field<string | null>;
74
+ readonly tenant_id: import("@protobase/schema").Field<string | null>;
75
+ readonly created_at: import("@protobase/schema").Field<string>;
76
+ readonly finished_at: import("@protobase/schema").Field<string | null>;
77
+ readonly duration_ms: import("@protobase/schema").Field<string | null>;
78
+ }, import("@protobase/schema").Ref<"id", string>>>;
79
+ workflowSteps: import("@protobase/schema").ResourceBuilder<{
80
+ readonly id: import("@protobase/schema").Field<string>;
81
+ readonly run_id: import("@protobase/schema").Field<string | number>;
82
+ readonly tenant_id: import("@protobase/schema").Field<string | null>;
83
+ readonly scope: import("@protobase/schema").Field<string>;
84
+ readonly seq: import("@protobase/schema").Field<number>;
85
+ readonly state: import("@protobase/schema").Field<string>;
86
+ readonly type: import("@protobase/schema").Field<string>;
87
+ readonly status: import("@protobase/schema").Field<"failed" | "succeeded" | "retrying" | "caught">;
88
+ readonly attempt: import("@protobase/schema").Field<number>;
89
+ readonly input: import("@protobase/schema").Field<import("zod").JSONType>;
90
+ readonly output: import("@protobase/schema").Field<import("zod").JSONType>;
91
+ readonly assigned: import("@protobase/schema").Field<import("zod").JSONType>;
92
+ readonly next: import("@protobase/schema").Field<string | null>;
93
+ readonly resume_at: import("@protobase/schema").Field<string | null>;
94
+ readonly error: import("@protobase/schema").Field<string | null>;
95
+ readonly cause: import("@protobase/schema").Field<string | null>;
96
+ readonly logs: import("@protobase/schema").Field<import("zod").JSONType>;
97
+ readonly started_at: import("@protobase/schema").Field<string>;
98
+ readonly finished_at: import("@protobase/schema").Field<string>;
99
+ readonly duration_ms: import("@protobase/schema").Field<string | null>;
100
+ }, import("@protobase/schema").Ref<"id", string>>;
101
+ workflowStepsView: import("@protobase/schema").ViewBuilder<import("@protobase/schema").ResourceBuilder<{
102
+ readonly id: import("@protobase/schema").Field<string>;
103
+ readonly run_id: import("@protobase/schema").Field<string | number>;
104
+ readonly tenant_id: import("@protobase/schema").Field<string | null>;
105
+ readonly scope: import("@protobase/schema").Field<string>;
106
+ readonly seq: import("@protobase/schema").Field<number>;
107
+ readonly state: import("@protobase/schema").Field<string>;
108
+ readonly type: import("@protobase/schema").Field<string>;
109
+ readonly status: import("@protobase/schema").Field<"failed" | "succeeded" | "retrying" | "caught">;
110
+ readonly attempt: import("@protobase/schema").Field<number>;
111
+ readonly input: import("@protobase/schema").Field<import("zod").JSONType>;
112
+ readonly output: import("@protobase/schema").Field<import("zod").JSONType>;
113
+ readonly assigned: import("@protobase/schema").Field<import("zod").JSONType>;
114
+ readonly next: import("@protobase/schema").Field<string | null>;
115
+ readonly resume_at: import("@protobase/schema").Field<string | null>;
116
+ readonly error: import("@protobase/schema").Field<string | null>;
117
+ readonly cause: import("@protobase/schema").Field<string | null>;
118
+ readonly logs: import("@protobase/schema").Field<import("zod").JSONType>;
119
+ readonly started_at: import("@protobase/schema").Field<string>;
120
+ readonly finished_at: import("@protobase/schema").Field<string>;
121
+ readonly duration_ms: import("@protobase/schema").Field<string | null>;
122
+ }, import("@protobase/schema").Ref<"id", string>>>;
123
+ };
124
+ //#endregion
@@ -0,0 +1,11 @@
1
+ import { workflowsSchema } from "./options.js";
2
+ import { workflowResources } from "@protobase/schema/internal";
3
+ //#region src/workflows/workflows-module.ts
4
+ /**
5
+ * What `workflows` in `protobase.config.ts` adds to the app's resources: Workflows, their versions, runs and steps,
6
+ * over a `workflows` schema that `protobase migration` writes. Who may make, change and run them and read their runs
7
+ * is the resources' access (`workflows.create`, `workflow_runs.create`, `workflow_steps.read`, ...).
8
+ */
9
+ const workflowsModule = (options = {}) => workflowResources(workflowsSchema(options));
10
+ //#endregion
11
+ export { workflowsModule };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@protobase/server",
3
- "version": "0.67.8",
3
+ "version": "0.67.10",
4
4
  "description": "The Protobase REST API as a Hono app, with Better Auth sign-in.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -44,9 +44,10 @@
44
44
  "@better-auth/sso": "^1.7.12",
45
45
  "@livekit/protocol": "1.53.1",
46
46
  "@modelcontextprotocol/server": "^2.3.1",
47
- "@protobase/layout": "0.67.8",
48
- "@protobase/query": "0.67.8",
49
- "@protobase/schema": "0.67.8",
47
+ "@protobase/layout": "0.67.10",
48
+ "@protobase/query": "0.67.10",
49
+ "@protobase/schema": "0.67.10",
50
+ "@protobase/workflows": "0.67.10",
50
51
  "@react-email/render": "^2.1.0",
51
52
  "@react-pdf/primitives": "^4.4.0",
52
53
  "@react-pdf/renderer": "^4.9.0",