リファレンス
niyase-plugin CLI・useNiyase() ブリッジ・型・ヘルパーの一覧。
@niyase/plugin-sdk の公開 API のうち、現時点で確定している範囲の一覧です。SDK は開発中のため今後も拡充します。
CLI(niyase-plugin)
| コマンド | 説明 |
|---|---|
new | @scope/name の雛形を生成 |
build | IIFE バンドルを生成(--entry / --out / --minify) |
lint | tsc + validateManifest() + 禁止 API 走査 |
test | vitest を実行 |
dev | ローカルプレビュー(--port) |
publish | ビルド + 検証 + 申請(--dry-run / --token / --registry) |
ブリッジ useNiyase()
data / core / connections / context / i18n / navigate / toast / palette。
connections は PROVIDER-CLIENT 型専用で、単独プラグインから呼ぶと CONNECTION_NOT_FOUND 系のエラーになります。
詳細は UI 統合 と コア API 連携。
import { createNiyase, useNiyase, register } from "@niyase/plugin-sdk";
// エントリで: createNiyase(); register("@scope/name", Root);
// 任意の場所で: const niyase = useNiyase();
マニフェスト(@niyase/plugin-sdk/manifest)
import {
defineManifest,
validateManifest,
parseManifestOrThrow,
type PluginManifest,
} from "@niyase/plugin-sdk/manifest";
defineManifest(m): 型付き identity(補完用)validateManifest(input):{ ok: true, manifest } | { ok: false, errors }(zod、niyase-plugin lintと同一の検証)parseManifestOrThrow(input): 検証に失敗すると例外を投げる版
マニフェストの各フィールドの詳細は マニフェスト を参照してください。
型
マニフェスト関連(@niyase/plugin-sdk/manifest): PluginManifest / PluginAudience / PluginTableDef(テーブルごとに resource 宣言が必須・rowScope は任意)/ PluginColumnDef(masked で列マスク)/ PluginPaletteMetadata / PluginScope / PluginVisibility / Industry / IntentCategory。
PluginIndustryPreset/PluginI18nTermsも後方互換のため型としては残っていますが、業種プリセットの仕組み自体は廃止済みです(はじめに の分類軸を参照)。新規プラグインでは使わないでください。
ブリッジ関連(@niyase/plugin-sdk): NiyaseBridge / NiyaseContextValue / NiyaseDataClient / NiyaseCoreClient / NiyaseConnectionsClient / NiyaseErrorCode。
その他のエクスポート(@niyase/plugin-sdk)
| エクスポート | 用途 |
|---|---|
pluginTableName(pluginId, table) | 物理テーブル名(plg_<scope>_<name>_<table>)を算出するヘルパー |
pluginTablePrefix(pluginId) | プラグインのテーブル接頭辞(plg_<scope>_<name>)を算出するヘルパー |
ManifestApp / MANIFEST_APP_CSS | 宣言的な config から一覧+フォームの汎用 CRUD UI を描画するコンポーネント |
テスト用ヘルパー(@niyase/plugin-sdk/host)
createTestHost({ manifest, context }): MOCK バックエンドに繋いだ headless なブリッジを返すrunBridgeConformance(bridge): ブリッジ契約の最小適合チェック(REAL / MOCK の振る舞いパリティを検証)
import { createTestHost } from "@niyase/plugin-sdk/host";
const { niyase } = createTestHost({ manifest, context });
await niyase.ready;
const res = await niyase.data.list("task");
サンプル
最良のリファレンスは、ローカルプレビュー(niyase-plugin dev)で動く自分の雛形です。
公式プラグイン @niyase/todos(最小の SDK/bundle 方式リファレンス実装)も参考になります。