orpc-fn 0.6.0 → 0.6.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
@@ -242,7 +242,7 @@ Sanitized tool-name collisions between distinct procedures throw; identical alia
242
242
 
243
243
  ## `orpc-fn/cli`
244
244
 
245
- Uses `hanzio/cli`, which orpc-fn depends on (`hanzio` ^3.1.0). Your `defineCli` must come from the same `hanzio` copy, so keep your own `hanzio` on a matching major.
245
+ Uses `hanzio/cli`, which orpc-fn depends on (`hanzio` ^3.3.0). Your `defineCli` must come from the same `hanzio` copy, so keep your own `hanzio` on a matching major.
246
246
 
247
247
  ```ts
248
248
  import { defineCli } from 'hanzio/cli'
package/dist/cli.js CHANGED
@@ -6,7 +6,13 @@ import { CliError, defineCli, defineCommand } from 'hanzio/cli';
6
6
  import { z } from 'zod';
7
7
  import { createStreamManifestAsync, renderStreamManifest } from './router.js';
8
8
  const streamManifest = defineCommand({
9
- description: "Write the paths of a router's streaming routes for createRpcLink({ streamPaths }), only when they change. Importing the router runs its module code: load .ts routers with bun, tsx or node >= 22.18.",
9
+ description: `Generate the stream manifest for createRpcLink({ streamPaths })
10
+
11
+ Imports the router (export "default" unless #export is given) and writes the
12
+ paths of its streaming routes for createRpcLink({ streamPaths }). The file is
13
+ only written when its content changes. --check writes nothing and exits 1 when
14
+ the file is missing or stale. Importing the router runs its module code; run
15
+ TypeScript routers with a runtime that loads .ts (bun, tsx, node >= 22.18).`,
10
16
  input: z.object({
11
17
  module: z
12
18
  .string()
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAExC,OAAO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A;QAC9B,MAAM,MAAM,GAAG,oBAAoB,CAClC,MAAM,yBAAyB,CAAC,MAAmB,CAAC,EACpD,EAAE,MAAM,EAAE,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,CACnE,CAAA;QACD,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAA;QAClE,IAAI,OAAO,KAAK,MAAM;YAAE,OAAM;QAC9B,IAAI,KAAK,CAAC,KAAK;YACd,MAAM,IAAI,QAAQ,CACjB,YAAY,KAAK,CAAC,GAAG,+CAA+C,CACpE,CAAA;QACF,MAAM,SAAS,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;QAC5B,OAAO,kBAAkB,KAAK,CAAC,GAAG,EAAE,CAAA;IACrC,CAAC;CACD,CAAC,CAAA;AAEF,MAAM,GAAG,GAAG,SAAS,CAAC;IACrB,IAAI,EAAE,SAAS;IACf,QAAQ,EAAE,EAAE,iBAAiB,EAAE,cAAc,EAAE;CAC/C,CAAC,CAAA;AAEF,iFAAiF;AACjF,OAAO,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,GAAG,EAAE,CAAC,CAAA","sourcesContent":["#!/usr/bin/env node\nimport { readFile, writeFile } from 'node:fs/promises'\nimport { resolve } from 'node:path'\nimport { pathToFileURL } from 'node:url'\nimport type { AnyRouter } from '@orpc/server'\nimport { CliError, defineCli, defineCommand } from 'hanzio/cli'\nimport { z } from 'zod'\nimport { createStreamManifestAsync, renderStreamManifest } from './router.js'\n\nconst streamManifest = defineCommand({\n\tdescription:\n\t\t\"Write the paths of a router's streaming routes for createRpcLink({ streamPaths }), only when they change. Importing the router runs its module code: load .ts routers with bun, tsx or node >= 22.18.\",\n\tinput: z.object({\n\t\tmodule: z\n\t\t\t.string()\n\t\t\t.describe('Router module, with #export for a named export')\n\t\t\t.meta({ positional: true }),\n\t\tout: z.string().describe('Manifest to write: file.ts or file.json'),\n\t\tname: z\n\t\t\t.string()\n\t\t\t.optional()\n\t\t\t.describe('Exported constant name in a .ts file'),\n\t\tcheck: z.boolean().describe('Exit 1 when the file is missing or stale')\n\t}),\n\trun: async (input) => {\n\t\tconst [modulePath = '', exportName = 'default'] = input.module.split('#')\n\t\tconst loaded: Record<string, unknown> = await import(\n\t\t\tpathToFileURL(resolve(modulePath)).href\n\t\t)\n\t\tconst router = loaded[exportName]\n\t\tif (!router || typeof router !== 'object')\n\t\t\tthrow new CliError(\n\t\t\t\t`orpc-fn: ${modulePath} has no router export \"${exportName}\"`,\n\t\t\t\t{ exitCode: 2 }\n\t\t\t)\n\t\tconst out = resolve(input.out)\n\t\tconst source = renderStreamManifest(\n\t\t\tawait createStreamManifestAsync(router as AnyRouter),\n\t\t\t{ format: out.endsWith('.json') ? 'json' : 'ts', name: input.name }\n\t\t)\n\t\tconst current = await readFile(out, 'utf8').catch(() => undefined)\n\t\tif (current === source) return\n\t\tif (input.check)\n\t\t\tthrow new CliError(\n\t\t\t\t`orpc-fn: ${input.out} is stale; rerun without --check to update it`\n\t\t\t)\n\t\tawait writeFile(out, source)\n\t\treturn `orpc-fn: wrote ${input.out}`\n\t}\n})\n\nconst cli = defineCli({\n\tname: 'orpc-fn',\n\tcommands: { 'stream-manifest': streamManifest }\n})\n\n// Exit explicitly: the imported router may hold open database or broker handles.\nprocess.exit(await cli.run())\n"]}
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAExC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,aAAa,E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AoB,CAClC,MAAM,yBAAyB,CAAC,MAAmB,CAAC,EACpD,EAAE,MAAM,EAAE,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,CACnE,CAAA;QACD,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAA;QAClE,IAAI,OAAO,KAAK,MAAM;YAAE,OAAM;QAC9B,IAAI,KAAK,CAAC,KAAK;YACd,MAAM,IAAI,QAAQ,CACjB,YAAY,KAAK,CAAC,GAAG,+CAA+C,CACpE,CAAA;QACF,MAAM,SAAS,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;QAC5B,OAAO,kBAAkB,KAAK,CAAC,GAAG,EAAE,CAAA;IACrC,CAAC;CACD,CAAC,CAAA;AAEF,MAAM,GAAG,GAAG,SAAS,CAAC;IACrB,IAAI,EAAE,SAAS;IACf,QAAQ,EAAE,EAAE,iBAAiB,EAAE,cAAc,EAAE;CAC/C,CAAC,CAAA;AAEF,iFAAiF;AACjF,OAAO,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,GAAG,EAAE,CAAC,CAAA","sourcesContent":["#!/usr/bin/env node\nimport { readFile, writeFile } from 'node:fs/promises'\nimport { resolve } from 'node:path'\nimport { pathToFileURL } from 'node:url'\nimport type { AnyRouter } from '@orpc/server'\nimport { CliError, defineCli, defineCommand } from 'hanzio/cli'\nimport { z } from 'zod'\nimport { createStreamManifestAsync, renderStreamManifest } from './router.js'\n\nconst streamManifest = defineCommand({\n\tdescription: `Generate the stream manifest for createRpcLink({ streamPaths })\n\nImports the router (export \"default\" unless #export is given) and writes the\npaths of its streaming routes for createRpcLink({ streamPaths }). The file is\nonly written when its content changes. --check writes nothing and exits 1 when\nthe file is missing or stale. Importing the router runs its module code; run\nTypeScript routers with a runtime that loads .ts (bun, tsx, node >= 22.18).`,\n\tinput: z.object({\n\t\tmodule: z\n\t\t\t.string()\n\t\t\t.describe('Router module, with #export for a named export')\n\t\t\t.meta({ positional: true }),\n\t\tout: z.string().describe('Manifest to write: file.ts or file.json'),\n\t\tname: z\n\t\t\t.string()\n\t\t\t.optional()\n\t\t\t.describe('Exported constant name in a .ts file'),\n\t\tcheck: z.boolean().describe('Exit 1 when the file is missing or stale')\n\t}),\n\trun: async (input) => {\n\t\tconst [modulePath = '', exportName = 'default'] = input.module.split('#')\n\t\tconst loaded: Record<string, unknown> = await import(\n\t\t\tpathToFileURL(resolve(modulePath)).href\n\t\t)\n\t\tconst router = loaded[exportName]\n\t\tif (!router || typeof router !== 'object')\n\t\t\tthrow new CliError(\n\t\t\t\t`orpc-fn: ${modulePath} has no router export \"${exportName}\"`,\n\t\t\t\t{ exitCode: 2 }\n\t\t\t)\n\t\tconst out = resolve(input.out)\n\t\tconst source = renderStreamManifest(\n\t\t\tawait createStreamManifestAsync(router as AnyRouter),\n\t\t\t{ format: out.endsWith('.json') ? 'json' : 'ts', name: input.name }\n\t\t)\n\t\tconst current = await readFile(out, 'utf8').catch(() => undefined)\n\t\tif (current === source) return\n\t\tif (input.check)\n\t\t\tthrow new CliError(\n\t\t\t\t`orpc-fn: ${input.out} is stale; rerun without --check to update it`\n\t\t\t)\n\t\tawait writeFile(out, source)\n\t\treturn `orpc-fn: wrote ${input.out}`\n\t}\n})\n\nconst cli = defineCli({\n\tname: 'orpc-fn',\n\tcommands: { 'stream-manifest': streamManifest }\n})\n\n// Exit explicitly: the imported router may hold open database or broker handles.\nprocess.exit(await cli.run())\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "orpc-fn",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
4
4
  "description": "Define a backend function once: a typed oRPC procedure with tracing, logging, guards, injected handler extras, nested calls and live queries over Redis.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -128,7 +128,7 @@
128
128
  "test:client-bundle": "bun scripts/check-client-bundle.ts"
129
129
  },
130
130
  "dependencies": {
131
- "hanzio": "^3.1.0"
131
+ "hanzio": "^3.3.0"
132
132
  },
133
133
  "peerDependencies": {
134
134
  "@mastra/core": "^1.51.0",
package/src/cli.ts CHANGED
@@ -8,8 +8,13 @@ import { z } from 'zod'
8
8
  import { createStreamManifestAsync, renderStreamManifest } from './router.js'
9
9
 
10
10
  const streamManifest = defineCommand({
11
- description:
12
- "Write the paths of a router's streaming routes for createRpcLink({ streamPaths }), only when they change. Importing the router runs its module code: load .ts routers with bun, tsx or node >= 22.18.",
11
+ description: `Generate the stream manifest for createRpcLink({ streamPaths })
12
+
13
+ Imports the router (export "default" unless #export is given) and writes the
14
+ paths of its streaming routes for createRpcLink({ streamPaths }). The file is
15
+ only written when its content changes. --check writes nothing and exits 1 when
16
+ the file is missing or stale. Importing the router runs its module code; run
17
+ TypeScript routers with a runtime that loads .ts (bun, tsx, node >= 22.18).`,
13
18
  input: z.object({
14
19
  module: z
15
20
  .string()