@tallpond/cli 0.0.2 → 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 +15 -2
  2. package/cli.js +8 -4
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -58,12 +58,25 @@ handler:
58
58
 
59
59
  ```ts
60
60
  // functions/submitMove.ts — invoked as tallpond.functions.invoke('submitMove', args)
61
- export default async (ctx, args) => {
62
- await ctx.db.query({ table: 'moves', insert: args })
61
+ import type { FunctionContext } from '@tallpond/sdk' // type-only; nothing bundled
62
+
63
+ export default async (ctx: FunctionContext, args: { resourceId: string; move: unknown }) => {
64
+ await ctx.db.query({
65
+ scope: { kind: 'resource', resourceId: args.resourceId },
66
+ table: 'moves',
67
+ op: 'insert',
68
+ values: { move: args.move },
69
+ })
63
70
  return { ok: true }
64
71
  }
65
72
  ```
66
73
 
74
+ The ctx surface is exactly `userId`, `resourceId`, `fn`, `invocationId`,
75
+ `db.query`/`db.batch` (raw `/v1/db` wire shape), and `gateway(path, body?, opts?)`
76
+ (POST by default, `{ method: 'GET' }` for read routes) —
77
+ annotate with `FunctionContext` so the compiler enforces it. Full contract:
78
+ <https://tallpond.com/docs/functions/>.
79
+
67
80
  File names must be identifiers (letters/digits/underscores). Shared helpers and
68
81
  types belong in a subdirectory (e.g. `functions/lib/`) — subdirectories aren't
69
82
  scanned, and handlers can import from them freely (everything is bundled). A
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.2",
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": {