@aurabase/functions 0.4.0 → 0.4.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/README.md CHANGED
@@ -36,7 +36,10 @@ const { data, error } = await aura.functions.invoke<{ ok: boolean }>('hello-worl
36
36
  })
37
37
 
38
38
  if (error) throw error
39
- console.log(data!.ok)
39
+ // `data` peut être `null` même en succès (204 / corps vide) : tester `data`
40
+ // plutôt que `error` évite l'assertion `!` et fait narrower TypeScript.
41
+ if (!data) throw new Error('réponse vide')
42
+ console.log(data.ok)
40
43
  ```
41
44
 
42
45
  Options complètes : `method`, `path` (sous-route à l'intérieur de la fonction), `headers` (transmis à la fonction elle-même, pas des headers de transport), `signal`, `timeout`.
package/dist/index.cjs CHANGED
@@ -79,8 +79,9 @@ var FunctionsService = class extends core.BaseService {
79
79
  });
80
80
  try {
81
81
  if (responseType === "json") {
82
+ const hasCanceller = options?.timeout !== void 0 || userSignal !== void 0;
82
83
  const res2 = await this.request("POST", `${this.prefix}/${slug}/invoke`, envelope, {
83
- signal: controller.signal
84
+ ...hasCanceller ? { signal: controller.signal } : {}
84
85
  });
85
86
  if (res2.error && controller.signal.aborted) return timeoutError();
86
87
  if (res2.error) return { data: null, error: toFunctionsError(res2.error) };
package/dist/index.js CHANGED
@@ -77,8 +77,9 @@ var FunctionsService = class extends BaseService {
77
77
  });
78
78
  try {
79
79
  if (responseType === "json") {
80
+ const hasCanceller = options?.timeout !== void 0 || userSignal !== void 0;
80
81
  const res2 = await this.request("POST", `${this.prefix}/${slug}/invoke`, envelope, {
81
- signal: controller.signal
82
+ ...hasCanceller ? { signal: controller.signal } : {}
82
83
  });
83
84
  if (res2.error && controller.signal.aborted) return timeoutError();
84
85
  if (res2.error) return { data: null, error: toFunctionsError(res2.error) };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aurabase/functions",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "Service edge functions du SDK Aurabase (invoke, jobs asynchrones, cron)",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
@@ -45,9 +45,10 @@
45
45
  "functions"
46
46
  ],
47
47
  "dependencies": {
48
- "@aurabase/core": "0.4.0"
48
+ "@aurabase/core": "0.4.1"
49
49
  },
50
50
  "devDependencies": {
51
+ "@types/node": "20.14.15",
51
52
  "tsup": "^8.0.0",
52
53
  "typescript": "^5.5.0",
53
54
  "vitest": "^4.1.6"
@@ -55,6 +56,7 @@
55
56
  "scripts": {
56
57
  "build": "tsup",
57
58
  "test": "vitest run --passWithNoTests",
58
- "typecheck": "tsc --noEmit"
59
+ "typecheck": "tsc --noEmit && tsc --noEmit -p tsconfig.test.json",
60
+ "typecheck:tests": "tsc --noEmit -p tsconfig.test.json"
59
61
  }
60
62
  }