@versori/run 0.4.0-alpha.13 → 0.4.0-alpha.15

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.
@@ -23,7 +23,7 @@ export function compileDurableWorkflow(ctx, trigger, signal) {
23
23
  signal.addEventListener('abort', cleanup, { once: true });
24
24
  let consecutiveErrors = 0;
25
25
  const maxConsecutiveErrors = 5;
26
- let currentlyRunningTasks = trigger.options.limit ?? 0;
26
+ let currentlyRunningTasks = 0;
27
27
  (async () => {
28
28
  while (true) {
29
29
  if (signal.aborted) {
@@ -54,7 +54,7 @@ export function compileDurableWorkflow(ctx, trigger, signal) {
54
54
  continue;
55
55
  }
56
56
  for (const wf of wfs.workflows) {
57
- const data = JSON.parse(atob(wf.payload ?? '{}'));
57
+ const data = JSON.parse(base64ToUtf8(wf.payload ?? 'e30='));
58
58
  let activation;
59
59
  try {
60
60
  const { data } = await ctx.platformApi.getActivation({
@@ -81,7 +81,7 @@ export function compileDurableWorkflow(ctx, trigger, signal) {
81
81
  }
82
82
  ctx.queueProvider.complete({
83
83
  id: wf.id,
84
- output: btoa(JSON.stringify(completedContext.data)),
84
+ output: utf8ToBase64(JSON.stringify(completedContext.data)),
85
85
  status: 'completed',
86
86
  });
87
87
  },
@@ -110,3 +110,19 @@ export const durableWorkflowCompiler = {
110
110
  ctor: DurableWorkflowTrigger,
111
111
  compile: compileDurableWorkflow,
112
112
  };
113
+ function utf8ToBase64(str) {
114
+ const encoder = new TextEncoder();
115
+ const data = encoder.encode(str);
116
+ const binaryString = String.fromCharCode.apply(null, data);
117
+ return btoa(binaryString);
118
+ }
119
+ function base64ToUtf8(b64) {
120
+ const binaryString = atob(b64);
121
+ // Create a Uint8Array from the binary string.
122
+ const bytes = new Uint8Array(binaryString.length);
123
+ for (let i = 0; i < binaryString.length; i++) {
124
+ bytes[i] = binaryString.charCodeAt(i);
125
+ }
126
+ const decoder = new TextDecoder();
127
+ return decoder.decode(bytes);
128
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@versori/run",
3
- "version": "0.4.0-alpha.13",
3
+ "version": "0.4.0-alpha.15",
4
4
  "description": "Versori Run",
5
5
  "homepage": "https://github.com/versori/versori-run#readme",
6
6
  "repository": {
@@ -27,7 +27,7 @@ function compileDurableWorkflow(ctx, trigger, signal) {
27
27
  signal.addEventListener('abort', cleanup, { once: true });
28
28
  let consecutiveErrors = 0;
29
29
  const maxConsecutiveErrors = 5;
30
- let currentlyRunningTasks = trigger.options.limit ?? 0;
30
+ let currentlyRunningTasks = 0;
31
31
  (async () => {
32
32
  while (true) {
33
33
  if (signal.aborted) {
@@ -58,7 +58,7 @@ function compileDurableWorkflow(ctx, trigger, signal) {
58
58
  continue;
59
59
  }
60
60
  for (const wf of wfs.workflows) {
61
- const data = JSON.parse(atob(wf.payload ?? '{}'));
61
+ const data = JSON.parse(base64ToUtf8(wf.payload ?? 'e30='));
62
62
  let activation;
63
63
  try {
64
64
  const { data } = await ctx.platformApi.getActivation({
@@ -85,7 +85,7 @@ function compileDurableWorkflow(ctx, trigger, signal) {
85
85
  }
86
86
  ctx.queueProvider.complete({
87
87
  id: wf.id,
88
- output: btoa(JSON.stringify(completedContext.data)),
88
+ output: utf8ToBase64(JSON.stringify(completedContext.data)),
89
89
  status: 'completed',
90
90
  });
91
91
  },
@@ -114,3 +114,19 @@ exports.durableWorkflowCompiler = {
114
114
  ctor: DurableTrigger_js_1.DurableWorkflowTrigger,
115
115
  compile: compileDurableWorkflow,
116
116
  };
117
+ function utf8ToBase64(str) {
118
+ const encoder = new TextEncoder();
119
+ const data = encoder.encode(str);
120
+ const binaryString = String.fromCharCode.apply(null, data);
121
+ return btoa(binaryString);
122
+ }
123
+ function base64ToUtf8(b64) {
124
+ const binaryString = atob(b64);
125
+ // Create a Uint8Array from the binary string.
126
+ const bytes = new Uint8Array(binaryString.length);
127
+ for (let i = 0; i < binaryString.length; i++) {
128
+ bytes[i] = binaryString.charCodeAt(i);
129
+ }
130
+ const decoder = new TextDecoder();
131
+ return decoder.decode(bytes);
132
+ }