wirejs-deploy-amplify-basic 0.0.130-async-api → 0.0.132-async-api

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.
@@ -54,7 +54,6 @@ function isBackgroundJob(o: any): o is BackgroundJob<any> {
54
54
  }
55
55
 
56
56
  export const handler: LambdaFunctionURLHandler = async (event, context) => {
57
- console.log('lambda invoke', event); // TEMP!
58
57
  const calls = JSON.parse(event.body!);
59
58
 
60
59
  if (Array.isArray(calls)) {
@@ -85,9 +84,13 @@ export const handler: LambdaFunctionURLHandler = async (event, context) => {
85
84
  body: JSON.stringify(responses)
86
85
  }
87
86
  } else if (typeof calls === 'object' && calls.async) {
88
- console.log('handling async execution', calls);
87
+ const sanitized = { ...calls };
88
+ sanitized.selfInvocationId = sanitized.selfInvocationId.slice(0, 8);
89
+
90
+ console.log('handling async execution', sanitized);
89
91
 
90
92
  if (!calls.absoluteId) {
93
+ console.error('Missing absoluteId in async call');
91
94
  return {
92
95
  statusCode: 400,
93
96
  body: JSON.stringify({ error: 'Missing absoluteId' })
@@ -95,21 +98,28 @@ export const handler: LambdaFunctionURLHandler = async (event, context) => {
95
98
  }
96
99
 
97
100
  if (calls.selfInvocationId !== env.SELF_INVOCATION_ID) {
101
+ console.error('Self invocation ID mismatch');
98
102
  return {
99
103
  statusCode: 403,
100
104
  body: JSON.stringify({ error: 'Forbidden' })
101
105
  };
102
106
  }
103
107
 
104
- const job = (BackgroundJob as any).registeredJobs[calls.absoluteId];
105
- if (!job || !isBackgroundJob(job)) {
108
+ const handler = (BackgroundJob as any).registeredJobs[calls.absoluteId];
109
+ if (!handler || typeof handler !== 'function') {
110
+ console.error('Background job not found',
111
+ calls.absoluteId,
112
+ (BackgroundJob as any).registeredJobs
113
+ );
106
114
  return {
107
115
  statusCode: 404,
108
116
  body: JSON.stringify({ error: 'Background job not found' })
109
117
  };
110
118
  }
111
119
 
112
- await job.start(...calls.args)
120
+ console.log('Starting background job');
121
+ await handler(...calls.args)
122
+ console.log('Background job completed');
113
123
 
114
124
  return {
115
125
  statusCode: 200,
@@ -3,6 +3,6 @@
3
3
  "dependencies": {
4
4
  "jsdom": "^25.0.1",
5
5
  "wirejs-dom": "^1.0.41",
6
- "wirejs-resources": "^0.1.98-async-api"
6
+ "wirejs-resources": "^0.1.100-async-api"
7
7
  }
8
8
  }
@@ -18,12 +18,10 @@ import { addResource } from '../resource-collector.js';
18
18
  * 3. In local development, **timeouts are not enforced.** (Yet.)
19
19
  */
20
20
  export class BackgroundJob extends Resource {
21
- #handler;
22
21
  #timeoutSeconds;
23
22
  static registeredJobs = {};
24
23
  constructor(scope, id, options) {
25
24
  super(scope, id);
26
- this.#handler = options.handler;
27
25
  if (options.timeoutSeconds && (options.timeoutSeconds < 1 || options.timeoutSeconds > 900)) {
28
26
  throw new Error('timeoutSeconds must be between 1 and 900 seconds.');
29
27
  }
@@ -32,7 +30,7 @@ export class BackgroundJob extends Resource {
32
30
  absoluteId: this.absoluteId,
33
31
  timeoutSeconds: this.#timeoutSeconds,
34
32
  });
35
- BackgroundJob.registeredJobs[this.absoluteId] = this;
33
+ BackgroundJob.registeredJobs[this.absoluteId] = options.handler;
36
34
  }
37
35
  /**
38
36
  * Serializes parameter data and schedules background execution.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wirejs-deploy-amplify-basic",
3
- "version": "0.0.130-async-api",
3
+ "version": "0.0.132-async-api",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -42,7 +42,7 @@
42
42
  "recursive-copy": "^2.0.14",
43
43
  "rimraf": "^6.0.1",
44
44
  "wirejs-dom": "^1.0.41",
45
- "wirejs-resources": "^0.1.98-async-api"
45
+ "wirejs-resources": "^0.1.100-async-api"
46
46
  },
47
47
  "devDependencies": {
48
48
  "@aws-amplify/backend": "^1.14.0",