@jay-framework/compiler-jay-stack 0.16.0 → 0.16.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.
package/dist/index.d.ts CHANGED
@@ -62,6 +62,8 @@ interface ActionMetadata {
62
62
  exportName: string;
63
63
  /** Whether this is a streaming action (makeJayStream) */
64
64
  isStreaming?: boolean;
65
+ /** Whether this action accepts file uploads (DL#131) */
66
+ acceptsFiles?: boolean;
65
67
  }
66
68
  /**
67
69
  * Result of extracting actions from a module.
package/dist/index.js CHANGED
@@ -314,6 +314,7 @@ function extractActionFromExpression(node) {
314
314
  let current = node;
315
315
  let method = "POST";
316
316
  let explicitMethod = null;
317
+ let acceptsFiles = false;
317
318
  while (tsBridge.isCallExpression(current)) {
318
319
  const expr = current.expression;
319
320
  if (tsBridge.isPropertyAccessExpression(expr) && expr.name.text === "withMethod") {
@@ -324,6 +325,11 @@ function extractActionFromExpression(node) {
324
325
  current = expr.expression;
325
326
  continue;
326
327
  }
328
+ if (tsBridge.isPropertyAccessExpression(expr) && expr.name.text === "withFiles") {
329
+ acceptsFiles = true;
330
+ current = expr.expression;
331
+ continue;
332
+ }
327
333
  if (tsBridge.isPropertyAccessExpression(expr) && ["withServices", "withCaching", "withHandler", "withTimeout"].includes(expr.name.text)) {
328
334
  current = expr.expression;
329
335
  continue;
@@ -337,7 +343,8 @@ function extractActionFromExpression(node) {
337
343
  return {
338
344
  actionName: nameArg.text,
339
345
  method: "POST",
340
- isStreaming: true
346
+ isStreaming: true,
347
+ ...acceptsFiles && { acceptsFiles: true }
341
348
  };
342
349
  }
343
350
  method = funcName === "makeJayQuery" ? "GET" : "POST";
@@ -346,7 +353,8 @@ function extractActionFromExpression(node) {
346
353
  }
347
354
  return {
348
355
  actionName: nameArg.text,
349
- method
356
+ method,
357
+ ...acceptsFiles && { acceptsFiles: true }
350
358
  };
351
359
  }
352
360
  }
@@ -405,14 +413,15 @@ async function transformActionImports(code, id, resolveActionModule) {
405
413
  for (const importName of imp.namedImports) {
406
414
  const action = actions.find((a) => a.exportName === importName);
407
415
  if (action) {
416
+ const filesOpt = action.acceptsFiles ? ", { acceptsFiles: true }" : "";
408
417
  if (action.isStreaming) {
409
418
  callerDeclarations.push(
410
- `const ${importName} = createStreamCaller('${action.actionName}');`
419
+ `const ${importName} = createStreamCaller('${action.actionName}'${filesOpt});`
411
420
  );
412
421
  needsCreateStreamCallerImport = true;
413
422
  } else {
414
423
  callerDeclarations.push(
415
- `const ${importName} = createActionCaller('${action.actionName}', '${action.method}');`
424
+ `const ${importName} = createActionCaller('${action.actionName}', '${action.method}'${filesOpt});`
416
425
  );
417
426
  needsCreateActionCallerImport = true;
418
427
  }
@@ -847,13 +856,14 @@ function jayStackCompiler(options = {}) {
847
856
  ""
848
857
  ];
849
858
  for (const action of actions) {
859
+ const filesOpt = action.acceptsFiles ? ", { acceptsFiles: true }" : "";
850
860
  if (action.isStreaming) {
851
861
  lines.push(
852
- `export const ${action.exportName} = createStreamCaller('${action.actionName}');`
862
+ `export const ${action.exportName} = createStreamCaller('${action.actionName}'${filesOpt});`
853
863
  );
854
864
  } else {
855
865
  lines.push(
856
- `export const ${action.exportName} = createActionCaller('${action.actionName}', '${action.method}');`
866
+ `export const ${action.exportName} = createActionCaller('${action.actionName}', '${action.method}'${filesOpt});`
857
867
  );
858
868
  }
859
869
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jay-framework/compiler-jay-stack",
3
- "version": "0.16.0",
3
+ "version": "0.16.1",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/index.js",
@@ -27,16 +27,16 @@
27
27
  "test:watch": "vitest"
28
28
  },
29
29
  "dependencies": {
30
- "@jay-framework/compiler": "^0.16.0",
31
- "@jay-framework/compiler-shared": "^0.16.0",
32
- "@jay-framework/logger": "^0.16.0",
33
- "@jay-framework/typescript-bridge": "^0.16.0",
34
- "@jay-framework/vite-plugin": "^0.16.0",
30
+ "@jay-framework/compiler": "^0.16.1",
31
+ "@jay-framework/compiler-shared": "^0.16.1",
32
+ "@jay-framework/logger": "^0.16.1",
33
+ "@jay-framework/typescript-bridge": "^0.16.1",
34
+ "@jay-framework/vite-plugin": "^0.16.1",
35
35
  "typescript": "^5.3.3",
36
36
  "vite": "^5.0.11"
37
37
  },
38
38
  "devDependencies": {
39
- "@jay-framework/dev-environment": "^0.16.0",
39
+ "@jay-framework/dev-environment": "^0.16.1",
40
40
  "rimraf": "^5.0.5",
41
41
  "tsup": "^8.0.1",
42
42
  "vitest": "^1.2.1"