@konspire/shared

v0.1.0

Published

Shared public primitives for the Konspire monorepo: URL helpers used by both server and client packages. Stays small + dependency-free so the CLI / renderer / future SDK packages can install it from npm without dragging in any internal infrastructure code

Readme

@konspire/shared

Tiny, dependency-free helpers shared between @konspire/cli, @konspire/renderer, and the Konspire API server. The bar for adding something here is "external consumers need it AND it has zero or minimal runtime dependencies".

You usually don't depend on this directly — it's pulled in transitively when you npm install @konspire/cli.

Install

npm install @konspire/shared

Exports

apiPath(...segments)

Type-safe joiner for Konspire API URL paths. Returns the full path including the /api/default/v1 prefix that all v1 endpoints sit under.

import { apiPath, API_PATH_PREFIX } from '@konspire/shared';

apiPath();                                // '/api/default/v1'
apiPath('me');                            // '/api/default/v1/me'
apiPath('plans', 'foo-bar_rev1', 'state'); // '/api/default/v1/plans/foo-bar_rev1/state'

API_PATH_PREFIX;                          // '/api/default/v1'

Segments are NOT re-encoded — the caller is responsible for encodeURIComponent on dynamic values that might contain /. This matches how URL and URLSearchParams treat input.

Why is the prefix /api/default/v1?

Konspire deploys on DigitalOcean App Platform's Functions component, which wraps OpenWhisk's web-actions gateway. The gateway URL pattern is /api/<package>/<function>/<rest>/api is the gateway prefix (always present, not user-controlled), and <package> is part of the URL even when named default. See docs/ARCHITECTURE.md §11.6 in the Konspire repo for the full rationale and the "$0 idle vs URL aesthetics" tradeoff.

Major-version versioning lives in the <function> segment. A future v2 ships as a sibling function with its own URL prefix; the public API surface is "additive only" inside a major version.

Links

License

MIT