@squadbase/vantage 0.5.2 → 0.5.3-dev.71d2349

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
@@ -7,7 +7,7 @@ You write `index.tsx`. Vantage owns routing, React, TanStack Query, Tailwind v4,
7
7
  the UI kit, the dev server, the optional API server, and the build. There is no
8
8
  config file.
9
9
 
10
- > **Status: prototype (v0.5.2).** APIs may still change between releases.
10
+ > **Status: prototype (v0.5.3).** APIs may still change between releases.
11
11
 
12
12
  ## Install
13
13
 
@@ -111,8 +111,9 @@ skipped with their location reported instead of copied a second time.
111
111
 
112
112
  ## Documentation
113
113
 
114
- Full guides live in the [Vantage docs](https://github.com/squadbase/vantage-framework/tree/main/docs)
115
- (bilingual — English under `docs/content/en`, Japanese under `docs/content`).
114
+ Full guides live in the
115
+ [Vantage docs](https://github.com/squadbase/squadbase-monorepo/tree/main/packages/vantage/site)
116
+ (bilingual — English under `site/content/en`, Japanese under `site/content`).
116
117
 
117
118
  ## License
118
119
 
package/dist/index.d.ts CHANGED
@@ -10,6 +10,6 @@ import 'react';
10
10
  */
11
11
 
12
12
  /** Framework version, kept in sync with package.json at build time. */
13
- declare const VERSION = "0.5.2";
13
+ declare const VERSION = "0.5.3";
14
14
 
15
15
  export { VERSION };
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@ function definePage(config) {
6
6
  }
7
7
 
8
8
  // src/index.ts
9
- var VERSION = "0.5.2";
9
+ var VERSION = "0.5.3";
10
10
 
11
11
  export { VERSION, definePage };
12
12
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/runtime/define-page.ts","../src/index.ts"],"names":[],"mappings":";;;AAyCO,SAAS,WAAW,MAAA,EAAgC;AACzD,EAAA,OAAO,MAAA;AACT;;;AChCO,IAAM,OAAA,GAAU","file":"index.js","sourcesContent":["import type { ComponentType, ReactNode } from \"react\"\n\n/**\n * Optional per-page configuration. The only required part of a page module is\n * its default-exported component; `definePage` covers everything else.\n */\nexport interface PageConfig {\n /** Document title applied when this route is active. */\n title?: string\n /** Description metadata for the page. */\n description?: string\n /**\n * Short label for navigation built from `useRoutes()`. Defaults to `title`,\n * which is often too long for a nav (\"Overview · Acme Analytics\").\n */\n navLabel?: string\n /**\n * Component rendered while the route is loading.\n * (Reserved — not yet applied to Vantage's code-split routes in the prototype.)\n */\n pendingComponent?: ComponentType\n /**\n * Component rendered when the route throws.\n * (Reserved — not yet applied to Vantage's code-split routes in the prototype.)\n */\n errorComponent?: ComponentType<{ error: unknown }>\n /**\n * Validate/transform the URL search params for this route.\n * (Reserved — not yet applied to Vantage's code-split routes in the prototype.)\n */\n validateSearch?: (search: Record<string, unknown>) => Record<string, unknown>\n}\n\n/**\n * Declare optional page configuration.\n *\n * ```tsx\n * export const page = definePage({ title: \"Monthly Analysis\" })\n * export default function MonthlyAnalysis() { return <div/> }\n * ```\n */\nexport function definePage(config: PageConfig): PageConfig {\n return config\n}\n\n/** Convenience type for a Vantage page component. */\nexport type PageComponent = ComponentType & { (): ReactNode }\n","/**\n * `@squadbase/vantage` — public runtime surface.\n *\n * The only import most pages need. Server state lives in\n * `@squadbase/vantage/query`, navigation in `@squadbase/vantage/router`,\n * UI in `@squadbase/vantage/ui`, and API types in `@squadbase/vantage/server`.\n */\nexport { definePage } from \"./runtime/define-page\"\nexport type { PageConfig, PageComponent } from \"./runtime/define-page\"\n\n/** Framework version, kept in sync with package.json at build time. */\nexport const VERSION = \"0.5.2\"\n"]}
1
+ {"version":3,"sources":["../src/runtime/define-page.ts","../src/index.ts"],"names":[],"mappings":";;;AAyCO,SAAS,WAAW,MAAA,EAAgC;AACzD,EAAA,OAAO,MAAA;AACT;;;AChCO,IAAM,OAAA,GAAU","file":"index.js","sourcesContent":["import type { ComponentType, ReactNode } from \"react\"\n\n/**\n * Optional per-page configuration. The only required part of a page module is\n * its default-exported component; `definePage` covers everything else.\n */\nexport interface PageConfig {\n /** Document title applied when this route is active. */\n title?: string\n /** Description metadata for the page. */\n description?: string\n /**\n * Short label for navigation built from `useRoutes()`. Defaults to `title`,\n * which is often too long for a nav (\"Overview · Acme Analytics\").\n */\n navLabel?: string\n /**\n * Component rendered while the route is loading.\n * (Reserved — not yet applied to Vantage's code-split routes in the prototype.)\n */\n pendingComponent?: ComponentType\n /**\n * Component rendered when the route throws.\n * (Reserved — not yet applied to Vantage's code-split routes in the prototype.)\n */\n errorComponent?: ComponentType<{ error: unknown }>\n /**\n * Validate/transform the URL search params for this route.\n * (Reserved — not yet applied to Vantage's code-split routes in the prototype.)\n */\n validateSearch?: (search: Record<string, unknown>) => Record<string, unknown>\n}\n\n/**\n * Declare optional page configuration.\n *\n * ```tsx\n * export const page = definePage({ title: \"Monthly Analysis\" })\n * export default function MonthlyAnalysis() { return <div/> }\n * ```\n */\nexport function definePage(config: PageConfig): PageConfig {\n return config\n}\n\n/** Convenience type for a Vantage page component. */\nexport type PageComponent = ComponentType & { (): ReactNode }\n","/**\n * `@squadbase/vantage` — public runtime surface.\n *\n * The only import most pages need. Server state lives in\n * `@squadbase/vantage/query`, navigation in `@squadbase/vantage/router`,\n * UI in `@squadbase/vantage/ui`, and API types in `@squadbase/vantage/server`.\n */\nexport { definePage } from \"./runtime/define-page\"\nexport type { PageConfig, PageComponent } from \"./runtime/define-page\"\n\n/** Framework version, kept in sync with package.json at build time. */\nexport const VERSION = \"0.5.3\"\n"]}
@@ -15,6 +15,7 @@ All of these target an agent that is **building a Vantage app**.
15
15
  | `vantage-app` | Creating an app, and growing a single-file `index.tsx` SPA into a fullstack app with `server/api`, nested layouts, dynamic routes, and 404/error pages |
16
16
  | `vantage-add-feature` | Adding a page / API / UI / block (`vantage add` through to `check` / `routes`) |
17
17
  | `vantage-pitfalls` | A pitfalls reference (Base UI ≠ Radix, `SelectValue` behavior, never importing `server/` from the client, and more) |
18
+ | `project-storage` | Working with Squadbase Project Storage (uploaded files) from the browser — listing, embedding images / video / PDFs, uploading. For apps running on Squadbase |
18
19
 
19
20
  ## Placing them
20
21
 
@@ -37,6 +38,7 @@ under the root, under `.claude/skills/`, under `.squadbase/skills/`, it doesn't
37
38
  ```text
38
39
  $ vantage add skill
39
40
  Bundled skills:
41
+ project-storage .claude/skills/project-storage/
40
42
  vantage-add-feature .claude/skills/vantage-add-feature/
41
43
  vantage-app .claude/skills/vantage-app/
42
44
  vantage-pitfalls not placed
@@ -56,7 +58,8 @@ your-app/
56
58
  └── skills/
57
59
  ├── vantage-app/SKILL.md
58
60
  ├── vantage-add-feature/SKILL.md
59
- └── vantage-pitfalls/SKILL.md
61
+ ├── vantage-pitfalls/SKILL.md
62
+ └── project-storage/SKILL.md
60
63
  ```
61
64
 
62
65
  Claude Code discovers `.claude/skills/` automatically. The agent loads and follows the matching
@@ -9,6 +9,23 @@ What changed in each Vantage release. Newest is on top.
9
9
  > minor release may include backwards-incompatible changes. A patch is limited to
10
10
  > backwards-compatible additions and bug fixes.
11
11
 
12
+ ## v0.5.3
13
+
14
+ Adds a bundled skill for working with Squadbase Project Storage from the browser.
15
+ Anything on `^0.5.0` picks this up as-is.
16
+
17
+ ### Added
18
+
19
+ - **A `project-storage` skill now ships with Vantage.** It covers reading and
20
+ writing Squadbase Project Storage — the files a user uploaded — from a page or
21
+ component through `useStorage()` from `@squadbase/react`: listing files,
22
+ embedding images / video / PDFs (including refreshing the short-lived URL),
23
+ reading file contents, and uploading, deleting or moving.
24
+
25
+ Place it like any other skill with `vantage add skill --all` (add `--dir` to
26
+ choose where it lands). No library code changed, so no app-side change is
27
+ needed.
28
+
12
29
  ## v0.5.2
13
30
 
14
31
  Fixes an already-open tab getting stuck on chunks from a build that is no longer
@@ -15,6 +15,7 @@ Vantage は **Claude Code の Agent Skills** を同梱しています。Skill
15
15
  | `vantage-app` | アプリの新規作成と、`index.tsx` 単体の SPA から `server/api`・ネストレイアウト・動的ルート・404/error を備えた fullstack への拡張 |
16
16
  | `vantage-add-feature` | ページ / API / UI / ブロックの追加(`vantage add` + `check` / `routes` までの一連) |
17
17
  | `vantage-pitfalls` | 落とし穴リファレンス(Base UI ≠ Radix、`SelectValue` の挙動、クライアントから `server/` を import しない など) |
18
+ | `project-storage` | Squadbase の Project Storage(アップロード済みファイル)をブラウザから扱う(一覧、画像 / 動画 / PDF の埋め込み、アップロード)。Squadbase 上で動くアプリ向け |
18
19
 
19
20
  ## 配置する
20
21
 
@@ -37,6 +38,7 @@ vantage add skill --all --force # 配置済みのコピーをそ
37
38
  ```text
38
39
  $ vantage add skill
39
40
  Bundled skills:
41
+ project-storage .claude/skills/project-storage/
40
42
  vantage-add-feature .claude/skills/vantage-add-feature/
41
43
  vantage-app .claude/skills/vantage-app/
42
44
  vantage-pitfalls not placed
@@ -56,7 +58,8 @@ your-app/
56
58
  └── skills/
57
59
  ├── vantage-app/SKILL.md
58
60
  ├── vantage-add-feature/SKILL.md
59
- └── vantage-pitfalls/SKILL.md
61
+ ├── vantage-pitfalls/SKILL.md
62
+ └── project-storage/SKILL.md
60
63
  ```
61
64
 
62
65
  `.claude/skills/` は Claude Code が自動で認識します。エージェントはタスクに応じて、対応する
@@ -8,6 +8,21 @@ Vantage のリリースごとの変更点です。新しいものが上に来ま
8
8
  > まだプロトタイプ(**0.x**)です。0.x の間は **minor が実質のメジャー**扱いで、後方互換性の
9
9
  > ない変更は minor で入ることがあります。patch は後方互換の機能追加とバグ修正のみです。
10
10
 
11
+ ## v0.5.3
12
+
13
+ Squadbase の Project Storage をブラウザから扱うための Skill を同梱しました。`^0.5.0` を
14
+ 指定していればそのまま入ります。
15
+
16
+ ### 追加
17
+
18
+ - **`project-storage` skill を同梱しました。** Squadbase の Project Storage(ユーザーが
19
+ アップロードしたファイル)を、`@squadbase/react` の `useStorage()` でページやコンポーネント
20
+ から扱う手順書です。ファイル一覧、画像 / 動画 / PDF の埋め込み(短命な URL の取り直しを
21
+ 含む)、中身の読み取り、アップロードと削除・移動を扱います。
22
+
23
+ 配置は他の skill と同じで `vantage add skill --all`(置き場を選ぶなら `--dir`)。
24
+ ライブラリのコードは変わっていないので、アプリ側の変更は要りません。
25
+
11
26
  ## v0.5.2
12
27
 
13
28
  再公開でビルドが差し替わったとき、開いたままのタブが古い chunk を取りに行って動かなくなる
package/package.json CHANGED
@@ -1,18 +1,18 @@
1
1
  {
2
2
  "name": "@squadbase/vantage",
3
- "version": "0.5.2",
3
+ "version": "0.5.3-dev.71d2349",
4
4
  "description": "Data dashboard framework for Squadbase Editor. Vite-powered, config-free, one-file first.",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "author": "Squadbase",
8
- "homepage": "https://github.com/squadbase/vantage-framework/tree/main/packages/vantage#readme",
8
+ "homepage": "https://github.com/squadbase/squadbase-monorepo/tree/main/packages/vantage#readme",
9
9
  "repository": {
10
10
  "type": "git",
11
- "url": "git+https://github.com/squadbase/vantage-framework.git",
11
+ "url": "git+https://github.com/squadbase/squadbase-monorepo.git",
12
12
  "directory": "packages/vantage"
13
13
  },
14
14
  "bugs": {
15
- "url": "https://github.com/squadbase/vantage-framework/issues"
15
+ "url": "https://github.com/squadbase/squadbase-monorepo/issues"
16
16
  },
17
17
  "keywords": [
18
18
  "vantage",
@@ -25,10 +25,11 @@
25
25
  "tanstack"
26
26
  ],
27
27
  "engines": {
28
- "node": ">=20"
28
+ "node": ">=22"
29
29
  },
30
30
  "publishConfig": {
31
- "access": "public"
31
+ "access": "public",
32
+ "registry": "https://registry.npmjs.org"
32
33
  },
33
34
  "bin": {
34
35
  "vantage": "./dist/cli.js"
@@ -93,7 +94,12 @@
93
94
  "dev": "tsup --watch --no-dts",
94
95
  "dev:types": "tsc --noEmit --watch",
95
96
  "typecheck": "tsc --noEmit",
96
- "prepublishOnly": "node scripts/build-docs.mjs && node scripts/build.mjs"
97
+ "type-check": "tsc --noEmit",
98
+ "prepublishOnly": "node scripts/build-docs.mjs && node scripts/build.mjs",
99
+ "release": "npm publish --@squadbase:registry=https://registry.npmjs.org",
100
+ "site:install": "npm --prefix site install",
101
+ "site:dev": "npm --prefix site run dev",
102
+ "site:build": "npm --prefix site run build"
97
103
  },
98
104
  "dependencies": {
99
105
  "@base-ui/react": "^1.6.0",
@@ -0,0 +1,157 @@
1
+ ---
2
+ name: project-storage
3
+ description: Squadbase の Project Storage(アップロード済みファイル)を @squadbase/react の useStorage() でブラウザから扱う手順。ファイル一覧、画像 / 動画 / PDF の埋め込み、中身の読み取り、アップロードと削除・移動。ページやコンポーネントがアップロード済みファイルを表示・埋め込み・アップロードするときに参照する。
4
+ ---
5
+
6
+ # Project Storage(ブラウザ側)
7
+
8
+ Squadbase の **Project Storage** を React コンポーネントから読み書きする手順。Squadbase 上で
9
+ 動くアプリでは資格情報も設定も要らず、そのまま動く。サーバー(`server/api/**`)からストレージを
10
+ 触る API は別物で、ここでは扱わない。
11
+
12
+ ## import は `@squadbase/react` から直接
13
+
14
+ 「import は `@squadbase/vantage` のサブパス経由」はフレームワークが所有するものの話。
15
+ **`@squadbase/react` は Squadbase プラットフォームの SDK なので直接 import する**
16
+ (`SquadbaseProvider` / `useUser` と同じ)。
17
+
18
+ ```tsx
19
+ import { useStorage } from "@squadbase/react"
20
+
21
+ const storage = useStorage()
22
+ // 呼び出しはすべて storage.uploads.* の下
23
+ ```
24
+
25
+ `useStorage()` が返すクライアントは安定なので、コンポーネント先頭で呼んで `useQuery` /
26
+ `useMutation` の中で使ってよい。データ取得のフックは `@squadbase/vantage/query` から取る
27
+ (`@tanstack/*` は直接 import しない)。
28
+
29
+ ## API
30
+
31
+ すべて async。`key` はストレージ内の**相対**パス(例: `reports/2025-q1.pdf`)で、先頭に
32
+ スラッシュを付けない。
33
+
34
+ 読み取り:
35
+
36
+ - `list(prefix?, options?)` → `{ objects, commonPrefixes, nextCursor? }`。`objects` は
37
+ `{ key, size, lastModified }[]`。`options.delimiter = "/"` でフォルダ表示(サブフォルダが
38
+ `commonPrefixes` に入る)、省略すると再帰的なフラット一覧。`options.limit` / `options.cursor`
39
+ でページング(`cursor` は前回の `nextCursor`)
40
+ - `head(key)` → `{ key, size, contentType, createdAt }`。メタ情報だけで本体は取らない
41
+ - `getUrl(key)` → `{ url, expiresAt }`。埋め込み用の一時 URL
42
+ - `get(key)` → 生の `Response`。`.json()` / `.text()` / `.blob()` / `.arrayBuffer()` で読む
43
+
44
+ 書き込み:
45
+
46
+ - `put(key, data, options?)` → `void`。`data` は `Blob`(`File` を含む) / `ArrayBuffer` /
47
+ `Uint8Array` / `string`
48
+ - `delete(key)` → `void`
49
+ - `copy(srcKey, destKey, options?)` / `move(srcKey, destKey, options?)` → `void`
50
+
51
+ ## 一覧を出す
52
+
53
+ ```tsx
54
+ import { useStorage } from "@squadbase/react"
55
+ import { useQuery } from "@squadbase/vantage/query"
56
+
57
+ const storage = useStorage()
58
+ const { data, isPending, isError } = useQuery({
59
+ queryKey: ["storage", "list", prefix],
60
+ queryFn: () => storage.uploads.list(prefix, { delimiter: "/" }),
61
+ })
62
+ ```
63
+
64
+ `data.commonPrefixes` をフォルダ、`data.objects` をファイルとして描く。プレフィックス配下を
65
+ まとめて出すなら `delimiter` を省く。
66
+
67
+ ## 画像 / 動画 / PDF を埋め込む
68
+
69
+ 埋め込みには URL が要るので `getUrl` を使う。**URL には期限がある**ので、切れる前に取り直す:
70
+
71
+ ```tsx
72
+ import { useStorage } from "@squadbase/react"
73
+ import { useQuery } from "@squadbase/vantage/query"
74
+
75
+ function useStorageUrl(key: string) {
76
+ const storage = useStorage()
77
+ return useQuery({
78
+ queryKey: ["storage", "url", key],
79
+ queryFn: () => storage.uploads.getUrl(key),
80
+ refetchInterval: (query) => {
81
+ const expiresAt = query.state.data?.expiresAt
82
+ if (!expiresAt) return false
83
+ // 期限の 60 秒前に取り直す
84
+ return Math.max(0, new Date(expiresAt).getTime() - Date.now() - 60_000)
85
+ },
86
+ })
87
+ }
88
+ ```
89
+
90
+ ```tsx
91
+ import { ErrorState, Loading } from "@squadbase/vantage/ui"
92
+
93
+ const { data, isPending, isError } = useStorageUrl("reports/cover.png")
94
+ if (isPending) return <Loading />
95
+ if (isError) return <ErrorState message="ファイルを読み込めませんでした" />
96
+ return <img src={data.url} alt="" className="w-full rounded-lg" />
97
+ ```
98
+
99
+ 動画は `<video src={data.url} controls className="w-full rounded-lg" />`、PDF は
100
+ `<iframe src={data.url} className="h-[80vh] w-full rounded-lg border border-border" />`。
101
+
102
+ ## 中身を JS で読む
103
+
104
+ ```tsx
105
+ const { data } = useQuery({
106
+ queryKey: ["storage", "content", key],
107
+ queryFn: async () => {
108
+ const res = await storage.uploads.get(key)
109
+ return (await res.json()) as Row[] // または res.text()
110
+ },
111
+ })
112
+ ```
113
+
114
+ ## アップロードする
115
+
116
+ ```tsx
117
+ import { useStorage } from "@squadbase/react"
118
+ import { useMutation, useQueryClient } from "@squadbase/vantage/query"
119
+
120
+ const storage = useStorage()
121
+ const queryClient = useQueryClient()
122
+ const upload = useMutation({
123
+ mutationFn: (file: File) =>
124
+ storage.uploads.put(`uploads/${file.name}`, file, { contentType: file.type }),
125
+ onSuccess: () => queryClient.invalidateQueries({ queryKey: ["storage", "list"] }),
126
+ })
127
+
128
+ <input
129
+ type="file"
130
+ onChange={(e) => {
131
+ const file = e.target.files?.[0]
132
+ if (file) upload.mutate(file)
133
+ }}
134
+ />
135
+ ```
136
+
137
+ `File` はそのまま `put` に渡す。書き込み後は該当する `["storage", "list", …]` を invalidate して
138
+ UI を追従させる。
139
+
140
+ ## 落とし穴
141
+
142
+ - **`getUrl` の URL は短命。** 結果を永続化したり長寿命のキャッシュに入れたりしない。
143
+ `expiresAt` の前に取り直す(上のフック)。`<img src>` に一度入れて放置すると、開いたままの
144
+ 画面で後から読み込まれた分が失敗する
145
+ - **`put` の `contentType` の既定は `application/octet-stream`。** 後で埋め込むもの(画像・動画・
146
+ PDF)には `file.type` を必ず渡す。付けないとブラウザが表示せずダウンロードに落ちる
147
+ - **`key` は相対パス。** 先頭にスラッシュを付けない。`getUrl` を通さず `<img src="/foo.png">` の
148
+ ような静的パスで参照しない ― ストレージはアプリの `public/` ではない
149
+ - **`copy` / `move` は既定で既存の宛先を上書きする。** 残したいときは `{ overwrite: false }`
150
+ - **サーバー(`server/api/**`)からは呼ばない。** `useStorage` はブラウザ側の API
151
+
152
+ ---
153
+
154
+ ## 関連スキル
155
+
156
+ - `vantage-add-feature` — ページ / API / コンポーネントを 1 つ足す手順
157
+ - `vantage-pitfalls` — UI・配色・ルーティングの落とし穴
@@ -379,6 +379,7 @@ body・レスポンスの status と形)まで出る。`vantage check --json` /
379
379
  - **`vantage-app`** — アプリを一から作る / 構成を広げるときの進め方と検証の順序
380
380
  - **`vantage-add-feature`** — 既存アプリに page / api / ui を 1 つ足す定型
381
381
  - **`vantage-pitfalls`** — Base UI(≠ Radix)の癖など、静かに壊れる落とし穴のリファレンス
382
+ - **`project-storage`** — Squadbase の Project Storage(アップロード済みファイル)をブラウザから読み書きする
382
383
 
383
384
  手順書の本体は `SKILL.md` というファイルで、置き場所はアプリによって違う(ルート直下・
384
385
  `.claude/skills/`・`.squadbase/skills/` など)。**探す必要はない ― CLI が探す:**