@tallpond/cli 0.0.3 → 0.0.4

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.
Files changed (3) hide show
  1. package/README.md +2 -1
  2. package/cli.js +8 -4
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -72,7 +72,8 @@ export default async (ctx: FunctionContext, args: { resourceId: string; move: un
72
72
  ```
73
73
 
74
74
  The ctx surface is exactly `userId`, `resourceId`, `fn`, `invocationId`,
75
- `db.query`/`db.batch` (raw `/v1/db` wire shape), and `gateway(path, body)`
75
+ `db.query`/`db.batch` (raw `/v1/db` wire shape), and `gateway(path, body?, opts?)`
76
+ (POST by default, `{ method: 'GET' }` for read routes) —
76
77
  annotate with `FunctionContext` so the compiler enforces it. Full contract:
77
78
  <https://tallpond.com/docs/functions/>.
78
79
 
package/cli.js CHANGED
@@ -382,11 +382,15 @@ function decodeInvocation(token) {
382
382
  function makeCtx(env, token) {
383
383
  const fetchImpl = env.TALLPOND_FETCH ?? fetch
384
384
  const base = String(env.TALLPOND_GATEWAY_URL ?? '').replace(/\\/$/, '')
385
- async function call(path, body) {
385
+ async function call(path, body, opts) {
386
+ const method = (opts && opts.method) || 'POST'
387
+ const bodyless = method === 'GET' || method === 'HEAD'
388
+ const headers = { authorization: 'Bearer ' + token }
389
+ if (!bodyless) headers['content-type'] = 'application/json'
386
390
  const res = await fetchImpl(base + path, {
387
- method: 'POST',
388
- headers: { 'content-type': 'application/json', authorization: 'Bearer ' + token },
389
- body: JSON.stringify(body),
391
+ method,
392
+ headers,
393
+ body: bodyless ? undefined : JSON.stringify(body),
390
394
  })
391
395
  const data = await res.json().catch(() => null)
392
396
  if (!res.ok) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tallpond/cli",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "description": "The tallpond developer CLI — sign in, register an app, and deploy schema + frontend with one command.",
5
5
  "license": "MIT",
6
6
  "repository": {