@diagonal-hq/workflows 0.2.0 → 0.3.1

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.
@@ -1,21 +1,255 @@
1
- import "../chunks/chunk-NUFRM6SI.js";
1
+ import "../chunks/chunk-CSWWU6TP.js";
2
+ import {
3
+ calendar,
4
+ callback,
5
+ chart,
6
+ data,
7
+ date,
8
+ file,
9
+ guard,
10
+ lifecycle,
11
+ mail,
12
+ markdown,
13
+ mediaLibrary,
14
+ money,
15
+ notification,
16
+ number,
17
+ package_,
18
+ page,
19
+ payables,
20
+ payment,
21
+ phone,
22
+ scheduling,
23
+ schema,
24
+ security,
25
+ subscriptions,
26
+ text,
27
+ time,
28
+ timezone,
29
+ tiptap,
30
+ transaction,
31
+ user,
32
+ workflow,
33
+ workspace
34
+ } from "../chunks/chunk-KXVTSLCN.js";
2
35
  import {
3
36
  InputField,
4
37
  InputSchema,
5
- v
6
- } from "../chunks/chunk-RTCHH3JG.js";
38
+ defineWorkflow,
39
+ parseWorkflowInput,
40
+ redirect,
41
+ respond,
42
+ v,
43
+ validateWorkflowInput
44
+ } from "../chunks/chunk-RWZW4V74.js";
7
45
  import {
8
46
  HostError,
9
47
  WorkflowFailure,
10
48
  fail,
11
49
  validationError
12
50
  } from "../chunks/chunk-OF5QITP7.js";
51
+
52
+ // packages/workflows/src/generated/profiles/migration.ts
53
+ var calendar2 = {
54
+ generateLink: calendar.generateLink,
55
+ searchEvents: calendar.searchEvents
56
+ };
57
+ var callback2 = {
58
+ get: callback.get,
59
+ remove: callback.remove,
60
+ set: callback.set
61
+ };
62
+ var chart2 = {
63
+ distribution: chart.distribution,
64
+ kpi: chart.kpi,
65
+ leaderboard: chart.leaderboard,
66
+ timeSeries: chart.timeSeries
67
+ };
68
+ var data2 = {
69
+ aggregateMetrics: data.aggregateMetrics,
70
+ count: data.count,
71
+ create: data.create,
72
+ createMany: data.createMany,
73
+ delete: data.delete,
74
+ deleteMany: data.deleteMany,
75
+ find: data.find,
76
+ findOrCreate: data.findOrCreate,
77
+ relation: {
78
+ attach: data.relation.attach,
79
+ attachMany: data.relation.attachMany,
80
+ detach: data.relation.detach,
81
+ detachMany: data.relation.detachMany,
82
+ sync: data.relation.sync
83
+ },
84
+ restore: data.restore,
85
+ search: data.search,
86
+ semanticSearch: data.semanticSearch,
87
+ sum: data.sum,
88
+ update: data.update,
89
+ updateOrCreate: data.updateOrCreate,
90
+ validate: data.validate
91
+ };
92
+ var date2 = {
93
+ add: date.add,
94
+ diff: date.diff,
95
+ endOf: date.endOf,
96
+ format: date.format,
97
+ startOf: date.startOf,
98
+ subtract: date.subtract
99
+ };
100
+ var file2 = {
101
+ changeVisibility: file.changeVisibility,
102
+ createMediaLibraryItem: file.createMediaLibraryItem,
103
+ createQrCode: file.createQrCode
104
+ };
105
+ var guard2 = {
106
+ validate: guard.validate
107
+ };
108
+ var lifecycle2 = {
109
+ output: lifecycle.output
110
+ };
111
+ var mail2 = {
112
+ search: mail.search
113
+ };
114
+ var markdown2 = {
115
+ fromContent: markdown.fromContent,
116
+ toContent: markdown.toContent
117
+ };
118
+ var mediaLibrary2 = {
119
+ createFolder: mediaLibrary.createFolder,
120
+ deleteItem: mediaLibrary.deleteItem,
121
+ moveItems: mediaLibrary.moveItems,
122
+ updateItem: mediaLibrary.updateItem
123
+ };
124
+ var money2 = {
125
+ format: money.format
126
+ };
127
+ var notification2 = {
128
+ setConsent: notification.setConsent
129
+ };
130
+ var number2 = {
131
+ format: number.format
132
+ };
133
+ var package_2 = {
134
+ installInput: package_.installInput
135
+ };
136
+ var page2 = {
137
+ url: page.url
138
+ };
139
+ var payables2 = {
140
+ void: payables.void,
141
+ writeOff: payables.writeOff
142
+ };
143
+ var payment2 = {
144
+ createManual: payment.createManual
145
+ };
146
+ var phone2 = {
147
+ format: phone.format
148
+ };
149
+ var scheduling2 = {
150
+ bookSlot: scheduling.bookSlot,
151
+ findSlots: scheduling.findSlots
152
+ };
153
+ var schema2 = {
154
+ toJsonSchema: schema.toJsonSchema
155
+ };
156
+ var security2 = {
157
+ randomPassword: security.randomPassword
158
+ };
159
+ var subscriptions2 = {
160
+ activate: subscriptions.activate,
161
+ cancel: subscriptions.cancel,
162
+ changeItems: subscriptions.changeItems,
163
+ create: subscriptions.create,
164
+ generateInvoice: subscriptions.generateInvoice,
165
+ pause: subscriptions.pause,
166
+ preview: subscriptions.preview,
167
+ previewChange: subscriptions.previewChange,
168
+ resume: subscriptions.resume,
169
+ setUpcomingItems: subscriptions.setUpcomingItems
170
+ };
171
+ var text2 = {
172
+ generate: text.generate,
173
+ hash: text.hash,
174
+ randomUuid: text.randomUuid,
175
+ toContent: text.toContent
176
+ };
177
+ var time2 = {
178
+ add: time.add,
179
+ diff: time.diff,
180
+ endOf: time.endOf,
181
+ format: time.format,
182
+ startOf: time.startOf,
183
+ subtract: time.subtract
184
+ };
185
+ var timezone2 = {
186
+ format: timezone.format,
187
+ interpret: timezone.interpret
188
+ };
189
+ var tiptap2 = {
190
+ parse: tiptap.parse
191
+ };
192
+ var user2 = {
193
+ authorize: user.authorize
194
+ };
195
+ var workflow2 = {
196
+ url: workflow.url
197
+ };
198
+ var workspace2 = {
199
+ loginUrl: workspace.loginUrl,
200
+ setValue: workspace.setValue,
201
+ setValues: workspace.setValues,
202
+ value: workspace.value,
203
+ values: workspace.values
204
+ };
205
+
206
+ // packages/workflows/src/profiles/migration.ts
207
+ var data3 = {
208
+ ...data2,
209
+ each: data.each
210
+ };
13
211
  export {
14
212
  HostError,
15
213
  InputField,
16
214
  InputSchema,
17
215
  WorkflowFailure,
216
+ calendar2 as calendar,
217
+ callback2 as callback,
218
+ chart2 as chart,
219
+ data3 as data,
220
+ date2 as date,
221
+ defineWorkflow,
18
222
  fail,
223
+ file2 as file,
224
+ guard2 as guard,
225
+ lifecycle2 as lifecycle,
226
+ mail2 as mail,
227
+ markdown2 as markdown,
228
+ mediaLibrary2 as mediaLibrary,
229
+ money2 as money,
230
+ notification2 as notification,
231
+ number2 as number,
232
+ package_2 as package,
233
+ page2 as page,
234
+ parseWorkflowInput,
235
+ payables2 as payables,
236
+ payment2 as payment,
237
+ phone2 as phone,
238
+ redirect,
239
+ respond,
240
+ scheduling2 as scheduling,
241
+ schema2 as schema,
242
+ security2 as security,
243
+ subscriptions2 as subscriptions,
244
+ text2 as text,
245
+ time2 as time,
246
+ timezone2 as timezone,
247
+ tiptap2 as tiptap,
248
+ transaction,
249
+ user2 as user,
19
250
  v,
20
- validationError
251
+ validateWorkflowInput,
252
+ validationError,
253
+ workflow2 as workflow,
254
+ workspace2 as workspace
21
255
  };
@@ -0,0 +1,4 @@
1
+ export { HostError, WorkflowFailure, fail, validationError } from "../errors.js";
2
+ export { InputField, InputSchema, v, type ContentDocument, type ContentNode, type ContentOptions, type FileVisibility, type Infer, type InferInput, type InputFieldKind, type InputFieldSpec, type InputShape, type Money, type RecordScope } from "../input.js";
3
+ export { defineWorkflow, parseWorkflowInput, redirect, respond, validateWorkflowInput, type Identity, type InputErrors, type InputValidator, type RequestContext, type ScriptExecution, type WorkflowContext, type WorkflowDefinition, type WorkflowExecution } from "../workflow.js";
4
+ export type { ScriptHostContext, WorkspaceNotificationTypes, WorkspaceResources } from "../index.js";
@@ -1,3 +1,9 @@
1
1
  import "../console.js";
2
- export { HostError, WorkflowFailure, fail, validationError } from "../errors.js";
3
- export { InputField, InputSchema, v, type ContentDocument, type ContentNode, type ContentOptions, type FileVisibility, type Infer, type InferInput, type InputFieldKind, type InputFieldSpec, type InputShape, type Money, type RecordScope } from "../input.js";
2
+ import { data as rootData } from "../data.js";
3
+ import { data as testData } from "../generated/profiles/test.js";
4
+ export * from "./shared.js";
5
+ export * from "../generated/profiles/test.js";
6
+ export { transaction } from "../transaction.js";
7
+ export declare const data: typeof testData & {
8
+ each: typeof rootData.each;
9
+ };
@@ -1,21 +1,300 @@
1
- import "../chunks/chunk-NUFRM6SI.js";
1
+ import "../chunks/chunk-CSWWU6TP.js";
2
+ import {
3
+ ai,
4
+ calendar,
5
+ callback,
6
+ chart,
7
+ data,
8
+ date,
9
+ file,
10
+ guard,
11
+ http,
12
+ lifecycle,
13
+ mail,
14
+ markdown,
15
+ mediaLibrary,
16
+ money,
17
+ notification,
18
+ number,
19
+ package_,
20
+ page,
21
+ payables,
22
+ payment,
23
+ payments,
24
+ phone,
25
+ scheduling,
26
+ schema,
27
+ security,
28
+ sms,
29
+ subscriptions,
30
+ text,
31
+ time,
32
+ timezone,
33
+ tiptap,
34
+ transaction,
35
+ user,
36
+ web,
37
+ workflow,
38
+ workspace
39
+ } from "../chunks/chunk-KXVTSLCN.js";
2
40
  import {
3
41
  InputField,
4
42
  InputSchema,
5
- v
6
- } from "../chunks/chunk-RTCHH3JG.js";
43
+ defineWorkflow,
44
+ parseWorkflowInput,
45
+ redirect,
46
+ respond,
47
+ v,
48
+ validateWorkflowInput
49
+ } from "../chunks/chunk-RWZW4V74.js";
7
50
  import {
8
51
  HostError,
9
52
  WorkflowFailure,
10
53
  fail,
11
54
  validationError
12
55
  } from "../chunks/chunk-OF5QITP7.js";
56
+
57
+ // packages/workflows/src/generated/profiles/test.ts
58
+ var ai2 = {
59
+ decide: ai.decide,
60
+ runPrompt: ai.runPrompt
61
+ };
62
+ var calendar2 = {
63
+ generateLink: calendar.generateLink,
64
+ searchEvents: calendar.searchEvents
65
+ };
66
+ var callback2 = {
67
+ get: callback.get,
68
+ remove: callback.remove,
69
+ set: callback.set
70
+ };
71
+ var chart2 = {
72
+ distribution: chart.distribution,
73
+ kpi: chart.kpi,
74
+ leaderboard: chart.leaderboard,
75
+ timeSeries: chart.timeSeries
76
+ };
77
+ var data2 = {
78
+ aggregateMetrics: data.aggregateMetrics,
79
+ count: data.count,
80
+ create: data.create,
81
+ createMany: data.createMany,
82
+ delete: data.delete,
83
+ deleteMany: data.deleteMany,
84
+ find: data.find,
85
+ findOrCreate: data.findOrCreate,
86
+ relation: {
87
+ attach: data.relation.attach,
88
+ attachMany: data.relation.attachMany,
89
+ detach: data.relation.detach,
90
+ detachMany: data.relation.detachMany,
91
+ sync: data.relation.sync
92
+ },
93
+ restore: data.restore,
94
+ search: data.search,
95
+ semanticSearch: data.semanticSearch,
96
+ sum: data.sum,
97
+ update: data.update,
98
+ updateOrCreate: data.updateOrCreate,
99
+ validate: data.validate
100
+ };
101
+ var date2 = {
102
+ add: date.add,
103
+ diff: date.diff,
104
+ endOf: date.endOf,
105
+ format: date.format,
106
+ startOf: date.startOf,
107
+ subtract: date.subtract
108
+ };
109
+ var file2 = {
110
+ changeVisibility: file.changeVisibility,
111
+ createFromUrl: file.createFromUrl,
112
+ createMediaLibraryItem: file.createMediaLibraryItem,
113
+ createQrCode: file.createQrCode
114
+ };
115
+ var guard2 = {
116
+ validate: guard.validate
117
+ };
118
+ var http2 = {
119
+ request: http.request
120
+ };
121
+ var lifecycle2 = {
122
+ output: lifecycle.output
123
+ };
124
+ var mail2 = {
125
+ search: mail.search,
126
+ send: mail.send,
127
+ sendNotification: mail.sendNotification
128
+ };
129
+ var markdown2 = {
130
+ fromContent: markdown.fromContent,
131
+ toContent: markdown.toContent
132
+ };
133
+ var mediaLibrary2 = {
134
+ createFolder: mediaLibrary.createFolder,
135
+ deleteItem: mediaLibrary.deleteItem,
136
+ moveItems: mediaLibrary.moveItems,
137
+ updateItem: mediaLibrary.updateItem
138
+ };
139
+ var money2 = {
140
+ format: money.format
141
+ };
142
+ var notification2 = {
143
+ send: notification.send,
144
+ sendBulkNotifications: notification.sendBulkNotifications,
145
+ sendNotification: notification.sendNotification,
146
+ setConsent: notification.setConsent
147
+ };
148
+ var number2 = {
149
+ format: number.format
150
+ };
151
+ var package_2 = {
152
+ installInput: package_.installInput
153
+ };
154
+ var page2 = {
155
+ url: page.url
156
+ };
157
+ var payables2 = {
158
+ void: payables.void,
159
+ writeOff: payables.writeOff
160
+ };
161
+ var payment2 = {
162
+ createManual: payment.createManual
163
+ };
164
+ var payments2 = {
165
+ charge: payments.charge,
166
+ checkout: payments.checkout,
167
+ confirm: payments.confirm,
168
+ refund: payments.refund
169
+ };
170
+ var phone2 = {
171
+ format: phone.format
172
+ };
173
+ var scheduling2 = {
174
+ bookSlot: scheduling.bookSlot,
175
+ findSlots: scheduling.findSlots
176
+ };
177
+ var schema2 = {
178
+ toJsonSchema: schema.toJsonSchema
179
+ };
180
+ var security2 = {
181
+ randomPassword: security.randomPassword
182
+ };
183
+ var sms2 = {
184
+ sendNotification: sms.sendNotification
185
+ };
186
+ var subscriptions2 = {
187
+ activate: subscriptions.activate,
188
+ cancel: subscriptions.cancel,
189
+ changeItems: subscriptions.changeItems,
190
+ create: subscriptions.create,
191
+ generateInvoice: subscriptions.generateInvoice,
192
+ pause: subscriptions.pause,
193
+ preview: subscriptions.preview,
194
+ previewChange: subscriptions.previewChange,
195
+ resume: subscriptions.resume,
196
+ setUpcomingItems: subscriptions.setUpcomingItems
197
+ };
198
+ var text2 = {
199
+ generate: text.generate,
200
+ hash: text.hash,
201
+ randomUuid: text.randomUuid,
202
+ toContent: text.toContent
203
+ };
204
+ var time2 = {
205
+ add: time.add,
206
+ diff: time.diff,
207
+ endOf: time.endOf,
208
+ format: time.format,
209
+ startOf: time.startOf,
210
+ subtract: time.subtract
211
+ };
212
+ var timezone2 = {
213
+ format: timezone.format,
214
+ interpret: timezone.interpret
215
+ };
216
+ var tiptap2 = {
217
+ parse: tiptap.parse
218
+ };
219
+ var user2 = {
220
+ authorize: user.authorize
221
+ };
222
+ var web2 = {
223
+ agent: web.agent,
224
+ batchScrape: web.batchScrape,
225
+ crawl: web.crawl,
226
+ extract: web.extract,
227
+ googleSearch: web.googleSearch,
228
+ map: web.map,
229
+ pdf: web.pdf,
230
+ scrape: web.scrape,
231
+ screenshot: web.screenshot,
232
+ searchRanked: web.searchRanked
233
+ };
234
+ var workflow2 = {
235
+ run: workflow.run,
236
+ url: workflow.url
237
+ };
238
+ var workspace2 = {
239
+ loginUrl: workspace.loginUrl,
240
+ setValue: workspace.setValue,
241
+ setValues: workspace.setValues,
242
+ value: workspace.value,
243
+ values: workspace.values
244
+ };
245
+
246
+ // packages/workflows/src/profiles/test.ts
247
+ var data3 = {
248
+ ...data2,
249
+ each: data.each
250
+ };
13
251
  export {
14
252
  HostError,
15
253
  InputField,
16
254
  InputSchema,
17
255
  WorkflowFailure,
256
+ ai2 as ai,
257
+ calendar2 as calendar,
258
+ callback2 as callback,
259
+ chart2 as chart,
260
+ data3 as data,
261
+ date2 as date,
262
+ defineWorkflow,
18
263
  fail,
264
+ file2 as file,
265
+ guard2 as guard,
266
+ http2 as http,
267
+ lifecycle2 as lifecycle,
268
+ mail2 as mail,
269
+ markdown2 as markdown,
270
+ mediaLibrary2 as mediaLibrary,
271
+ money2 as money,
272
+ notification2 as notification,
273
+ number2 as number,
274
+ package_2 as package,
275
+ page2 as page,
276
+ parseWorkflowInput,
277
+ payables2 as payables,
278
+ payment2 as payment,
279
+ payments2 as payments,
280
+ phone2 as phone,
281
+ redirect,
282
+ respond,
283
+ scheduling2 as scheduling,
284
+ schema2 as schema,
285
+ security2 as security,
286
+ sms2 as sms,
287
+ subscriptions2 as subscriptions,
288
+ text2 as text,
289
+ time2 as time,
290
+ timezone2 as timezone,
291
+ tiptap2 as tiptap,
292
+ transaction,
293
+ user2 as user,
19
294
  v,
20
- validationError
295
+ validateWorkflowInput,
296
+ validationError,
297
+ web2 as web,
298
+ workflow2 as workflow,
299
+ workspace2 as workspace
21
300
  };
@@ -2,8 +2,7 @@ import {
2
2
  parseWorkflowInput,
3
3
  setTransport,
4
4
  validateWorkflowInput
5
- } from "../chunks/chunk-3EO3FSI5.js";
6
- import "../chunks/chunk-RTCHH3JG.js";
5
+ } from "../chunks/chunk-RWZW4V74.js";
7
6
  import {
8
7
  HostError
9
8
  } from "../chunks/chunk-OF5QITP7.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@diagonal-hq/workflows",
3
- "version": "0.2.0",
3
+ "version": "0.3.1",
4
4
  "description": "The authoring API of Diagonal managed workflows, their capabilities, and the workflow test helpers.",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "repository": {
@@ -1,94 +0,0 @@
1
- import {
2
- coerceInput
3
- } from "./chunk-RTCHH3JG.js";
4
- import {
5
- validationError
6
- } from "./chunk-OF5QITP7.js";
7
-
8
- // packages/workflows/src/transport.ts
9
- var active = null;
10
- function setTransport(transport) {
11
- active = transport;
12
- }
13
- function invoke(name, input) {
14
- if (active === null) {
15
- return Promise.reject(
16
- new Error(
17
- "No Diagonal host transport is set. In tests, call setTransport(new MockTransport(...))."
18
- )
19
- );
20
- }
21
- return active.call(name, input);
22
- }
23
-
24
- // packages/workflows/src/workflow.ts
25
- function parseWorkflowInput(workflow, input) {
26
- return workflow.input === void 0 ? input : coerceInput(workflow.input, input);
27
- }
28
- async function validateWorkflowInput(validator, input, ctx) {
29
- const reported = await validator(input, ctx);
30
- if (reported === void 0 || reported === null) {
31
- return;
32
- }
33
- if (typeof reported !== "object" || Array.isArray(reported)) {
34
- throw new TypeError(
35
- "validateInput must return an object of errors keyed by field, or nothing."
36
- );
37
- }
38
- const errors = {};
39
- for (const [field, messages] of Object.entries(reported)) {
40
- const list = (Array.isArray(messages) ? messages : [messages]).filter(
41
- (message) => typeof message === "string" && message !== ""
42
- );
43
- if (list.length > 0) {
44
- errors[field] = list;
45
- }
46
- }
47
- if (Object.keys(errors).length > 0) {
48
- validationError(errors);
49
- }
50
- }
51
- function defineWorkflow(inputOrHandler, maybeHandler) {
52
- if (typeof inputOrHandler === "function") {
53
- return { $diagonal: "workflow", run: async (input, ctx) => inputOrHandler(input, ctx) };
54
- }
55
- const spec = inputOrHandler.$spec;
56
- const handler = maybeHandler;
57
- if (handler === void 0) {
58
- throw new TypeError("defineWorkflow(input, handler) needs a handler after the input schema.");
59
- }
60
- return {
61
- $diagonal: "workflow",
62
- input: spec,
63
- run: async (input, ctx) => handler(input, ctx)
64
- };
65
- }
66
- function respond(body, options = {}) {
67
- return {
68
- $response_status: options.status ?? 200,
69
- $response_body: body,
70
- $response_content_type: options.contentType ?? "application/json"
71
- };
72
- }
73
- function redirect(url, options = {}) {
74
- const type = options.type ?? (/^\/(?![/\\])/.test(url) ? "internal" : "external");
75
- const output = {
76
- redirect_url: url,
77
- redirect_type: type,
78
- permanent: type !== "back" && options.permanent === true
79
- };
80
- if (options.success !== void 0) {
81
- output.success = options.success;
82
- }
83
- return output;
84
- }
85
-
86
- export {
87
- setTransport,
88
- invoke,
89
- parseWorkflowInput,
90
- validateWorkflowInput,
91
- defineWorkflow,
92
- respond,
93
- redirect
94
- };