@patodo/localapp 0.1.0
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/.localapp-artifact.json +2731 -0
- package/LICENSE +21 -0
- package/README.md +288 -0
- package/bin/localapp.mjs +34182 -0
- package/package.json +21 -0
- package/runtime/bootstrap/localapp-daemon-bootstrap.mjs +150 -0
- package/runtime/native/adapter-manifest.json +85 -0
- package/runtime/native/darwin-arm64/LocalAppBridge.app/Contents/Info.plist +21 -0
- package/runtime/native/darwin-arm64/LocalAppBridge.app/Contents/MacOS/LocalAppBridge +0 -0
- package/runtime/native/darwin-arm64/LocalAppBridge.app/Contents/Resources/localapp-native-ipc-client.mjs +940 -0
- package/runtime/native/darwin-arm64/LocalAppBridge.app/Contents/_CodeSignature/CodeResources +128 -0
- package/runtime/native/darwin-x64/LocalAppBridge.app/Contents/Info.plist +21 -0
- package/runtime/native/darwin-x64/LocalAppBridge.app/Contents/MacOS/LocalAppBridge +0 -0
- package/runtime/native/darwin-x64/LocalAppBridge.app/Contents/Resources/localapp-native-ipc-client.mjs +940 -0
- package/runtime/native/darwin-x64/LocalAppBridge.app/Contents/_CodeSignature/CodeResources +128 -0
- package/runtime/native/linux-x64/localapp-native-ipc-client.mjs +940 -0
- package/runtime/native/linux-x64/localapp-notifications +0 -0
- package/runtime/native/win32-x64/localapp-native-ipc-client.mjs +940 -0
- package/runtime/native/win32-x64/localapp-native.exe +0 -0
- package/runtime/server/.localapp-server-runtime.json +133 -0
- package/runtime/server/bin/server-cli.cjs +8343 -0
- package/runtime/server/bin/server.mjs +8 -0
- package/runtime/server/bin/worker.cjs +144339 -0
- package/runtime/server/node_modules/sql.js/dist/sql-wasm.js +185 -0
- package/runtime/server/node_modules/sql.js/dist/sql-wasm.wasm +0 -0
- package/runtime/server/node_modules/sql.js/package.json +58 -0
- package/runtime/server/package.json +11 -0
- package/runtime/server/runner/localapp-runner.mjs +324 -0
- package/runtime/server/web/404.html +1 -0
- package/runtime/server/web/_next/static/CqtRUQyhpQ2FmEc3vaVz3/_buildManifest.js +1 -0
- package/runtime/server/web/_next/static/CqtRUQyhpQ2FmEc3vaVz3/_ssgManifest.js +1 -0
- package/runtime/server/web/_next/static/chunks/184-184da63eba05808f.js +1 -0
- package/runtime/server/web/_next/static/chunks/265-a58973dbf631dc41.js +1 -0
- package/runtime/server/web/_next/static/chunks/308-d74213c6f5179bf0.js +1 -0
- package/runtime/server/web/_next/static/chunks/416-53d48ad9442eb7b2.js +1 -0
- package/runtime/server/web/_next/static/chunks/448-280e06e915001cb5.js +1 -0
- package/runtime/server/web/_next/static/chunks/66-6f6658280a10fbca.js +1 -0
- package/runtime/server/web/_next/static/chunks/740d80ee-6c0a9504f1fd46f8.js +1 -0
- package/runtime/server/web/_next/static/chunks/86-7105ac54171494a1.js +1 -0
- package/runtime/server/web/_next/static/chunks/900-743e38de13217291.js +1 -0
- package/runtime/server/web/_next/static/chunks/app/(dashboard)/inbox/page-32b885c019043e48.js +1 -0
- package/runtime/server/web/_next/static/chunks/app/(dashboard)/layout-4b3a212263712a5c.js +1 -0
- package/runtime/server/web/_next/static/chunks/app/(dashboard)/my/analytics/page-6af9adc14ccfa925.js +1 -0
- package/runtime/server/web/_next/static/chunks/app/(dashboard)/my/apps/[name]/settings/page-8b6f809eeccdbd22.js +1 -0
- package/runtime/server/web/_next/static/chunks/app/(dashboard)/my/apps/page-7f1ddf07889da248.js +1 -0
- package/runtime/server/web/_next/static/chunks/app/(dashboard)/my/dashboard/page-a25eb621fb18491d.js +1 -0
- package/runtime/server/web/_next/static/chunks/app/(dashboard)/my/device-actions/page-e6045823829567f7.js +1 -0
- package/runtime/server/web/_next/static/chunks/app/(dashboard)/my/device-notifications/page-377ed49cf55da81d.js +1 -0
- package/runtime/server/web/_next/static/chunks/app/(dashboard)/my/favorites/page-82f292daebf98a2f.js +1 -0
- package/runtime/server/web/_next/static/chunks/app/(dashboard)/my/groups/page-fe4ed80c7b11920f.js +1 -0
- package/runtime/server/web/_next/static/chunks/app/(dashboard)/my/info/page-d5d5075eec069ce3.js +1 -0
- package/runtime/server/web/_next/static/chunks/app/(dashboard)/my/keys/page-35ed01bf39a163b6.js +1 -0
- package/runtime/server/web/_next/static/chunks/app/(dashboard)/my/layout-5481d53aae3a0ce1.js +1 -0
- package/runtime/server/web/_next/static/chunks/app/(dashboard)/my/orgs/page-44c606ff2233f1a8.js +1 -0
- package/runtime/server/web/_next/static/chunks/app/(dashboard)/my/page-f2331bbbe09541aa.js +1 -0
- package/runtime/server/web/_next/static/chunks/app/(dashboard)/my/pages/page-6bf4e160a99411ce.js +1 -0
- package/runtime/server/web/_next/static/chunks/app/(dashboard)/my/peers/page-27041dd149601002.js +1 -0
- package/runtime/server/web/_next/static/chunks/app/(dashboard)/my/recent/page-f321688d374a8ff3.js +1 -0
- package/runtime/server/web/_next/static/chunks/app/(dashboard)/my/settings/page-64e724318dc3a584.js +1 -0
- package/runtime/server/web/_next/static/chunks/app/(dashboard)/my/studio/page-a2c0c34538ac62b3.js +1 -0
- package/runtime/server/web/_next/static/chunks/app/(dashboard)/my/subscriptions/page-57cdaafe12347e32.js +1 -0
- package/runtime/server/web/_next/static/chunks/app/(dashboard)/my/system/page-96d2e1f8c2fb22b0.js +1 -0
- package/runtime/server/web/_next/static/chunks/app/(dashboard)/my/tasks/page-bf16b78ed6749d78.js +1 -0
- package/runtime/server/web/_next/static/chunks/app/(dashboard)/my/users/page-c47d4524d2a156b8.js +1 -0
- package/runtime/server/web/_next/static/chunks/app/(dashboard)/page-f4641be7b88818a2.js +1 -0
- package/runtime/server/web/_next/static/chunks/app/_not-found/page-f4902e6b69eebd4c.js +1 -0
- package/runtime/server/web/_next/static/chunks/app/layout-5557bc90d966fded.js +1 -0
- package/runtime/server/web/_next/static/chunks/app/platform-shell/[userId]/[name]/page-da0d5e71857f33d1.js +1 -0
- package/runtime/server/web/_next/static/chunks/app/platform-shell-preview/page-52fa7e8c8b480934.js +1 -0
- package/runtime/server/web/_next/static/chunks/app/setup/page-9e29d6f66825a8f8.js +1 -0
- package/runtime/server/web/_next/static/chunks/framework-1c02a2e60068b586.js +1 -0
- package/runtime/server/web/_next/static/chunks/main-21ea4d4d10f4a256.js +1 -0
- package/runtime/server/web/_next/static/chunks/main-app-5b3c67453d8c5b99.js +1 -0
- package/runtime/server/web/_next/static/chunks/pages/_app-649f81c9fedecf29.js +1 -0
- package/runtime/server/web/_next/static/chunks/pages/_error-64e3bd84e2ecae08.js +1 -0
- package/runtime/server/web/_next/static/chunks/polyfills-42372ed130431b0a.js +1 -0
- package/runtime/server/web/_next/static/chunks/webpack-0bed2fdf6baa566e.js +1 -0
- package/runtime/server/web/_next/static/css/afdc0938fca59693.css +3 -0
- package/runtime/server/web/_next/static/media/013b72fa676f92e0-s.woff2 +0 -0
- package/runtime/server/web/_next/static/media/22a5144ee8d83bca-s.p.woff2 +0 -0
- package/runtime/server/web/_next/static/media/2b5b02fc7e511755-s.woff2 +0 -0
- package/runtime/server/web/_next/static/media/65f03d54ccadf4a8-s.woff2 +0 -0
- package/runtime/server/web/_next/static/media/7d4881bb7e1bf84d-s.p.woff2 +0 -0
- package/runtime/server/web/_next/static/media/9766a7e9e2e0ad5a-s.woff2 +0 -0
- package/runtime/server/web/_next/static/media/aa016aab0e6d1295-s.woff2 +0 -0
- package/runtime/server/web/_next/static/media/b66cf8e69499582a-s.woff2 +0 -0
- package/runtime/server/web/_next/static/media/b9408752a0c24fb9-s.woff2 +0 -0
- package/runtime/server/web/_next/static/media/e038a29029a234f2-s.woff2 +0 -0
- package/runtime/server/web/_next/static/media/f639721981034f88-s.woff2 +0 -0
- package/runtime/server/web/home/redline-launch-hero.png +0 -0
- package/runtime/server/web/inbox.html +1 -0
- package/runtime/server/web/inbox.txt +27 -0
- package/runtime/server/web/index.html +1 -0
- package/runtime/server/web/index.txt +27 -0
- package/runtime/server/web/my/analytics.html +1 -0
- package/runtime/server/web/my/analytics.txt +27 -0
- package/runtime/server/web/my/apps/placeholder/settings.html +1 -0
- package/runtime/server/web/my/apps/placeholder/settings.txt +24 -0
- package/runtime/server/web/my/apps.html +1 -0
- package/runtime/server/web/my/apps.txt +27 -0
- package/runtime/server/web/my/dashboard.html +1 -0
- package/runtime/server/web/my/dashboard.txt +27 -0
- package/runtime/server/web/my/device-actions.html +1 -0
- package/runtime/server/web/my/device-actions.txt +24 -0
- package/runtime/server/web/my/device-notifications.html +1 -0
- package/runtime/server/web/my/device-notifications.txt +24 -0
- package/runtime/server/web/my/favorites.html +1 -0
- package/runtime/server/web/my/favorites.txt +27 -0
- package/runtime/server/web/my/groups.html +1 -0
- package/runtime/server/web/my/groups.txt +27 -0
- package/runtime/server/web/my/info.html +1 -0
- package/runtime/server/web/my/info.txt +27 -0
- package/runtime/server/web/my/keys.html +1 -0
- package/runtime/server/web/my/keys.txt +27 -0
- package/runtime/server/web/my/orgs.html +1 -0
- package/runtime/server/web/my/orgs.txt +27 -0
- package/runtime/server/web/my/pages.html +1 -0
- package/runtime/server/web/my/pages.txt +27 -0
- package/runtime/server/web/my/peers.html +1 -0
- package/runtime/server/web/my/peers.txt +24 -0
- package/runtime/server/web/my/recent.html +1 -0
- package/runtime/server/web/my/recent.txt +27 -0
- package/runtime/server/web/my/settings.html +1 -0
- package/runtime/server/web/my/settings.txt +27 -0
- package/runtime/server/web/my/studio.html +1 -0
- package/runtime/server/web/my/studio.txt +24 -0
- package/runtime/server/web/my/subscriptions.html +1 -0
- package/runtime/server/web/my/subscriptions.txt +27 -0
- package/runtime/server/web/my/system.html +1 -0
- package/runtime/server/web/my/system.txt +24 -0
- package/runtime/server/web/my/tasks.html +1 -0
- package/runtime/server/web/my/tasks.txt +24 -0
- package/runtime/server/web/my/users.html +1 -0
- package/runtime/server/web/my/users.txt +27 -0
- package/runtime/server/web/my.html +1 -0
- package/runtime/server/web/my.txt +27 -0
- package/runtime/server/web/platform-shell/placeholder/placeholder.html +1 -0
- package/runtime/server/web/platform-shell/placeholder/placeholder.txt +23 -0
- package/runtime/server/web/platform-shell-preview.html +1 -0
- package/runtime/server/web/platform-shell-preview.txt +23 -0
- package/runtime/server/web/setup.html +1 -0
- package/runtime/server/web/setup.txt +23 -0
- package/template/.claude/skills/agent-tool-patterns/SKILL.md +195 -0
- package/template/.claude/skills/localapp/SKILL.md +80 -0
- package/template/.claude/skills/localapp-auth/SKILL.md +299 -0
- package/template/.claude/skills/localapp-business/SKILL.md +325 -0
- package/template/.claude/skills/localapp-data/SKILL.md +381 -0
- package/template/.claude/skills/localapp-device-actions/SKILL.md +60 -0
- package/template/.claude/skills/localapp-notify/SKILL.md +118 -0
- package/template/.claude/skills/localapp-transitions/SKILL.md +238 -0
- package/template/.claude/skills/localapp-ui/SKILL.md +67 -0
- package/template/.claude/skills/localapp-upload/SKILL.md +172 -0
- package/template/AGENTS.md +33 -0
- package/template/CLAUDE.md +117 -0
- package/template/ISSUES.md +32 -0
- package/template/backend/resources/work_items/mutations.json +83 -0
- package/template/backend/resources/work_items/queries.json +83 -0
- package/template/backend/resources/work_items/schema.json +31 -0
- package/template/backend/schemas/mutations.schema.json +15 -0
- package/template/backend/schemas/queries.schema.json +36 -0
- package/template/backend/schemas/resource-schema.schema.json +25 -0
- package/template/components.json +25 -0
- package/template/index.html +12 -0
- package/template/migrations/001_work_items.sql +6 -0
- package/template/package.json +70 -0
- package/template/postcss.config.js +5 -0
- package/template/runtime/dev-shell.tsx +6398 -0
- package/template/runtime/hooks/use-mobile.ts +19 -0
- package/template/runtime/issue-reference.ts +44 -0
- package/template/runtime/lib/utils.ts +6 -0
- package/template/runtime/package.json +14 -0
- package/template/runtime/platform-capabilities.json +109 -0
- package/template/runtime/sdk/agent/package.json +51 -0
- package/template/runtime/sdk/agent/src/agent-chat.tsx +188 -0
- package/template/runtime/sdk/agent/src/assistant-ui-adapter.ts +87 -0
- package/template/runtime/sdk/agent/src/context.ts +56 -0
- package/template/runtime/sdk/agent/src/dev-bridge.ts +21 -0
- package/template/runtime/sdk/agent/src/index.ts +19 -0
- package/template/runtime/sdk/agent/src/llm-adapter.ts +263 -0
- package/template/runtime/sdk/agent/src/native-registry.ts +61 -0
- package/template/runtime/sdk/agent/src/platform-runtime.ts +164 -0
- package/template/runtime/sdk/agent/src/postmessage-bridge.ts +60 -0
- package/template/runtime/sdk/agent/src/postmessage-types.ts +150 -0
- package/template/runtime/sdk/agent/src/tools.ts +70 -0
- package/template/runtime/sdk/agent/src/types.ts +27 -0
- package/template/runtime/sdk/agent/src/use-agent.ts +139 -0
- package/template/runtime/sdk/agent/src/use-register-edit-session.ts +54 -0
- package/template/runtime/sdk/agent/src/use-register-tools.ts +92 -0
- package/template/runtime/sdk/agent/tests/platform-runtime.test.ts +154 -0
- package/template/runtime/sdk/agent/tests/postmessage-bridge.test.ts +119 -0
- package/template/runtime/sdk/agent/tests/shell-integration.test.ts +71 -0
- package/template/runtime/sdk/agent/tests/use-register-edit-session.test.tsx +125 -0
- package/template/runtime/sdk/agent/tests/use-register-tools.test.ts +208 -0
- package/template/runtime/sdk/agent/tsconfig.json +18 -0
- package/template/runtime/sdk/agent/vitest.config.ts +8 -0
- package/template/runtime/sdk/backend/package.json +15 -0
- package/template/runtime/sdk/backend/src/index.ts +92 -0
- package/template/runtime/sdk/backend/tsconfig.json +8 -0
- package/template/runtime/sdk/core/package.json +15 -0
- package/template/runtime/sdk/core/src/client.ts +317 -0
- package/template/runtime/sdk/core/src/collaboration.ts +66 -0
- package/template/runtime/sdk/core/src/desktop.ts +469 -0
- package/template/runtime/sdk/core/src/device.ts +112 -0
- package/template/runtime/sdk/core/src/index.ts +6 -0
- package/template/runtime/sdk/core/src/invalidate.ts +40 -0
- package/template/runtime/sdk/core/src/types.ts +108 -0
- package/template/runtime/sdk/core/tests/capabilities.test.ts +64 -0
- package/template/runtime/sdk/core/tests/client.test.ts +424 -0
- package/template/runtime/sdk/core/tests/collaboration.test.ts +92 -0
- package/template/runtime/sdk/core/tests/desktop.test.ts +310 -0
- package/template/runtime/sdk/core/tests/device.test.ts +69 -0
- package/template/runtime/sdk/core/tsconfig.json +17 -0
- package/template/runtime/sdk/react/package.json +34 -0
- package/template/runtime/sdk/react/src/client.ts +7 -0
- package/template/runtime/sdk/react/src/components/can.tsx +24 -0
- package/template/runtime/sdk/react/src/hooks/use-action.ts +34 -0
- package/template/runtime/sdk/react/src/hooks/use-capabilities.ts +35 -0
- package/template/runtime/sdk/react/src/hooks/use-count.ts +37 -0
- package/template/runtime/sdk/react/src/hooks/use-create.ts +37 -0
- package/template/runtime/sdk/react/src/hooks/use-delete.ts +36 -0
- package/template/runtime/sdk/react/src/hooks/use-desktop-action.ts +94 -0
- package/template/runtime/sdk/react/src/hooks/use-device-action.ts +62 -0
- package/template/runtime/sdk/react/src/hooks/use-get.ts +37 -0
- package/template/runtime/sdk/react/src/hooks/use-group-members.ts +31 -0
- package/template/runtime/sdk/react/src/hooks/use-groups.ts +31 -0
- package/template/runtime/sdk/react/src/hooks/use-list.ts +53 -0
- package/template/runtime/sdk/react/src/hooks/use-me.ts +35 -0
- package/template/runtime/sdk/react/src/hooks/use-mutation.ts +30 -0
- package/template/runtime/sdk/react/src/hooks/use-permissions.ts +37 -0
- package/template/runtime/sdk/react/src/hooks/use-platform-data.ts +94 -0
- package/template/runtime/sdk/react/src/hooks/use-query.ts +30 -0
- package/template/runtime/sdk/react/src/hooks/use-time.ts +36 -0
- package/template/runtime/sdk/react/src/hooks/use-transaction.ts +30 -0
- package/template/runtime/sdk/react/src/hooks/use-transitions.ts +82 -0
- package/template/runtime/sdk/react/src/hooks/use-update.ts +37 -0
- package/template/runtime/sdk/react/src/hooks/use-upload.ts +30 -0
- package/template/runtime/sdk/react/src/hooks/use-users.ts +31 -0
- package/template/runtime/sdk/react/src/index.ts +40 -0
- package/template/runtime/sdk/react/src/permissions.ts +94 -0
- package/template/runtime/sdk/react/tests/permissions.test.ts +176 -0
- package/template/runtime/sdk/react/tests/use-action.test.tsx +64 -0
- package/template/runtime/sdk/react/tests/use-capabilities.test.tsx +48 -0
- package/template/runtime/sdk/react/tests/use-desktop-action.test.tsx +144 -0
- package/template/runtime/sdk/react/tests/use-permissions.test.tsx +162 -0
- package/template/runtime/sdk/react/tests/use-platform-data.test.tsx +89 -0
- package/template/runtime/sdk/react/tests/use-transaction.test.tsx +65 -0
- package/template/runtime/sdk/react/tests/use-transitions.test.ts +149 -0
- package/template/runtime/sdk/react/tsconfig.json +18 -0
- package/template/runtime/sdk/react/vitest.config.ts +9 -0
- package/template/runtime/sdk/react/vitest.setup.ts +6 -0
- package/template/runtime/server-core/dist/generated/platform-capabilities.d.ts +84 -0
- package/template/runtime/server-core/dist/generated/platform-capabilities.d.ts.map +1 -0
- package/template/runtime/server-core/dist/generated/platform-capabilities.js +115 -0
- package/template/runtime/server-core/dist/generated/platform-capabilities.js.map +1 -0
- package/template/runtime/server-core/dist/index.d.ts +19 -0
- package/template/runtime/server-core/dist/index.d.ts.map +1 -0
- package/template/runtime/server-core/dist/index.js +35 -0
- package/template/runtime/server-core/dist/index.js.map +1 -0
- package/template/runtime/server-core/dist/lib/__tests__/action-runtime-hardening.test.d.ts +2 -0
- package/template/runtime/server-core/dist/lib/__tests__/action-runtime-hardening.test.d.ts.map +1 -0
- package/template/runtime/server-core/dist/lib/__tests__/action-runtime-hardening.test.js +475 -0
- package/template/runtime/server-core/dist/lib/__tests__/action-runtime-hardening.test.js.map +1 -0
- package/template/runtime/server-core/dist/lib/__tests__/app-api-contract.test.d.ts +2 -0
- package/template/runtime/server-core/dist/lib/__tests__/app-api-contract.test.d.ts.map +1 -0
- package/template/runtime/server-core/dist/lib/__tests__/app-api-contract.test.js +65 -0
- package/template/runtime/server-core/dist/lib/__tests__/app-api-contract.test.js.map +1 -0
- package/template/runtime/server-core/dist/lib/__tests__/app-runtime.test.d.ts +2 -0
- package/template/runtime/server-core/dist/lib/__tests__/app-runtime.test.d.ts.map +1 -0
- package/template/runtime/server-core/dist/lib/__tests__/app-runtime.test.js +103 -0
- package/template/runtime/server-core/dist/lib/__tests__/app-runtime.test.js.map +1 -0
- package/template/runtime/server-core/dist/lib/__tests__/backend-actions.test.d.ts +2 -0
- package/template/runtime/server-core/dist/lib/__tests__/backend-actions.test.d.ts.map +1 -0
- package/template/runtime/server-core/dist/lib/__tests__/backend-actions.test.js +358 -0
- package/template/runtime/server-core/dist/lib/__tests__/backend-actions.test.js.map +1 -0
- package/template/runtime/server-core/dist/lib/__tests__/backend-contract.test.d.ts +2 -0
- package/template/runtime/server-core/dist/lib/__tests__/backend-contract.test.d.ts.map +1 -0
- package/template/runtime/server-core/dist/lib/__tests__/backend-contract.test.js +786 -0
- package/template/runtime/server-core/dist/lib/__tests__/backend-contract.test.js.map +1 -0
- package/template/runtime/server-core/dist/lib/__tests__/content-capabilities.test.d.ts +2 -0
- package/template/runtime/server-core/dist/lib/__tests__/content-capabilities.test.d.ts.map +1 -0
- package/template/runtime/server-core/dist/lib/__tests__/content-capabilities.test.js +82 -0
- package/template/runtime/server-core/dist/lib/__tests__/content-capabilities.test.js.map +1 -0
- package/template/runtime/server-core/dist/lib/__tests__/database-write-guard.test.d.ts +2 -0
- package/template/runtime/server-core/dist/lib/__tests__/database-write-guard.test.d.ts.map +1 -0
- package/template/runtime/server-core/dist/lib/__tests__/database-write-guard.test.js +42 -0
- package/template/runtime/server-core/dist/lib/__tests__/database-write-guard.test.js.map +1 -0
- package/template/runtime/server-core/dist/lib/__tests__/issue-collaboration.test.d.ts +2 -0
- package/template/runtime/server-core/dist/lib/__tests__/issue-collaboration.test.d.ts.map +1 -0
- package/template/runtime/server-core/dist/lib/__tests__/issue-collaboration.test.js +144 -0
- package/template/runtime/server-core/dist/lib/__tests__/issue-collaboration.test.js.map +1 -0
- package/template/runtime/server-core/dist/lib/__tests__/issue-comment-minimization.test.d.ts +2 -0
- package/template/runtime/server-core/dist/lib/__tests__/issue-comment-minimization.test.d.ts.map +1 -0
- package/template/runtime/server-core/dist/lib/__tests__/issue-comment-minimization.test.js +75 -0
- package/template/runtime/server-core/dist/lib/__tests__/issue-comment-minimization.test.js.map +1 -0
- package/template/runtime/server-core/dist/lib/__tests__/issue-comment-pins.test.d.ts +2 -0
- package/template/runtime/server-core/dist/lib/__tests__/issue-comment-pins.test.d.ts.map +1 -0
- package/template/runtime/server-core/dist/lib/__tests__/issue-comment-pins.test.js +85 -0
- package/template/runtime/server-core/dist/lib/__tests__/issue-comment-pins.test.js.map +1 -0
- package/template/runtime/server-core/dist/lib/__tests__/issue-cross-references.test.d.ts +2 -0
- package/template/runtime/server-core/dist/lib/__tests__/issue-cross-references.test.d.ts.map +1 -0
- package/template/runtime/server-core/dist/lib/__tests__/issue-cross-references.test.js +75 -0
- package/template/runtime/server-core/dist/lib/__tests__/issue-cross-references.test.js.map +1 -0
- package/template/runtime/server-core/dist/lib/__tests__/issue-dependencies.test.d.ts +2 -0
- package/template/runtime/server-core/dist/lib/__tests__/issue-dependencies.test.d.ts.map +1 -0
- package/template/runtime/server-core/dist/lib/__tests__/issue-dependencies.test.js +78 -0
- package/template/runtime/server-core/dist/lib/__tests__/issue-dependencies.test.js.map +1 -0
- package/template/runtime/server-core/dist/lib/__tests__/issue-duplicates.test.d.ts +2 -0
- package/template/runtime/server-core/dist/lib/__tests__/issue-duplicates.test.d.ts.map +1 -0
- package/template/runtime/server-core/dist/lib/__tests__/issue-duplicates.test.js +66 -0
- package/template/runtime/server-core/dist/lib/__tests__/issue-duplicates.test.js.map +1 -0
- package/template/runtime/server-core/dist/lib/__tests__/issue-list.test.d.ts +2 -0
- package/template/runtime/server-core/dist/lib/__tests__/issue-list.test.d.ts.map +1 -0
- package/template/runtime/server-core/dist/lib/__tests__/issue-list.test.js +322 -0
- package/template/runtime/server-core/dist/lib/__tests__/issue-list.test.js.map +1 -0
- package/template/runtime/server-core/dist/lib/__tests__/issue-potential-duplicates.test.d.ts +2 -0
- package/template/runtime/server-core/dist/lib/__tests__/issue-potential-duplicates.test.d.ts.map +1 -0
- package/template/runtime/server-core/dist/lib/__tests__/issue-potential-duplicates.test.js +49 -0
- package/template/runtime/server-core/dist/lib/__tests__/issue-potential-duplicates.test.js.map +1 -0
- package/template/runtime/server-core/dist/lib/__tests__/issue-reactions.test.d.ts +2 -0
- package/template/runtime/server-core/dist/lib/__tests__/issue-reactions.test.d.ts.map +1 -0
- package/template/runtime/server-core/dist/lib/__tests__/issue-reactions.test.js +67 -0
- package/template/runtime/server-core/dist/lib/__tests__/issue-reactions.test.js.map +1 -0
- package/template/runtime/server-core/dist/lib/__tests__/issue-revisions.test.d.ts +2 -0
- package/template/runtime/server-core/dist/lib/__tests__/issue-revisions.test.d.ts.map +1 -0
- package/template/runtime/server-core/dist/lib/__tests__/issue-revisions.test.js +91 -0
- package/template/runtime/server-core/dist/lib/__tests__/issue-revisions.test.js.map +1 -0
- package/template/runtime/server-core/dist/lib/__tests__/issue-saved-views.test.d.ts +2 -0
- package/template/runtime/server-core/dist/lib/__tests__/issue-saved-views.test.d.ts.map +1 -0
- package/template/runtime/server-core/dist/lib/__tests__/issue-saved-views.test.js +69 -0
- package/template/runtime/server-core/dist/lib/__tests__/issue-saved-views.test.js.map +1 -0
- package/template/runtime/server-core/dist/lib/__tests__/issue-sub-issues.test.d.ts +2 -0
- package/template/runtime/server-core/dist/lib/__tests__/issue-sub-issues.test.d.ts.map +1 -0
- package/template/runtime/server-core/dist/lib/__tests__/issue-sub-issues.test.js +159 -0
- package/template/runtime/server-core/dist/lib/__tests__/issue-sub-issues.test.js.map +1 -0
- package/template/runtime/server-core/dist/lib/__tests__/issue-task-conversion.test.d.ts +2 -0
- package/template/runtime/server-core/dist/lib/__tests__/issue-task-conversion.test.d.ts.map +1 -0
- package/template/runtime/server-core/dist/lib/__tests__/issue-task-conversion.test.js +102 -0
- package/template/runtime/server-core/dist/lib/__tests__/issue-task-conversion.test.js.map +1 -0
- package/template/runtime/server-core/dist/lib/__tests__/issue-templates.test.d.ts +2 -0
- package/template/runtime/server-core/dist/lib/__tests__/issue-templates.test.d.ts.map +1 -0
- package/template/runtime/server-core/dist/lib/__tests__/issue-templates.test.js +65 -0
- package/template/runtime/server-core/dist/lib/__tests__/issue-templates.test.js.map +1 -0
- package/template/runtime/server-core/dist/lib/__tests__/issue-timeline.test.d.ts +2 -0
- package/template/runtime/server-core/dist/lib/__tests__/issue-timeline.test.d.ts.map +1 -0
- package/template/runtime/server-core/dist/lib/__tests__/issue-timeline.test.js +226 -0
- package/template/runtime/server-core/dist/lib/__tests__/issue-timeline.test.js.map +1 -0
- package/template/runtime/server-core/dist/lib/__tests__/issue-types.test.d.ts +2 -0
- package/template/runtime/server-core/dist/lib/__tests__/issue-types.test.d.ts.map +1 -0
- package/template/runtime/server-core/dist/lib/__tests__/issue-types.test.js +64 -0
- package/template/runtime/server-core/dist/lib/__tests__/issue-types.test.js.map +1 -0
- package/template/runtime/server-core/dist/lib/__tests__/migrations.test.d.ts +2 -0
- package/template/runtime/server-core/dist/lib/__tests__/migrations.test.d.ts.map +1 -0
- package/template/runtime/server-core/dist/lib/__tests__/migrations.test.js +101 -0
- package/template/runtime/server-core/dist/lib/__tests__/migrations.test.js.map +1 -0
- package/template/runtime/server-core/dist/lib/__tests__/platform-capabilities.test.d.ts +2 -0
- package/template/runtime/server-core/dist/lib/__tests__/platform-capabilities.test.d.ts.map +1 -0
- package/template/runtime/server-core/dist/lib/__tests__/platform-capabilities.test.js +69 -0
- package/template/runtime/server-core/dist/lib/__tests__/platform-capabilities.test.js.map +1 -0
- package/template/runtime/server-core/dist/lib/__tests__/transitions.test.d.ts +2 -0
- package/template/runtime/server-core/dist/lib/__tests__/transitions.test.d.ts.map +1 -0
- package/template/runtime/server-core/dist/lib/__tests__/transitions.test.js +32 -0
- package/template/runtime/server-core/dist/lib/__tests__/transitions.test.js.map +1 -0
- package/template/runtime/server-core/dist/lib/access-control.d.ts +34 -0
- package/template/runtime/server-core/dist/lib/access-control.d.ts.map +1 -0
- package/template/runtime/server-core/dist/lib/access-control.js +138 -0
- package/template/runtime/server-core/dist/lib/access-control.js.map +1 -0
- package/template/runtime/server-core/dist/lib/app-api-contract.d.ts +69 -0
- package/template/runtime/server-core/dist/lib/app-api-contract.d.ts.map +1 -0
- package/template/runtime/server-core/dist/lib/app-api-contract.js +57 -0
- package/template/runtime/server-core/dist/lib/app-api-contract.js.map +1 -0
- package/template/runtime/server-core/dist/lib/app-db.d.ts +486 -0
- package/template/runtime/server-core/dist/lib/app-db.d.ts.map +1 -0
- package/template/runtime/server-core/dist/lib/app-db.js +2581 -0
- package/template/runtime/server-core/dist/lib/app-db.js.map +1 -0
- package/template/runtime/server-core/dist/lib/app-runtime.d.ts +28 -0
- package/template/runtime/server-core/dist/lib/app-runtime.d.ts.map +1 -0
- package/template/runtime/server-core/dist/lib/app-runtime.js +56 -0
- package/template/runtime/server-core/dist/lib/app-runtime.js.map +1 -0
- package/template/runtime/server-core/dist/lib/backend-actions.d.ts +149 -0
- package/template/runtime/server-core/dist/lib/backend-actions.d.ts.map +1 -0
- package/template/runtime/server-core/dist/lib/backend-actions.js +926 -0
- package/template/runtime/server-core/dist/lib/backend-actions.js.map +1 -0
- package/template/runtime/server-core/dist/lib/backend-contract.d.ts +399 -0
- package/template/runtime/server-core/dist/lib/backend-contract.d.ts.map +1 -0
- package/template/runtime/server-core/dist/lib/backend-contract.js +1148 -0
- package/template/runtime/server-core/dist/lib/backend-contract.js.map +1 -0
- package/template/runtime/server-core/dist/lib/content-capabilities.d.ts +30 -0
- package/template/runtime/server-core/dist/lib/content-capabilities.d.ts.map +1 -0
- package/template/runtime/server-core/dist/lib/content-capabilities.js +133 -0
- package/template/runtime/server-core/dist/lib/content-capabilities.js.map +1 -0
- package/template/runtime/server-core/dist/lib/issue-saved-replies.d.ts +7 -0
- package/template/runtime/server-core/dist/lib/issue-saved-replies.d.ts.map +1 -0
- package/template/runtime/server-core/dist/lib/issue-saved-replies.js +22 -0
- package/template/runtime/server-core/dist/lib/issue-saved-replies.js.map +1 -0
- package/template/runtime/server-core/dist/lib/issue-saved-views.d.ts +43 -0
- package/template/runtime/server-core/dist/lib/issue-saved-views.d.ts.map +1 -0
- package/template/runtime/server-core/dist/lib/issue-saved-views.js +201 -0
- package/template/runtime/server-core/dist/lib/issue-saved-views.js.map +1 -0
- package/template/runtime/server-core/dist/lib/issue-task-conversion.d.ts +11 -0
- package/template/runtime/server-core/dist/lib/issue-task-conversion.d.ts.map +1 -0
- package/template/runtime/server-core/dist/lib/issue-task-conversion.js +66 -0
- package/template/runtime/server-core/dist/lib/issue-task-conversion.js.map +1 -0
- package/template/runtime/server-core/dist/lib/issue-templates.d.ts +16 -0
- package/template/runtime/server-core/dist/lib/issue-templates.d.ts.map +1 -0
- package/template/runtime/server-core/dist/lib/issue-templates.js +89 -0
- package/template/runtime/server-core/dist/lib/issue-templates.js.map +1 -0
- package/template/runtime/server-core/dist/lib/migrations.d.ts +31 -0
- package/template/runtime/server-core/dist/lib/migrations.d.ts.map +1 -0
- package/template/runtime/server-core/dist/lib/migrations.js +180 -0
- package/template/runtime/server-core/dist/lib/migrations.js.map +1 -0
- package/template/runtime/server-core/dist/lib/notify-permission-sql.d.ts +21 -0
- package/template/runtime/server-core/dist/lib/notify-permission-sql.d.ts.map +1 -0
- package/template/runtime/server-core/dist/lib/notify-permission-sql.js +71 -0
- package/template/runtime/server-core/dist/lib/notify-permission-sql.js.map +1 -0
- package/template/runtime/server-core/dist/lib/record-access.d.ts +34 -0
- package/template/runtime/server-core/dist/lib/record-access.d.ts.map +1 -0
- package/template/runtime/server-core/dist/lib/record-access.js +81 -0
- package/template/runtime/server-core/dist/lib/record-access.js.map +1 -0
- package/template/runtime/server-core/dist/lib/runtime-errors.d.ts +28 -0
- package/template/runtime/server-core/dist/lib/runtime-errors.d.ts.map +1 -0
- package/template/runtime/server-core/dist/lib/runtime-errors.js +67 -0
- package/template/runtime/server-core/dist/lib/runtime-errors.js.map +1 -0
- package/template/runtime/server-core/dist/lib/transitions.d.ts +55 -0
- package/template/runtime/server-core/dist/lib/transitions.d.ts.map +1 -0
- package/template/runtime/server-core/dist/lib/transitions.js +142 -0
- package/template/runtime/server-core/dist/lib/transitions.js.map +1 -0
- package/template/runtime/server-core/dist/types/models.d.ts +163 -0
- package/template/runtime/server-core/dist/types/models.d.ts.map +1 -0
- package/template/runtime/server-core/dist/types/models.js +3 -0
- package/template/runtime/server-core/dist/types/models.js.map +1 -0
- package/template/runtime/server-core/package.json +24 -0
- package/template/runtime/styles/preset.css +282 -0
- package/template/runtime/sync-template-command.cjs +19 -0
- package/template/runtime/sync-template.cjs +71 -0
- package/template/runtime/tsconfig.base.json +20 -0
- package/template/runtime/version.json +3 -0
- package/template/runtime/vite-plugin.mjs +309 -0
- package/template/src/App.tsx +273 -0
- package/template/src/components/ui/accordion.tsx +79 -0
- package/template/src/components/ui/alert-dialog.tsx +197 -0
- package/template/src/components/ui/alert.tsx +76 -0
- package/template/src/components/ui/aspect-ratio.tsx +11 -0
- package/template/src/components/ui/avatar.tsx +110 -0
- package/template/src/components/ui/badge.tsx +49 -0
- package/template/src/components/ui/breadcrumb.tsx +122 -0
- package/template/src/components/ui/button-group.tsx +83 -0
- package/template/src/components/ui/button.tsx +67 -0
- package/template/src/components/ui/calendar.tsx +221 -0
- package/template/src/components/ui/card.tsx +103 -0
- package/template/src/components/ui/carousel.tsx +240 -0
- package/template/src/components/ui/chart.tsx +373 -0
- package/template/src/components/ui/checkbox.tsx +31 -0
- package/template/src/components/ui/collapsible.tsx +33 -0
- package/template/src/components/ui/combobox.tsx +299 -0
- package/template/src/components/ui/command.tsx +193 -0
- package/template/src/components/ui/context-menu.tsx +261 -0
- package/template/src/components/ui/dialog.tsx +168 -0
- package/template/src/components/ui/direction.tsx +22 -0
- package/template/src/components/ui/drawer.tsx +132 -0
- package/template/src/components/ui/dropdown-menu.tsx +269 -0
- package/template/src/components/ui/empty.tsx +104 -0
- package/template/src/components/ui/field.tsx +238 -0
- package/template/src/components/ui/hover-card.tsx +42 -0
- package/template/src/components/ui/input-group.tsx +154 -0
- package/template/src/components/ui/input-otp.tsx +87 -0
- package/template/src/components/ui/input.tsx +19 -0
- package/template/src/components/ui/item.tsx +196 -0
- package/template/src/components/ui/kbd.tsx +26 -0
- package/template/src/components/ui/label.tsx +22 -0
- package/template/src/components/ui/menubar.tsx +280 -0
- package/template/src/components/ui/native-select.tsx +61 -0
- package/template/src/components/ui/navigation-menu.tsx +164 -0
- package/template/src/components/ui/pagination.tsx +129 -0
- package/template/src/components/ui/popover.tsx +87 -0
- package/template/src/components/ui/progress.tsx +31 -0
- package/template/src/components/ui/radio-group.tsx +42 -0
- package/template/src/components/ui/resizable.tsx +50 -0
- package/template/src/components/ui/scroll-area.tsx +53 -0
- package/template/src/components/ui/select.tsx +192 -0
- package/template/src/components/ui/separator.tsx +26 -0
- package/template/src/components/ui/sheet.tsx +145 -0
- package/template/src/components/ui/sidebar.tsx +700 -0
- package/template/src/components/ui/skeleton.tsx +13 -0
- package/template/src/components/ui/slider.tsx +59 -0
- package/template/src/components/ui/sonner.tsx +47 -0
- package/template/src/components/ui/spinner.tsx +10 -0
- package/template/src/components/ui/switch.tsx +33 -0
- package/template/src/components/ui/table.tsx +114 -0
- package/template/src/components/ui/tabs.tsx +90 -0
- package/template/src/components/ui/textarea.tsx +18 -0
- package/template/src/components/ui/toggle-group.tsx +89 -0
- package/template/src/components/ui/toggle.tsx +45 -0
- package/template/src/components/ui/tooltip.tsx +57 -0
- package/template/src/hooks/use-mobile.ts +3 -0
- package/template/src/index.css +4 -0
- package/template/src/lib/utils.ts +3 -0
- package/template/src/main.tsx +10 -0
- package/template/src/vite-env.d.ts +1 -0
- package/template/template.gitignore +10 -0
- package/template/template.npmrc +1 -0
- package/template/tests/agent-context.test.ts +69 -0
- package/template/tests/agent-guidance-template.test.ts +49 -0
- package/template/tests/agent-runtime.test.ts +198 -0
- package/template/tests/agent-tools.test.ts +150 -0
- package/template/tests/agent-use-agent.test.ts +86 -0
- package/template/tests/assistant-ui-adapter.test.ts +211 -0
- package/template/tests/business-modeling-template.test.ts +71 -0
- package/template/tests/client.test.ts +382 -0
- package/template/tests/dev-issue-search-suggestions.test.ts +36 -0
- package/template/tests/dev-shell-context.test.tsx +40 -0
- package/template/tests/dev-shell-template.test.ts +2593 -0
- package/template/tests/invalidation.test.ts +126 -0
- package/template/tests/main-tsx.test.ts +28 -0
- package/template/tests/media-preview-template.test.ts +21 -0
- package/template/tests/mutations.test.ts +224 -0
- package/template/tests/react.test.ts +302 -0
- package/template/tests/redirect.test.ts +51 -0
- package/template/tests/skill-docs.test.ts +76 -0
- package/template/tests/state-transitions-template.test.ts +61 -0
- package/template/tests/template-ui.test.ts +145 -0
- package/template/tests/upload.test.ts +143 -0
- package/template/tests/vite-plugin.test.ts +426 -0
- package/template/tests/vite-proxy-security.test.ts +153 -0
- package/template/tsconfig.json +11 -0
- package/template/vite.config.ts +7 -0
- package/template/vitest.config.ts +16 -0
- package/template/vitest.setup.ts +1 -0
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
|
|
2
|
+
import { renderHook, waitFor, act, cleanup } from "@testing-library/react";
|
|
3
|
+
import { useMe, useList, useGet, useCount } from "@localapp/sdk-react";
|
|
4
|
+
import { LocalAppError } from "@localapp/sdk";
|
|
5
|
+
|
|
6
|
+
afterEach(() => {
|
|
7
|
+
cleanup();
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
describe("useMe", () => {
|
|
11
|
+
beforeEach(() => {
|
|
12
|
+
delete (window as any).location;
|
|
13
|
+
(window as any).location = { pathname: "/serve/alice/my-app/", origin: "http://localhost:3000" };
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it("returns logged-in user", async () => {
|
|
17
|
+
globalThis.fetch = vi.fn().mockResolvedValueOnce({
|
|
18
|
+
ok: true,
|
|
19
|
+
status: 200,
|
|
20
|
+
json: () => Promise.resolve({ success: true, data: { id: "alice", name: "alice" } }),
|
|
21
|
+
} as Response);
|
|
22
|
+
|
|
23
|
+
const { result } = renderHook(() => useMe());
|
|
24
|
+
await waitFor(() => expect(result.current.loading).toBe(false));
|
|
25
|
+
expect(result.current.me).toEqual({ id: "alice", name: "alice" });
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it("returns null for unauthenticated user", async () => {
|
|
29
|
+
globalThis.fetch = vi.fn().mockResolvedValueOnce({
|
|
30
|
+
ok: true,
|
|
31
|
+
status: 200,
|
|
32
|
+
json: () => Promise.resolve({ success: true, data: null }),
|
|
33
|
+
} as Response);
|
|
34
|
+
|
|
35
|
+
const { result } = renderHook(() => useMe());
|
|
36
|
+
await waitFor(() => expect(result.current.loading).toBe(false));
|
|
37
|
+
expect(result.current.me).toBeNull();
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it("sets error on fetch failure", async () => {
|
|
41
|
+
globalThis.fetch = vi.fn().mockResolvedValueOnce({
|
|
42
|
+
ok: false,
|
|
43
|
+
status: 500,
|
|
44
|
+
json: () => Promise.resolve({ success: false, error: "Internal error" }),
|
|
45
|
+
} as Response);
|
|
46
|
+
|
|
47
|
+
const { result } = renderHook(() => useMe());
|
|
48
|
+
await waitFor(() => expect(result.current.loading).toBe(false));
|
|
49
|
+
expect(result.current.error).toBeInstanceOf(LocalAppError);
|
|
50
|
+
expect(result.current.error!.status).toBe(500);
|
|
51
|
+
expect(result.current.me).toBeNull();
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it("refreshes the current user when dev context changes", async () => {
|
|
55
|
+
const fetchSpy = vi
|
|
56
|
+
.fn()
|
|
57
|
+
.mockResolvedValueOnce({
|
|
58
|
+
ok: true,
|
|
59
|
+
status: 200,
|
|
60
|
+
json: () => Promise.resolve({ success: true, data: null }),
|
|
61
|
+
} as Response)
|
|
62
|
+
.mockResolvedValueOnce({
|
|
63
|
+
ok: true,
|
|
64
|
+
status: 200,
|
|
65
|
+
json: () => Promise.resolve({ success: true, data: { id: "dev-user", name: "Dev User" } }),
|
|
66
|
+
} as Response);
|
|
67
|
+
globalThis.fetch = fetchSpy;
|
|
68
|
+
|
|
69
|
+
const { result } = renderHook(() => useMe());
|
|
70
|
+
await waitFor(() => expect(result.current.loading).toBe(false));
|
|
71
|
+
expect(result.current.me).toBeNull();
|
|
72
|
+
|
|
73
|
+
act(() => {
|
|
74
|
+
window.dispatchEvent(new CustomEvent("localapp:dev-context-changed"));
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
await waitFor(() => expect(fetchSpy).toHaveBeenCalledTimes(2));
|
|
78
|
+
await waitFor(() => expect(result.current.me).toEqual({ id: "dev-user", name: "Dev User" }));
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
describe("useList", () => {
|
|
83
|
+
beforeEach(() => {
|
|
84
|
+
delete (window as any).location;
|
|
85
|
+
(window as any).location = { pathname: "/serve/alice/my-app/", origin: "http://localhost:3000" };
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it("returns rows and pagination", async () => {
|
|
89
|
+
globalThis.fetch = vi.fn().mockResolvedValueOnce({
|
|
90
|
+
ok: true,
|
|
91
|
+
status: 200,
|
|
92
|
+
json: () => Promise.resolve({
|
|
93
|
+
success: true,
|
|
94
|
+
data: {
|
|
95
|
+
rows: [{ id: 1, title: "hello" }, { id: 2, title: "world" }],
|
|
96
|
+
pagination: { offset: 0, limit: 50, total: 2 },
|
|
97
|
+
},
|
|
98
|
+
}),
|
|
99
|
+
} as Response);
|
|
100
|
+
|
|
101
|
+
const { result } = renderHook(() => useList("posts"));
|
|
102
|
+
await waitFor(() => expect(result.current.loading).toBe(false));
|
|
103
|
+
expect(result.current.rows).toHaveLength(2);
|
|
104
|
+
expect(result.current.pagination.total).toBe(2);
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
it("passes filters to URL", async () => {
|
|
108
|
+
const fetchSpy = vi.fn().mockResolvedValue({
|
|
109
|
+
ok: true,
|
|
110
|
+
status: 200,
|
|
111
|
+
json: () => Promise.resolve({ success: true, data: { rows: [], pagination: { offset: 0, limit: 50, total: 0 } } }),
|
|
112
|
+
} as Response);
|
|
113
|
+
globalThis.fetch = fetchSpy;
|
|
114
|
+
|
|
115
|
+
renderHook(() => useList("posts", { filters: { status: "published" } }));
|
|
116
|
+
await waitFor(() => expect(fetchSpy).toHaveBeenCalled());
|
|
117
|
+
expect(fetchSpy.mock.calls[0][0]).toBe("/serve/alice/my-app/api/queries/$posts.list");
|
|
118
|
+
expect(JSON.parse(fetchSpy.mock.calls[0][1].body as string).params.status).toBe("published");
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
it("passes offset, limit, sort, order to URL", async () => {
|
|
122
|
+
const fetchSpy = vi.fn().mockResolvedValue({
|
|
123
|
+
ok: true,
|
|
124
|
+
status: 200,
|
|
125
|
+
json: () => Promise.resolve({ success: true, data: { rows: [], pagination: { offset: 10, limit: 5, total: 0 } } }),
|
|
126
|
+
} as Response);
|
|
127
|
+
globalThis.fetch = fetchSpy;
|
|
128
|
+
|
|
129
|
+
renderHook(() => useList("posts", { offset: 10, limit: 5, sort: "created_at", order: "desc" }));
|
|
130
|
+
await waitFor(() => expect(fetchSpy).toHaveBeenCalled());
|
|
131
|
+
const params = JSON.parse(fetchSpy.mock.calls[0][1].body as string).params;
|
|
132
|
+
expect(params.offset).toBe(10);
|
|
133
|
+
expect(params.limit).toBe(5);
|
|
134
|
+
expect(params.sort).toBe("created_at");
|
|
135
|
+
expect(params.order).toBe("desc");
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
it("refresh() re-fetches data", async () => {
|
|
139
|
+
let callCount = 0;
|
|
140
|
+
globalThis.fetch = vi.fn().mockImplementation(() => {
|
|
141
|
+
callCount++;
|
|
142
|
+
return Promise.resolve({
|
|
143
|
+
ok: true,
|
|
144
|
+
status: 200,
|
|
145
|
+
json: () => Promise.resolve({ success: true, data: { rows: [{ id: callCount }], pagination: { offset: 0, limit: 50, total: 1 } } }),
|
|
146
|
+
} as Response);
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
const { result } = renderHook(() => useList("posts"));
|
|
150
|
+
await waitFor(() => expect(result.current.loading).toBe(false));
|
|
151
|
+
expect(result.current.rows[0].id).toBe(1);
|
|
152
|
+
|
|
153
|
+
await act(async () => { result.current.refresh(); });
|
|
154
|
+
await waitFor(() => expect(result.current.rows[0].id).toBe(2));
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
it("sets error on 401 and loading becomes false", async () => {
|
|
158
|
+
globalThis.fetch = vi.fn().mockResolvedValueOnce({
|
|
159
|
+
ok: false,
|
|
160
|
+
status: 401,
|
|
161
|
+
json: () => Promise.resolve({ success: false, error: "Authentication required" }),
|
|
162
|
+
} as Response);
|
|
163
|
+
|
|
164
|
+
const { result } = renderHook(() => useList("posts"));
|
|
165
|
+
await waitFor(() => expect(result.current.loading).toBe(false));
|
|
166
|
+
expect(result.current.error).toBeInstanceOf(LocalAppError);
|
|
167
|
+
expect(result.current.error!.status).toBe(401);
|
|
168
|
+
expect(result.current.rows).toEqual([]);
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
it("sets error on 403", async () => {
|
|
172
|
+
globalThis.fetch = vi.fn().mockResolvedValueOnce({
|
|
173
|
+
ok: false,
|
|
174
|
+
status: 403,
|
|
175
|
+
json: () => Promise.resolve({ success: false, error: "Access denied" }),
|
|
176
|
+
} as Response);
|
|
177
|
+
|
|
178
|
+
const { result } = renderHook(() => useList("posts"));
|
|
179
|
+
await waitFor(() => expect(result.current.loading).toBe(false));
|
|
180
|
+
expect(result.current.error).toBeInstanceOf(LocalAppError);
|
|
181
|
+
expect(result.current.error!.status).toBe(403);
|
|
182
|
+
});
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
describe("useGet", () => {
|
|
186
|
+
beforeEach(() => {
|
|
187
|
+
delete (window as any).location;
|
|
188
|
+
(window as any).location = { pathname: "/serve/alice/my-app/", origin: "http://localhost:3000" };
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
it("returns existing record", async () => {
|
|
192
|
+
globalThis.fetch = vi.fn().mockResolvedValueOnce({
|
|
193
|
+
ok: true,
|
|
194
|
+
status: 200,
|
|
195
|
+
json: () => Promise.resolve({ success: true, data: { id: 1, title: "hello" } }),
|
|
196
|
+
} as Response);
|
|
197
|
+
|
|
198
|
+
const { result } = renderHook(() => useGet("posts", 1));
|
|
199
|
+
await waitFor(() => expect(result.current.loading).toBe(false));
|
|
200
|
+
expect(result.current.row).toEqual({ id: 1, title: "hello" });
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
it("returns null for non-existent record", async () => {
|
|
204
|
+
globalThis.fetch = vi.fn().mockResolvedValueOnce({
|
|
205
|
+
ok: true,
|
|
206
|
+
status: 200,
|
|
207
|
+
json: () => Promise.resolve({ success: true, data: null }),
|
|
208
|
+
} as Response);
|
|
209
|
+
|
|
210
|
+
const { result } = renderHook(() => useGet("posts", 999));
|
|
211
|
+
await waitFor(() => expect(result.current.loading).toBe(false));
|
|
212
|
+
expect(result.current.row).toBeNull();
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
it("sets error on 401 and loading becomes false", async () => {
|
|
216
|
+
globalThis.fetch = vi.fn().mockResolvedValueOnce({
|
|
217
|
+
ok: false,
|
|
218
|
+
status: 401,
|
|
219
|
+
json: () => Promise.resolve({ success: false, error: "Authentication required" }),
|
|
220
|
+
} as Response);
|
|
221
|
+
|
|
222
|
+
const { result } = renderHook(() => useGet("posts", 1));
|
|
223
|
+
await waitFor(() => expect(result.current.loading).toBe(false));
|
|
224
|
+
expect(result.current.error).toBeInstanceOf(LocalAppError);
|
|
225
|
+
expect(result.current.error!.status).toBe(401);
|
|
226
|
+
expect(result.current.row).toBeNull();
|
|
227
|
+
});
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
describe("useCount", () => {
|
|
231
|
+
beforeEach(() => {
|
|
232
|
+
delete (window as any).location;
|
|
233
|
+
(window as any).location = { pathname: "/serve/alice/my-app/", origin: "http://localhost:3000" };
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
it("returns count", async () => {
|
|
237
|
+
globalThis.fetch = vi.fn().mockResolvedValueOnce({
|
|
238
|
+
ok: true,
|
|
239
|
+
status: 200,
|
|
240
|
+
json: () => Promise.resolve({ success: true, data: { count: 42 } }),
|
|
241
|
+
} as Response);
|
|
242
|
+
|
|
243
|
+
const { result } = renderHook(() => useCount("posts"));
|
|
244
|
+
await waitFor(() => expect(result.current.loading).toBe(false));
|
|
245
|
+
expect(result.current.count).toBe(42);
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
it("passes filters", async () => {
|
|
249
|
+
const fetchSpy = vi.fn().mockResolvedValue({
|
|
250
|
+
ok: true,
|
|
251
|
+
status: 200,
|
|
252
|
+
json: () => Promise.resolve({ success: true, data: { count: 10 } }),
|
|
253
|
+
} as Response);
|
|
254
|
+
globalThis.fetch = fetchSpy;
|
|
255
|
+
|
|
256
|
+
renderHook(() => useCount("posts", { status: "published" }));
|
|
257
|
+
await waitFor(() => expect(fetchSpy).toHaveBeenCalled());
|
|
258
|
+
expect(fetchSpy.mock.calls[0][0]).toBe("/serve/alice/my-app/api/queries/$posts.count");
|
|
259
|
+
expect(JSON.parse(fetchSpy.mock.calls[0][1].body as string).params.status).toBe("published");
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
it("sets error on 401 and loading becomes false", async () => {
|
|
263
|
+
globalThis.fetch = vi.fn().mockResolvedValueOnce({
|
|
264
|
+
ok: false,
|
|
265
|
+
status: 401,
|
|
266
|
+
json: () => Promise.resolve({ success: false, error: "Authentication required" }),
|
|
267
|
+
} as Response);
|
|
268
|
+
|
|
269
|
+
const { result } = renderHook(() => useCount("posts"));
|
|
270
|
+
await waitFor(() => expect(result.current.loading).toBe(false));
|
|
271
|
+
expect(result.current.error).toBeInstanceOf(LocalAppError);
|
|
272
|
+
expect(result.current.error!.status).toBe(401);
|
|
273
|
+
expect(result.current.count).toBe(0);
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
it("refreshes when dev context changes", async () => {
|
|
277
|
+
const fetchSpy = vi
|
|
278
|
+
.fn()
|
|
279
|
+
.mockResolvedValueOnce({
|
|
280
|
+
ok: true,
|
|
281
|
+
status: 200,
|
|
282
|
+
json: () => Promise.resolve({ success: true, data: { count: 1 } }),
|
|
283
|
+
} as Response)
|
|
284
|
+
.mockResolvedValueOnce({
|
|
285
|
+
ok: true,
|
|
286
|
+
status: 200,
|
|
287
|
+
json: () => Promise.resolve({ success: true, data: { count: 2 } }),
|
|
288
|
+
} as Response);
|
|
289
|
+
globalThis.fetch = fetchSpy;
|
|
290
|
+
|
|
291
|
+
const { result } = renderHook(() => useCount("posts"));
|
|
292
|
+
await waitFor(() => expect(result.current.loading).toBe(false));
|
|
293
|
+
expect(result.current.count).toBe(1);
|
|
294
|
+
|
|
295
|
+
act(() => {
|
|
296
|
+
window.dispatchEvent(new CustomEvent("localapp:dev-context-changed"));
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
await waitFor(() => expect(fetchSpy).toHaveBeenCalledTimes(2));
|
|
300
|
+
await waitFor(() => expect(result.current.count).toBe(2));
|
|
301
|
+
});
|
|
302
|
+
});
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { describe, it, expect, vi, afterEach } from "vitest";
|
|
2
|
+
import { redirectToLogin } from "@localapp/sdk";
|
|
3
|
+
|
|
4
|
+
describe("redirectToLogin", () => {
|
|
5
|
+
const originalParent = window.parent;
|
|
6
|
+
const originalLocation = window.location;
|
|
7
|
+
|
|
8
|
+
afterEach(() => {
|
|
9
|
+
vi.restoreAllMocks();
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it("asks the same-page platform shell to open login without navigating away", () => {
|
|
13
|
+
const mockParent = { location: { href: "" } } as unknown as Window;
|
|
14
|
+
const mockLocation = { href: "http://localhost/serve/alice/app/" };
|
|
15
|
+
const request = vi.fn((event: Event) => event.preventDefault());
|
|
16
|
+
delete (window as any).parent;
|
|
17
|
+
(window as any).parent = mockParent;
|
|
18
|
+
delete (window as any).location;
|
|
19
|
+
(window as any).location = mockLocation;
|
|
20
|
+
window.addEventListener("localapp:platform_request", request);
|
|
21
|
+
|
|
22
|
+
redirectToLogin();
|
|
23
|
+
|
|
24
|
+
expect(request).toHaveBeenCalledOnce();
|
|
25
|
+
expect((request.mock.calls[0][0] as CustomEvent).detail).toMatchObject({
|
|
26
|
+
type: "localapp:platform_request",
|
|
27
|
+
capability: "auth.login",
|
|
28
|
+
});
|
|
29
|
+
expect(mockLocation.href).toBe("http://localhost/serve/alice/app/");
|
|
30
|
+
expect(mockParent.location.href).toBe("");
|
|
31
|
+
|
|
32
|
+
window.removeEventListener("localapp:platform_request", request);
|
|
33
|
+
(window as any).parent = originalParent;
|
|
34
|
+
(window as any).location = originalLocation;
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it("falls back to the platform home when no shell handles the request", () => {
|
|
38
|
+
const mockLocation = { href: "http://localhost/serve/alice/app/" };
|
|
39
|
+
delete (window as any).parent;
|
|
40
|
+
(window as any).parent = window;
|
|
41
|
+
delete (window as any).location;
|
|
42
|
+
(window as any).location = mockLocation;
|
|
43
|
+
|
|
44
|
+
redirectToLogin();
|
|
45
|
+
|
|
46
|
+
expect(mockLocation.href).toBe("/");
|
|
47
|
+
|
|
48
|
+
(window as any).parent = originalParent;
|
|
49
|
+
(window as any).location = originalLocation;
|
|
50
|
+
});
|
|
51
|
+
});
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { describe, expect, it } from "vitest";
|
|
4
|
+
|
|
5
|
+
const skillsDir = path.resolve(process.cwd(), ".claude", "skills");
|
|
6
|
+
const repoRoot = path.resolve(process.cwd(), "..");
|
|
7
|
+
|
|
8
|
+
function readSkill(name: string): string {
|
|
9
|
+
return fs.readFileSync(path.join(skillsDir, name, "SKILL.md"), "utf8");
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
describe("LocalApp skill documentation consistency", () => {
|
|
13
|
+
it("recommends count APIs instead of list(limit: 1) as normal application code", () => {
|
|
14
|
+
const dataSkill = readSkill("localapp-data");
|
|
15
|
+
expect(dataSkill).toContain("useCount");
|
|
16
|
+
expect(dataSkill).toContain("client.count()");
|
|
17
|
+
expect(dataSkill).toContain("不要把 `list({ limit: 1 })` / `list(limit: 1)` 当作常规计数写法");
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it("documents content upload separately from the deployment compatibility transport", () => {
|
|
21
|
+
const uploadSkill = readSkill("localapp-upload");
|
|
22
|
+
expect(uploadSkill).toContain("useUpload()");
|
|
23
|
+
expect(uploadSkill).toContain("/api/content/upload");
|
|
24
|
+
expect(uploadSkill).toContain("/serve/<owner>/<app>/api/content/<key>");
|
|
25
|
+
expect(uploadSkill).not.toContain("返回的 `url` 指向 `/api/content/{key}`");
|
|
26
|
+
expect(uploadSkill).toContain("应用代码不得调用 `/api/upload`");
|
|
27
|
+
expect(uploadSkill).toContain("部署兼容传输");
|
|
28
|
+
expect(uploadSkill).toContain("不是第二套安装实现");
|
|
29
|
+
expect(uploadSkill).not.toContain("已整体移除");
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it("does not recommend removed schema CLI commands in app-building skills", () => {
|
|
33
|
+
const skillFiles = fs
|
|
34
|
+
.readdirSync(skillsDir, { withFileTypes: true })
|
|
35
|
+
.filter((entry) => entry.isDirectory())
|
|
36
|
+
.map((entry) => path.join(skillsDir, entry.name, "SKILL.md"))
|
|
37
|
+
.filter((file) => fs.existsSync(file));
|
|
38
|
+
|
|
39
|
+
for (const file of skillFiles) {
|
|
40
|
+
const content = fs.readFileSync(file, "utf8");
|
|
41
|
+
expect(content, file).not.toMatch(/localapp\s+schemas\s+create/);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it("guides production data access to registered named SQL without raw SQL escape hatches", () => {
|
|
46
|
+
const dataSkill = readSkill("localapp-data");
|
|
47
|
+
expect(dataSkill).toContain("client.query(");
|
|
48
|
+
expect(dataSkill).toContain("client.mutate(");
|
|
49
|
+
expect(dataSkill).toContain("backend");
|
|
50
|
+
expect(dataSkill).not.toMatch(/client\.exec\([^)]*sql/i);
|
|
51
|
+
expect(dataSkill).not.toMatch(/await\s+exec\(/);
|
|
52
|
+
expect(dataSkill).toContain("没有 raw SQL 端点");
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it("documents formal PlatformShell route as the uploaded app validation entry", () => {
|
|
56
|
+
const claudeGuide = fs.readFileSync(path.resolve(process.cwd(), "CLAUDE.md"), "utf8");
|
|
57
|
+
expect(claudeGuide).toContain("http://<server-origin>/<userId>/<pageName>/");
|
|
58
|
+
expect(claudeGuide).toContain("raw app resource/API base");
|
|
59
|
+
expect(claudeGuide).toContain("不作为应用功能验收入口");
|
|
60
|
+
|
|
61
|
+
const platformLoopRefs = [
|
|
62
|
+
".agents/skills/localapp-app-loop/references/task-envelope.md",
|
|
63
|
+
".agents/skills/localapp-app-loop/references/user-validation.md",
|
|
64
|
+
];
|
|
65
|
+
const availablePlatformLoopRefs = platformLoopRefs.filter((rel) =>
|
|
66
|
+
fs.existsSync(path.join(repoRoot, rel))
|
|
67
|
+
);
|
|
68
|
+
expect([0, platformLoopRefs.length]).toContain(availablePlatformLoopRefs.length);
|
|
69
|
+
for (const rel of availablePlatformLoopRefs) {
|
|
70
|
+
const content = fs.readFileSync(path.join(repoRoot, rel), "utf8");
|
|
71
|
+
expect(content, rel).toContain("PlatformShell");
|
|
72
|
+
expect(content, rel).not.toMatch(/Verify\s+\/serve\/<owner>\/<app>\/\./);
|
|
73
|
+
expect(content, rel).not.toContain("deployed `/serve/{owner}/{app}/` app");
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
});
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
|
|
5
|
+
const root = path.resolve(__dirname, "..");
|
|
6
|
+
|
|
7
|
+
function readTemplateFile(relativePath: string) {
|
|
8
|
+
return fs.readFileSync(path.join(root, relativePath), "utf-8");
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
describe("state transitions template guidance", () => {
|
|
12
|
+
it("CLAUDE.md 列出状态流转 skill 入口", () => {
|
|
13
|
+
const claude = readTemplateFile("CLAUDE.md");
|
|
14
|
+
expect(claude).toMatch(/状态流转|state transition|transitions/);
|
|
15
|
+
expect(claude).toContain(".claude/skills/localapp-transitions");
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it(".claude/skills/ 包含状态流转 skill 文件", () => {
|
|
19
|
+
const skillPath = path.join(root, ".claude", "skills", "localapp-transitions", "SKILL.md");
|
|
20
|
+
expect(fs.existsSync(skillPath)).toBe(true);
|
|
21
|
+
|
|
22
|
+
const skill = fs.readFileSync(skillPath, "utf-8");
|
|
23
|
+
expect(skill).toContain("name: localapp-transitions");
|
|
24
|
+
expect(skill).toContain("business.transitions");
|
|
25
|
+
expect(skill).toContain("useTransitions");
|
|
26
|
+
expect(skill).toContain("from");
|
|
27
|
+
expect(skill).toContain("to");
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it("localapp-data skill 提示业务状态变化优先使用 transition API", () => {
|
|
31
|
+
const dataSkill = readTemplateFile(".claude/skills/localapp-data/SKILL.md");
|
|
32
|
+
expect(dataSkill).toMatch(/状态变化|状态流转|transition/);
|
|
33
|
+
expect(dataSkill).toMatch(/useTransitions|transition API/);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it("localapp-business skill 提示用 transition 而非 update 改业务状态", () => {
|
|
37
|
+
const businessSkill = readTemplateFile(".claude/skills/localapp-business/SKILL.md");
|
|
38
|
+
expect(businessSkill).toMatch(/transition|状态流转/);
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
describe("default App.tsx 状态流转示例", () => {
|
|
43
|
+
it("示例使用 useTransitions 而非普通 update 改业务状态", () => {
|
|
44
|
+
const app = readTemplateFile(path.join("src", "App.tsx"));
|
|
45
|
+
expect(app).toContain("useTransitions");
|
|
46
|
+
// 不应再用普通 useUpdate 来改业务状态字段
|
|
47
|
+
expect(app).not.toMatch(/useUpdate.*status/);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it("示例从 @localapp/sdk-react 导入 useTransitions", () => {
|
|
51
|
+
const app = readTemplateFile(path.join("src", "App.tsx"));
|
|
52
|
+
expect(app).toMatch(/from ["']@localapp\/sdk-react["']/);
|
|
53
|
+
expect(app).toMatch(/useTransitions/);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it("示例展示可用 transition 按钮和执行后刷新", () => {
|
|
57
|
+
const app = readTemplateFile(path.join("src", "App.tsx"));
|
|
58
|
+
// transitions.map 应当渲染按钮
|
|
59
|
+
expect(app).toMatch(/transitions\.map|transition\(/);
|
|
60
|
+
});
|
|
61
|
+
});
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
|
|
5
|
+
const root = path.resolve(__dirname, "..");
|
|
6
|
+
const runtimeRoot = fs.existsSync(path.join(root, "runtime")) ? "runtime" : path.join(".localapp", "runtime");
|
|
7
|
+
|
|
8
|
+
function readTemplateFile(relativePath: string) {
|
|
9
|
+
const parts = relativePath.split(/[\\/]/);
|
|
10
|
+
const resolved = parts[0] === "runtime" ? path.join(runtimeRoot, ...parts.slice(1)) : relativePath;
|
|
11
|
+
return fs.readFileSync(path.join(root, resolved), "utf-8");
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
describe("shadcn UI template files", () => {
|
|
15
|
+
it("includes shadcn project structure and key component files", () => {
|
|
16
|
+
expect(fs.existsSync(path.join(root, "components.json"))).toBe(true);
|
|
17
|
+
expect(fs.existsSync(path.join(root, "src", "lib", "utils.ts"))).toBe(true);
|
|
18
|
+
expect(fs.existsSync(path.join(root, "src", "components", "ui"))).toBe(true);
|
|
19
|
+
|
|
20
|
+
for (const component of [
|
|
21
|
+
"button",
|
|
22
|
+
"input",
|
|
23
|
+
"label",
|
|
24
|
+
"textarea",
|
|
25
|
+
"card",
|
|
26
|
+
"dialog",
|
|
27
|
+
"select",
|
|
28
|
+
"tabs",
|
|
29
|
+
"table",
|
|
30
|
+
"badge",
|
|
31
|
+
"popover",
|
|
32
|
+
"command",
|
|
33
|
+
"calendar",
|
|
34
|
+
"sheet",
|
|
35
|
+
"sidebar",
|
|
36
|
+
]) {
|
|
37
|
+
expect(fs.existsSync(path.join(root, "src", "components", "ui", `${component}.tsx`))).toBe(true);
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it("configures aliases, cn helper, and shadcn theme variables", () => {
|
|
42
|
+
const tsconfig = readTemplateFile("tsconfig.json");
|
|
43
|
+
expect(tsconfig).toContain('"baseUrl": "."');
|
|
44
|
+
expect(tsconfig).toContain('"@/*"');
|
|
45
|
+
expect(tsconfig).toContain('"src/*"');
|
|
46
|
+
expect(tsconfig).toContain('"extends": "@localapp/app-kit/tsconfig.base"');
|
|
47
|
+
|
|
48
|
+
// 别名现在由 CLI 领地的 vite plugin 注入,根 vite.config.ts 极简引用
|
|
49
|
+
const viteConfig = readTemplateFile("vite.config.ts");
|
|
50
|
+
expect(viteConfig).toContain("@localapp/app-kit/vite");
|
|
51
|
+
expect(viteConfig).toContain("localapp()");
|
|
52
|
+
|
|
53
|
+
// 真正的 alias/proxy 逻辑在 runtime/vite-plugin.mjs(.mjs 绕过 Node 26 node_modules type stripping 限制)
|
|
54
|
+
const vitePlugin = readTemplateFile("runtime/vite-plugin.mjs");
|
|
55
|
+
expect(vitePlugin).toContain("alias");
|
|
56
|
+
expect(vitePlugin).toContain('"@"');
|
|
57
|
+
expect(vitePlugin).toContain("proxy");
|
|
58
|
+
|
|
59
|
+
// 主题变量和 Tailwind 入口在 runtime/styles/preset.css
|
|
60
|
+
const preset = readTemplateFile(path.join("runtime", "styles", "preset.css"));
|
|
61
|
+
expect(preset).toContain('@import "tailwindcss";');
|
|
62
|
+
expect(preset).toContain("--background");
|
|
63
|
+
expect(preset).toContain("--primary");
|
|
64
|
+
expect(preset).toContain("--radius");
|
|
65
|
+
|
|
66
|
+
// src/index.css 仅引用 preset,不直接 import tailwind
|
|
67
|
+
const indexCss = readTemplateFile(path.join("src", "index.css"));
|
|
68
|
+
expect(indexCss).toContain("@localapp/app-kit/styles/preset.css");
|
|
69
|
+
|
|
70
|
+
// cn 实现在 runtime/lib/utils.ts,src/lib/utils.ts 为重新导出 shim
|
|
71
|
+
const runtimeUtils = readTemplateFile(path.join("runtime", "lib", "utils.ts"));
|
|
72
|
+
expect(runtimeUtils).toContain("export function cn");
|
|
73
|
+
expect(runtimeUtils).toContain("twMerge");
|
|
74
|
+
|
|
75
|
+
const shimUtils = readTemplateFile(path.join("src", "lib", "utils.ts"));
|
|
76
|
+
expect(shimUtils).toContain("@localapp/app-kit/lib/utils");
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it("documents shadcn UI guidance for AI agents", () => {
|
|
80
|
+
const claude = readTemplateFile("CLAUDE.md");
|
|
81
|
+
expect(claude).toContain(".claude/skills/localapp-ui");
|
|
82
|
+
expect(claude).toContain("@/components/ui");
|
|
83
|
+
|
|
84
|
+
const uiSkillPath = path.join(root, ".claude", "skills", "localapp-ui", "SKILL.md");
|
|
85
|
+
expect(fs.existsSync(uiSkillPath)).toBe(true);
|
|
86
|
+
const uiSkill = fs.readFileSync(uiSkillPath, "utf-8");
|
|
87
|
+
expect(uiSkill).toContain("shadcn/ui");
|
|
88
|
+
expect(uiSkill).toContain("基础组件优先");
|
|
89
|
+
expect(uiSkill).toContain("复杂组件");
|
|
90
|
+
expect(uiSkill).toContain("Command");
|
|
91
|
+
expect(uiSkill).toContain("Sidebar");
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
it("documents named SQL-first backend boundaries for AI agents", () => {
|
|
95
|
+
const claude = readTemplateFile("CLAUDE.md");
|
|
96
|
+
expect(claude).toContain("named SQL-first");
|
|
97
|
+
expect(claude).toContain("不要创建 `backend/actions/`");
|
|
98
|
+
expect(claude).toContain("反馈平台补齐原语");
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
it("uses shadcn base components in the default SDK example", () => {
|
|
102
|
+
const app = readTemplateFile(path.join("src", "App.tsx"));
|
|
103
|
+
expect(app).toContain("@/components/ui/button");
|
|
104
|
+
expect(app).toContain("@/components/ui/card");
|
|
105
|
+
expect(app).toContain("@/components/ui/input");
|
|
106
|
+
expect(app).toContain("@/components/ui/label");
|
|
107
|
+
expect(app).toContain("useMe");
|
|
108
|
+
expect(app).toContain("useQuery");
|
|
109
|
+
expect(app).toContain("useMutation");
|
|
110
|
+
expect(app).not.toContain("useAction");
|
|
111
|
+
expect(app).toContain("$work_items.complete");
|
|
112
|
+
expect(app).toContain("$work_items.create");
|
|
113
|
+
expect(app).toContain("htmlFor=");
|
|
114
|
+
expect(app).not.toContain("组件陈列");
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
it("includes backend contract examples with JSON schema declarations", () => {
|
|
118
|
+
const schema = JSON.parse(readTemplateFile(path.join("backend", "resources", "work_items", "schema.json")));
|
|
119
|
+
const queries = JSON.parse(readTemplateFile(path.join("backend", "resources", "work_items", "queries.json")));
|
|
120
|
+
const mutations = JSON.parse(readTemplateFile(path.join("backend", "resources", "work_items", "mutations.json")));
|
|
121
|
+
const resourceSchema = JSON.parse(readTemplateFile(path.join("backend", "schemas", "resource-schema.schema.json")));
|
|
122
|
+
const queriesSchema = JSON.parse(readTemplateFile(path.join("backend", "schemas", "queries.schema.json")));
|
|
123
|
+
const mutationsSchema = JSON.parse(readTemplateFile(path.join("backend", "schemas", "mutations.schema.json")));
|
|
124
|
+
|
|
125
|
+
expect(schema.$schema).toBe("https://localapp.dev/schemas/backend/resource-schema.schema.json");
|
|
126
|
+
expect(schema.name).toBe("work_items");
|
|
127
|
+
expect(schema.fields.created_by.type).toBe("string");
|
|
128
|
+
expect(queries.$schema).toBe("https://localapp.dev/schemas/backend/queries.schema.json");
|
|
129
|
+
expect(queries.queries["$work_items.list"]).toBeDefined();
|
|
130
|
+
expect(queries.queries["$work_items.get"]).toBeDefined();
|
|
131
|
+
expect(queries.queries["$work_items.count"]).toBeDefined();
|
|
132
|
+
expect(queries.queries["$work_items.list"].result.mode).toBe("page");
|
|
133
|
+
expect(queries.queries["$work_items.get"].result.mode).toBe("single");
|
|
134
|
+
expect(queries.queries["$work_items.count"].result.mode).toBe("aggregate");
|
|
135
|
+
expect(queries.queries["work_items.mine"]).toBeDefined();
|
|
136
|
+
expect(queries.queries["work_items.dashboard"]).toBeDefined();
|
|
137
|
+
expect(mutations.$schema).toBe("https://localapp.dev/schemas/backend/mutations.schema.json");
|
|
138
|
+
expect(mutations.mutations["$work_items.create"]).toBeDefined();
|
|
139
|
+
expect(mutations.mutations["$work_items.update"]).toBeDefined();
|
|
140
|
+
expect(mutations.mutations["$work_items.delete"]).toBeDefined();
|
|
141
|
+
expect(resourceSchema.$id).toBe("https://localapp.dev/schemas/backend/resource-schema.schema.json");
|
|
142
|
+
expect(queriesSchema.$id).toBe("https://localapp.dev/schemas/backend/queries.schema.json");
|
|
143
|
+
expect(mutationsSchema.$id).toBe("https://localapp.dev/schemas/backend/mutations.schema.json");
|
|
144
|
+
});
|
|
145
|
+
});
|