apps 0.0.1-beta.109 → 0.0.1-beta.110

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/js/host.js CHANGED
@@ -151,38 +151,53 @@ var isolatedWorkflowExecution = (run, deliver, signal) => {
151
151
  invoke: (input) => request({ operation: "invoke", ...input })
152
152
  };
153
153
  };
154
+ var unanswered = ({ operation, key }, unread) => {
155
+ const cause = unread ? `This app's apps release could not read Executor's reply to ctx.workflows.${operation}; redeploy the app on the current apps release.` : `Executor did not answer ctx.workflows.${operation}.`;
156
+ switch (operation) {
157
+ case "start":
158
+ return new WorkflowFailure({
159
+ reason: "engine",
160
+ retryable: false,
161
+ message: key === void 0 ? `${cause} The run may have started. This start had no key, so check ctx.workflows.list before starting again: another start creates another run.` : `${cause} The run may have started. Start it again with the same key and input, which returns the run if it exists, or check ctx.workflows.list before starting another.`
162
+ });
163
+ case "terminate":
164
+ return new WorkflowFailure({
165
+ reason: "engine",
166
+ retryable: false,
167
+ message: `${cause} The run may have stopped. Read it with ctx.workflows.get before terminating it again.`
168
+ });
169
+ default:
170
+ return new WorkflowFailure({
171
+ reason: "engine",
172
+ retryable: !unread,
173
+ message: unread ? cause : `${cause} Try again.`
174
+ });
175
+ }
176
+ };
154
177
  var isolatedWorkflowControls = (deliver) => {
155
- const request = (input) => (
178
+ const request = (input, schema) => (
156
179
  // oxlint-disable-next-line executor/authored-code-through-adapter -- the host's workflow RPC
157
180
  Effect_exports.tryPromise({
158
181
  try: () => deliver(input),
159
- catch: () => new WorkflowFailure({ reason: "engine", retryable: true })
182
+ catch: () => unanswered(input, false)
160
183
  }).pipe(
161
- Effect_exports.flatMap(Schema_exports.decodeUnknownEffect(WorkflowRpcResult)),
162
- Effect_exports.mapError(() => new WorkflowFailure({ reason: "engine", retryable: true })),
163
184
  Effect_exports.flatMap(
164
- (result) => result.ok ? Effect_exports.succeed(result.value) : Effect_exports.fail(result.error)
165
- )
166
- )
167
- );
168
- const run = (input) => request(input).pipe(
169
- Effect_exports.flatMap(
170
- (value) => Schema_exports.decodeUnknownEffect(WorkflowRun)(value).pipe(
171
- Effect_exports.mapError(() => new WorkflowFailure({ reason: "engine", retryable: true }))
185
+ (reply) => Schema_exports.decodeUnknownEffect(WorkflowRpcResult)(reply).pipe(
186
+ Effect_exports.mapError(() => unanswered(input, true))
187
+ )
188
+ ),
189
+ Effect_exports.flatMap(
190
+ (result) => result.ok ? Schema_exports.decodeUnknownEffect(schema)(result.value).pipe(
191
+ Effect_exports.mapError(() => unanswered(input, true))
192
+ ) : Effect_exports.fail(result.error)
172
193
  )
173
194
  )
174
195
  );
175
196
  return {
176
- start: (input) => run({ operation: "start", ...input }),
177
- get: (input) => run({ operation: "get", ...input }),
178
- terminate: (input) => run({ operation: "terminate", ...input }),
179
- list: (input) => request({ operation: "list", ...input }).pipe(
180
- Effect_exports.flatMap(
181
- (value) => Schema_exports.decodeUnknownEffect(WorkflowRunPage)(value).pipe(
182
- Effect_exports.mapError(() => new WorkflowFailure({ reason: "engine", retryable: true }))
183
- )
184
- )
185
- )
197
+ start: (input) => request({ operation: "start", ...input }, WorkflowRun),
198
+ get: (input) => request({ operation: "get", ...input }, WorkflowRun),
199
+ terminate: (input) => request({ operation: "terminate", ...input }, WorkflowRun),
200
+ list: (input) => request({ operation: "list", ...input }, WorkflowRunPage)
186
201
  };
187
202
  };
188
203
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apps",
3
- "version": "0.0.1-beta.109",
3
+ "version": "0.0.1-beta.110",
4
4
  "description": "TypeScript apps with typed tools, accounts, storage, and UI.",
5
5
  "type": "module",
6
6
  "sideEffects": false,