@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,143 @@
|
|
|
1
|
+
import { describe, it, expect, vi, beforeEach } from "vitest";
|
|
2
|
+
import { renderHook, waitFor, act } from "@testing-library/react";
|
|
3
|
+
import { useUpload } from "@localapp/sdk-react";
|
|
4
|
+
import { LocalAppError } from "@localapp/sdk";
|
|
5
|
+
|
|
6
|
+
describe("useUpload", () => {
|
|
7
|
+
beforeEach(() => {
|
|
8
|
+
delete (window as any).location;
|
|
9
|
+
(window as any).location = { pathname: "/serve/alice/my-app/", origin: "http://localhost:3000" };
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it("uploads a file successfully", async () => {
|
|
13
|
+
globalThis.fetch = vi.fn().mockResolvedValueOnce({
|
|
14
|
+
ok: true,
|
|
15
|
+
status: 201,
|
|
16
|
+
json: () => Promise.resolve({
|
|
17
|
+
success: true,
|
|
18
|
+
data: { key: "abc123.png", url: "/serve/alice/my-app/api/content/abc123.png" },
|
|
19
|
+
}),
|
|
20
|
+
} as Response);
|
|
21
|
+
|
|
22
|
+
const { result } = renderHook(() => useUpload());
|
|
23
|
+
const file = new File(["data"], "photo.png", { type: "image/png" });
|
|
24
|
+
|
|
25
|
+
let uploadResult;
|
|
26
|
+
await act(async () => {
|
|
27
|
+
uploadResult = await result.current.upload(file);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
expect(uploadResult).toEqual({
|
|
31
|
+
key: "abc123.png",
|
|
32
|
+
url: "/serve/alice/my-app/api/content/abc123.png",
|
|
33
|
+
});
|
|
34
|
+
expect(result.current.loading).toBe(false);
|
|
35
|
+
expect(result.current.error).toBeNull();
|
|
36
|
+
|
|
37
|
+
// Verify FormData was used
|
|
38
|
+
const fetchCall = (globalThis.fetch as ReturnType<typeof vi.fn>).mock.calls[0];
|
|
39
|
+
expect(fetchCall[1].method).toBe("POST");
|
|
40
|
+
expect(fetchCall[1].body).toBeInstanceOf(FormData);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it("sets loading during upload", async () => {
|
|
44
|
+
let resolveUpload: (value: any) => void;
|
|
45
|
+
const uploadPromise = new Promise((resolve) => { resolveUpload = resolve; });
|
|
46
|
+
globalThis.fetch = vi.fn().mockReturnValueOnce(uploadPromise);
|
|
47
|
+
|
|
48
|
+
const { result } = renderHook(() => useUpload());
|
|
49
|
+
const file = new File(["data"], "photo.png", { type: "image/png" });
|
|
50
|
+
|
|
51
|
+
act(() => {
|
|
52
|
+
result.current.upload(file);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
expect(result.current.loading).toBe(true);
|
|
56
|
+
|
|
57
|
+
await act(async () => {
|
|
58
|
+
resolveUpload!({
|
|
59
|
+
ok: true,
|
|
60
|
+
status: 201,
|
|
61
|
+
json: () => Promise.resolve({ success: true, data: { key: "a.png", url: "/x" } }),
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
expect(result.current.loading).toBe(false);
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it("sets error and rejects on server error", async () => {
|
|
69
|
+
globalThis.fetch = vi.fn().mockResolvedValueOnce({
|
|
70
|
+
ok: false,
|
|
71
|
+
status: 401,
|
|
72
|
+
json: () => Promise.resolve({ success: false, error: "Authentication required" }),
|
|
73
|
+
} as Response);
|
|
74
|
+
|
|
75
|
+
const { result } = renderHook(() => useUpload());
|
|
76
|
+
const file = new File(["data"], "photo.png", { type: "image/png" });
|
|
77
|
+
|
|
78
|
+
let thrown: unknown;
|
|
79
|
+
await act(async () => {
|
|
80
|
+
try {
|
|
81
|
+
await result.current.upload(file);
|
|
82
|
+
} catch (e) {
|
|
83
|
+
thrown = e;
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
expect(thrown).toBeInstanceOf(LocalAppError);
|
|
88
|
+
expect((thrown as LocalAppError).status).toBe(401);
|
|
89
|
+
expect(result.current.loading).toBe(false);
|
|
90
|
+
expect(result.current.error).toBeInstanceOf(LocalAppError);
|
|
91
|
+
expect(result.current.error?.status).toBe(401);
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
it("handles unsupported file type (400)", async () => {
|
|
95
|
+
globalThis.fetch = vi.fn().mockResolvedValueOnce({
|
|
96
|
+
ok: false,
|
|
97
|
+
status: 400,
|
|
98
|
+
json: () => Promise.resolve({ success: false, error: "Unsupported file type" }),
|
|
99
|
+
} as Response);
|
|
100
|
+
|
|
101
|
+
const { result } = renderHook(() => useUpload());
|
|
102
|
+
const file = new File(["data"], "doc.txt", { type: "text/plain" });
|
|
103
|
+
|
|
104
|
+
let thrown: unknown;
|
|
105
|
+
await act(async () => {
|
|
106
|
+
try {
|
|
107
|
+
await result.current.upload(file);
|
|
108
|
+
} catch (e) {
|
|
109
|
+
thrown = e;
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
expect(thrown).toBeInstanceOf(LocalAppError);
|
|
114
|
+
expect((thrown as LocalAppError).message).toBe("Unsupported file type");
|
|
115
|
+
expect((thrown as LocalAppError).status).toBe(400);
|
|
116
|
+
expect(result.current.error?.status).toBe(400);
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
it("handles file too large (413)", async () => {
|
|
120
|
+
globalThis.fetch = vi.fn().mockResolvedValueOnce({
|
|
121
|
+
ok: false,
|
|
122
|
+
status: 413,
|
|
123
|
+
json: () => Promise.resolve({ success: false, error: "File exceeds 10MB limit" }),
|
|
124
|
+
} as Response);
|
|
125
|
+
|
|
126
|
+
const { result } = renderHook(() => useUpload());
|
|
127
|
+
const file = new File(["x".repeat(1024)], "big.png", { type: "image/png" });
|
|
128
|
+
|
|
129
|
+
let thrown: unknown;
|
|
130
|
+
await act(async () => {
|
|
131
|
+
try {
|
|
132
|
+
await result.current.upload(file);
|
|
133
|
+
} catch (e) {
|
|
134
|
+
thrown = e;
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
expect(thrown).toBeInstanceOf(LocalAppError);
|
|
139
|
+
expect((thrown as LocalAppError).message).toBe("File exceeds 10MB limit");
|
|
140
|
+
expect((thrown as LocalAppError).status).toBe(413);
|
|
141
|
+
expect(result.current.error?.status).toBe(413);
|
|
142
|
+
});
|
|
143
|
+
});
|
|
@@ -0,0 +1,426 @@
|
|
|
1
|
+
// @vitest-environment node
|
|
2
|
+
import { describe, expect, it } from "vitest";
|
|
3
|
+
// @ts-ignore - .mjs file has no type declarations
|
|
4
|
+
import { buildDevServer, buildProxy, localapp } from "@localapp/app-kit/vite";
|
|
5
|
+
|
|
6
|
+
type VitePlugin = {
|
|
7
|
+
name: string;
|
|
8
|
+
transformIndexHtml?: (html: string) => string | null | undefined;
|
|
9
|
+
resolveId?: (id: string) => string | null | undefined;
|
|
10
|
+
load?: (id: string) => string | null | undefined;
|
|
11
|
+
buildStart?: { call: (ctx: unknown) => void } | (() => void);
|
|
12
|
+
config?: (userConfig: any, env?: { command?: string }) => any;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const TEST_DEV_CONFIG = {
|
|
16
|
+
serverUrl: "http://127.0.0.1:43127",
|
|
17
|
+
userId: "testuser",
|
|
18
|
+
pageName: "demo",
|
|
19
|
+
appServerPort: 5182,
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
function getLocalAppworkPlugin(options: { command?: "serve" | "build"; devConfig?: Record<string, unknown>; devApiKey?: string } = {}): VitePlugin {
|
|
23
|
+
// @ts-ignore - localapp accepts vite UserConfig-style options
|
|
24
|
+
const plugins = localapp({ devApiKey: "test-key", ...options, devConfig: options.devConfig ?? TEST_DEV_CONFIG });
|
|
25
|
+
return plugins.find((p: VitePlugin) => p.name === "localapp-runtime");
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function applyProxyRequest(proxyConfig: any, method: string, url: string) {
|
|
29
|
+
let proxyRequestHandler: ((proxyReq: any, req: any) => void) | undefined;
|
|
30
|
+
proxyConfig.configure({
|
|
31
|
+
on: (event: string, handler: (proxyReq: any, req: any) => void) => {
|
|
32
|
+
if (event === "proxyReq") proxyRequestHandler = handler;
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
const headers = new Map<string, string>();
|
|
37
|
+
const proxyReq = {
|
|
38
|
+
path: url,
|
|
39
|
+
setHeader: (name: string, value: string) => headers.set(name, value),
|
|
40
|
+
};
|
|
41
|
+
proxyRequestHandler!(proxyReq, { method, url });
|
|
42
|
+
return { headers, path: proxyReq.path };
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function matchingProxy(config: any, requestPath: string) {
|
|
46
|
+
for (const [context, proxyConfig] of Object.entries(config.proxy)) {
|
|
47
|
+
const matches = context.startsWith("^")
|
|
48
|
+
? new RegExp(context).test(requestPath)
|
|
49
|
+
: requestPath.startsWith(context);
|
|
50
|
+
if (matches) return proxyConfig as any;
|
|
51
|
+
}
|
|
52
|
+
throw new Error(`No proxy matched ${requestPath}`);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function matchingProxyIndex(config: any, requestPath: string) {
|
|
56
|
+
return Object.keys(config.proxy).findIndex((context) => (
|
|
57
|
+
context.startsWith("^")
|
|
58
|
+
? new RegExp(context).test(requestPath)
|
|
59
|
+
: requestPath.startsWith(context)
|
|
60
|
+
));
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
describe("vite-plugin DevShell virtual module injection", () => {
|
|
64
|
+
describe("transformIndexHtml hook", () => {
|
|
65
|
+
it("exists when command=serve", () => {
|
|
66
|
+
const qplugin = getLocalAppworkPlugin({ command: "serve" });
|
|
67
|
+
expect(qplugin).toBeDefined();
|
|
68
|
+
expect(typeof qplugin.transformIndexHtml).toBe("function");
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it("replaces main.tsx script with the virtual module in dev", () => {
|
|
72
|
+
const qplugin = getLocalAppworkPlugin({ command: "serve" });
|
|
73
|
+
const html = `<script type="module" crossorigin src="/src/main.tsx"></script>`;
|
|
74
|
+
const result = qplugin.transformIndexHtml!(html);
|
|
75
|
+
expect(result).toContain("/virtual:localapp-dev.tsx");
|
|
76
|
+
expect(result).not.toContain('src="/src/main.tsx"');
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it("replaces main.tsx script with query string in dev", () => {
|
|
80
|
+
const qplugin = getLocalAppworkPlugin({ command: "serve" });
|
|
81
|
+
const html = `<script type="module" crossorigin src="/src/main.tsx?t=1781618087021"></script>`;
|
|
82
|
+
const result = qplugin.transformIndexHtml!(html);
|
|
83
|
+
expect(result).toContain("/virtual:localapp-dev.tsx");
|
|
84
|
+
expect(result).not.toContain('src="/src/main.tsx?t=');
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it("reads serve command from Vite config hook before injection", () => {
|
|
88
|
+
const qplugin = getLocalAppworkPlugin();
|
|
89
|
+
qplugin.config?.({}, { command: "serve" });
|
|
90
|
+
const html = `<script type="module" crossorigin src="/src/main.tsx"></script>`;
|
|
91
|
+
const result = qplugin.transformIndexHtml!(html);
|
|
92
|
+
expect(result).toContain("/virtual:localapp-dev.tsx");
|
|
93
|
+
expect(result).not.toContain('src="/src/main.tsx"');
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it("does not modify html in build mode", () => {
|
|
97
|
+
const qplugin = getLocalAppworkPlugin({ command: "build" });
|
|
98
|
+
const html = `<script type="module" crossorigin src="/src/main.tsx"></script>`;
|
|
99
|
+
const result = qplugin.transformIndexHtml!(html);
|
|
100
|
+
expect(result).toBe(html);
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
it("does not inject dev-only markers in build mode", () => {
|
|
104
|
+
const qplugin = getLocalAppworkPlugin({ command: "build" });
|
|
105
|
+
const html = `<script type="module" crossorigin src="/src/main.tsx"></script>`;
|
|
106
|
+
const result = qplugin.transformIndexHtml!(html);
|
|
107
|
+
const devOnlyMarkers = [
|
|
108
|
+
"localapp-dev-shell",
|
|
109
|
+
"localapp:dev-context-changed",
|
|
110
|
+
"/api/dev/context",
|
|
111
|
+
"/api/dev/data",
|
|
112
|
+
"/api/dev/diagnostics",
|
|
113
|
+
"/api/dev/business",
|
|
114
|
+
"iframe",
|
|
115
|
+
"sandbox",
|
|
116
|
+
];
|
|
117
|
+
|
|
118
|
+
for (const marker of devOnlyMarkers) {
|
|
119
|
+
expect(result).not.toContain(marker);
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
describe("resolveId hook", () => {
|
|
125
|
+
it("resolves the TSX virtual module in serve mode", () => {
|
|
126
|
+
const qplugin = getLocalAppworkPlugin({ command: "serve" });
|
|
127
|
+
const resolved = qplugin.resolveId!("/virtual:localapp-dev.tsx");
|
|
128
|
+
expect(resolved).toBe("\0virtual:localapp-dev.tsx");
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
it("returns null for non-virtual modules", () => {
|
|
132
|
+
const qplugin = getLocalAppworkPlugin({ command: "serve" });
|
|
133
|
+
const resolved = qplugin.resolveId!("/src/main.tsx");
|
|
134
|
+
expect(resolved).toBeNull();
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
it("does not resolve the DevShell virtual module in build mode", () => {
|
|
138
|
+
const qplugin = getLocalAppworkPlugin({ command: "build" });
|
|
139
|
+
expect(qplugin.resolveId!("/virtual:localapp-dev.tsx")).toBeNull();
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
describe("load hook", () => {
|
|
144
|
+
it("returns native DevShell virtual module source in serve mode", () => {
|
|
145
|
+
const qplugin = getLocalAppworkPlugin({ command: "serve" });
|
|
146
|
+
const code = qplugin.load!("\0virtual:localapp-dev.tsx");
|
|
147
|
+
expect(code).toContain('import { DevShell } from "@localapp/app-kit/dev-shell"');
|
|
148
|
+
expect(code).toContain('import "/src/index.css";');
|
|
149
|
+
expect(code).toContain('import App from "/src/App.tsx"');
|
|
150
|
+
expect(code).toContain("createRoot");
|
|
151
|
+
expect(code).toContain("React.createElement(DevShell");
|
|
152
|
+
expect(code).toContain("React.createElement(App");
|
|
153
|
+
expect(code).not.toContain("<DevShell>");
|
|
154
|
+
expect(code).not.toContain("<App />");
|
|
155
|
+
expect(code).not.toContain("iframe");
|
|
156
|
+
expect(code).not.toContain("sandbox");
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
it("returns null for non-virtual module IDs", () => {
|
|
160
|
+
const qplugin = getLocalAppworkPlugin({ command: "serve" });
|
|
161
|
+
const code = qplugin.load!("/src/main.tsx");
|
|
162
|
+
expect(code).toBeNull();
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
it("does not load DevShell virtual module source in build mode", () => {
|
|
166
|
+
const qplugin = getLocalAppworkPlugin({ command: "build" });
|
|
167
|
+
const code = qplugin.load!("\0virtual:localapp-dev.tsx");
|
|
168
|
+
expect(code).toBeNull();
|
|
169
|
+
});
|
|
170
|
+
});
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
describe("vite-plugin App path checks", () => {
|
|
174
|
+
it("has buildStart hook in serve mode", () => {
|
|
175
|
+
const qplugin = getLocalAppworkPlugin({ command: "serve" });
|
|
176
|
+
expect(typeof qplugin.buildStart).toBe("function");
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
it("does not throw from buildStart when src/App.tsx exists", () => {
|
|
180
|
+
const qplugin = getLocalAppworkPlugin({ command: "serve" });
|
|
181
|
+
expect(() => qplugin.buildStart!.call({})).not.toThrow();
|
|
182
|
+
});
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
describe("vite-plugin dev auth injection", () => {
|
|
186
|
+
it("injects a private process credential without requiring it in dev-config", () => {
|
|
187
|
+
// Break caught: persisting the proxy credential in public dev-config leaks it into project state.
|
|
188
|
+
const qplugin = getLocalAppworkPlugin({ command: "serve" });
|
|
189
|
+
const config = qplugin.config?.({}, { command: "serve" });
|
|
190
|
+
const request = applyProxyRequest(config.server.proxy["/api"], "GET", "/api/tasks");
|
|
191
|
+
|
|
192
|
+
expect(TEST_DEV_CONFIG).not.toHaveProperty("apiKey");
|
|
193
|
+
expect(request.headers.get("X-API-Key")).toBe("test-key");
|
|
194
|
+
});
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
describe("vite-plugin canonical Server routing", () => {
|
|
198
|
+
it("routes ordinary APIs and Device Action endpoints to the same local Server", () => {
|
|
199
|
+
const config = buildProxy(
|
|
200
|
+
{
|
|
201
|
+
serverUrl: "http://127.0.0.1:43127",
|
|
202
|
+
apiKey: "test-key",
|
|
203
|
+
userId: "testuser",
|
|
204
|
+
pageName: "demo",
|
|
205
|
+
},
|
|
206
|
+
"http://127.0.0.1:43127",
|
|
207
|
+
);
|
|
208
|
+
|
|
209
|
+
expect(matchingProxy(config, "/api/device-actions").target).toBe("http://127.0.0.1:43127");
|
|
210
|
+
expect(matchingProxy(config, "/api/desktop-actions").target).toBe("http://127.0.0.1:43127");
|
|
211
|
+
expect(config.proxy["/api"].target).toBe("http://127.0.0.1:43127");
|
|
212
|
+
expect(config.proxy["/api"].rewrite("/api/tasks")).toBe("/serve/testuser/demo/api/tasks");
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
it("rewrites only exact POST Device Action creation and adds canonical auth headers", () => {
|
|
216
|
+
const config = buildProxy(
|
|
217
|
+
{
|
|
218
|
+
apiKey: "test-key",
|
|
219
|
+
userId: "testuser",
|
|
220
|
+
pageName: "demo",
|
|
221
|
+
},
|
|
222
|
+
"https://prod.example",
|
|
223
|
+
);
|
|
224
|
+
const deviceActions = matchingProxy(config, "/api/device-actions");
|
|
225
|
+
|
|
226
|
+
const create = applyProxyRequest(
|
|
227
|
+
deviceActions,
|
|
228
|
+
"POST",
|
|
229
|
+
"/api/device-actions?source=dev",
|
|
230
|
+
);
|
|
231
|
+
expect(create.path).toBe(
|
|
232
|
+
"/serve/testuser/demo/api/device-actions?source=dev",
|
|
233
|
+
);
|
|
234
|
+
expect(create.headers.get("X-API-Key")).toBe("test-key");
|
|
235
|
+
expect(create.headers.get("Referer")).toBe("https://prod.example/testuser/demo/");
|
|
236
|
+
|
|
237
|
+
for (const [method, path] of [
|
|
238
|
+
["GET", "/api/device-actions"],
|
|
239
|
+
["POST", "/api/device-actions/"],
|
|
240
|
+
["GET", "/api/device-actions/capabilities"],
|
|
241
|
+
["GET", "/api/device-actions/request-1"],
|
|
242
|
+
["GET", "/api/device-actions/request-1/events"],
|
|
243
|
+
["PATCH", "/api/device-actions/request-1/status"],
|
|
244
|
+
["POST", "/api/device-actions/recover"],
|
|
245
|
+
]) {
|
|
246
|
+
const forwarded = applyProxyRequest(deviceActions, method, path);
|
|
247
|
+
expect(forwarded.path).toBe(path);
|
|
248
|
+
expect(forwarded.headers.get("X-API-Key")).toBe("test-key");
|
|
249
|
+
expect(forwarded.headers.has("Referer")).toBe(false);
|
|
250
|
+
}
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
it("routes global APIs and page APIs to one configured Server", () => {
|
|
254
|
+
const config = buildProxy(
|
|
255
|
+
{ serverUrl: "http://127.0.0.1:43127", apiKey: "test-key", userId: "testuser", pageName: "demo" },
|
|
256
|
+
"http://127.0.0.1:43127",
|
|
257
|
+
);
|
|
258
|
+
|
|
259
|
+
expect(matchingProxy(config, "/api/llm").target).toBe("http://127.0.0.1:43127");
|
|
260
|
+
expect(matchingProxy(config, "/api/issues").target).toBe("http://127.0.0.1:43127");
|
|
261
|
+
expect(matchingProxy(config, "/api/platform").target).toBe("http://127.0.0.1:43127");
|
|
262
|
+
expect(matchingProxy(config, "/api/dev").target).toBe("http://127.0.0.1:43127");
|
|
263
|
+
expect(config.proxy["/api"].target).toBe("http://127.0.0.1:43127");
|
|
264
|
+
expect(config.proxy["/api"].rewrite("/api/tasks")).toBe("/serve/testuser/demo/api/tasks");
|
|
265
|
+
const devContext = applyProxyRequest(matchingProxy(config, "/api/dev/context"), "GET", "/api/dev/context");
|
|
266
|
+
expect(devContext.path).toBe("/api/dev/context");
|
|
267
|
+
expect(devContext.headers.get("X-API-Key")).toBe("test-key");
|
|
268
|
+
expect(devContext.headers.get("X-LocalApp-Dev-Page")).toBe("demo");
|
|
269
|
+
|
|
270
|
+
const issues = applyProxyRequest(matchingProxy(config, "/api/issues"), "GET", "/api/issues?pagePath=/testuser/demo/");
|
|
271
|
+
expect(issues.path).toBe("/api/issues?pagePath=/testuser/demo/");
|
|
272
|
+
expect(issues.headers.get("X-API-Key")).toBe("test-key");
|
|
273
|
+
|
|
274
|
+
const platformUsers = applyProxyRequest(matchingProxy(config, "/api/platform/users"), "GET", "/api/platform/users");
|
|
275
|
+
expect(platformUsers.path).toBe("/api/platform/users");
|
|
276
|
+
expect(platformUsers.headers.get("X-API-Key")).toBe("test-key");
|
|
277
|
+
});
|
|
278
|
+
|
|
279
|
+
it("proxies application resource URLs to the canonical Server with dev auth", () => {
|
|
280
|
+
const config = buildProxy(
|
|
281
|
+
{ serverUrl: "http://127.0.0.1:43127", apiKey: "test-key", userId: "testuser", pageName: "demo" },
|
|
282
|
+
"http://127.0.0.1:43127",
|
|
283
|
+
);
|
|
284
|
+
|
|
285
|
+
expect(matchingProxy(config, "/serve/testuser/demo/").target).toBe("http://127.0.0.1:43127");
|
|
286
|
+
const content = applyProxyRequest(
|
|
287
|
+
matchingProxy(config, "/serve/testuser/demo/api/content/image-key"),
|
|
288
|
+
"GET",
|
|
289
|
+
"/serve/testuser/demo/api/content/image-key",
|
|
290
|
+
);
|
|
291
|
+
expect(content.path).toBe("/serve/testuser/demo/api/content/image-key");
|
|
292
|
+
expect(content.headers.get("X-API-Key")).toBe("test-key");
|
|
293
|
+
expect(content.headers.get("X-LocalApp-Dev-Page")).toBe("demo");
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
it("keeps global exceptions before the page API fallback", () => {
|
|
297
|
+
const config = buildProxy(
|
|
298
|
+
{ serverUrl: "http://127.0.0.1:43127", apiKey: "test-key", userId: "testuser", pageName: "demo" },
|
|
299
|
+
"http://127.0.0.1:43127",
|
|
300
|
+
);
|
|
301
|
+
|
|
302
|
+
for (const endpoint of [
|
|
303
|
+
"/api/me",
|
|
304
|
+
"/api/users",
|
|
305
|
+
"/api/groups",
|
|
306
|
+
"/api/llm",
|
|
307
|
+
"/api/issues",
|
|
308
|
+
"/api/platform",
|
|
309
|
+
"/api/device-actions",
|
|
310
|
+
"/api/desktop-actions",
|
|
311
|
+
]) {
|
|
312
|
+
expect(matchingProxyIndex(config, endpoint)).toBeLessThan(Object.keys(config.proxy).indexOf("/api"));
|
|
313
|
+
}
|
|
314
|
+
expect(matchingProxy(config, "/api/messages")).toBe(config.proxy["/api"]);
|
|
315
|
+
});
|
|
316
|
+
|
|
317
|
+
it("does not create a local API proxy without a canonical Server URL", () => {
|
|
318
|
+
expect(buildProxy({ serverUrl: "", apiKey: "", userId: "testuser", pageName: "demo" }, "")).toBeUndefined();
|
|
319
|
+
});
|
|
320
|
+
|
|
321
|
+
it("keeps Device Action creation before the page API fallback", () => {
|
|
322
|
+
const config = buildProxy(
|
|
323
|
+
{ serverUrl: "https://prod.example", apiKey: "test-key", userId: "testuser", pageName: "demo" },
|
|
324
|
+
"https://prod.example",
|
|
325
|
+
);
|
|
326
|
+
|
|
327
|
+
expect(matchingProxyIndex(config, "/api/device-actions")).toBeLessThan(
|
|
328
|
+
Object.keys(config.proxy).indexOf("/api"),
|
|
329
|
+
);
|
|
330
|
+
expect(matchingProxyIndex(config, "/api/desktop-actions")).toBeLessThan(
|
|
331
|
+
Object.keys(config.proxy).indexOf("/api"),
|
|
332
|
+
);
|
|
333
|
+
});
|
|
334
|
+
|
|
335
|
+
it("uses the same exact creation exception for the legacy alias", () => {
|
|
336
|
+
const config = buildProxy(
|
|
337
|
+
{
|
|
338
|
+
apiKey: "legacy-key",
|
|
339
|
+
userId: "owner name",
|
|
340
|
+
pageName: "desktop/app",
|
|
341
|
+
},
|
|
342
|
+
"https://prod.example/base",
|
|
343
|
+
);
|
|
344
|
+
const desktopActions = matchingProxy(config, "/api/desktop-actions");
|
|
345
|
+
|
|
346
|
+
const create = applyProxyRequest(desktopActions, "POST", "/api/desktop-actions");
|
|
347
|
+
expect(create.path).toBe(
|
|
348
|
+
"/serve/owner%20name/desktop%2Fapp/api/desktop-actions",
|
|
349
|
+
);
|
|
350
|
+
expect(create.headers.get("X-API-Key")).toBe("legacy-key");
|
|
351
|
+
expect(create.headers.get("Referer")).toBe(
|
|
352
|
+
"https://prod.example/owner%20name/desktop%2Fapp/",
|
|
353
|
+
);
|
|
354
|
+
|
|
355
|
+
for (const [method, path] of [
|
|
356
|
+
["PUT", "/api/desktop-actions"],
|
|
357
|
+
["GET", "/api/desktop-actions/capabilities"],
|
|
358
|
+
["GET", "/api/desktop-actions/request-1"],
|
|
359
|
+
["GET", "/api/desktop-actions/request-1/events"],
|
|
360
|
+
["PATCH", "/api/desktop-actions/request-1/status"],
|
|
361
|
+
["POST", "/api/desktop-actions/recover"],
|
|
362
|
+
]) {
|
|
363
|
+
const forwarded = applyProxyRequest(desktopActions, method, path);
|
|
364
|
+
expect(forwarded.path).toBe(path);
|
|
365
|
+
expect(forwarded.headers.get("X-API-Key")).toBe("legacy-key");
|
|
366
|
+
expect(forwarded.headers.has("Referer")).toBe(false);
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
expect(config.proxy["/api"].rewrite("/api/tasks")).toBe(
|
|
370
|
+
"/serve/owner name/desktop/app/api/tasks",
|
|
371
|
+
);
|
|
372
|
+
});
|
|
373
|
+
});
|
|
374
|
+
|
|
375
|
+
describe("vite-plugin dependency prebundling", () => {
|
|
376
|
+
it("prebundles only direct DevShell markdown dependencies", () => {
|
|
377
|
+
const qplugin = getLocalAppworkPlugin({ command: "serve" });
|
|
378
|
+
const config = qplugin.config?.({}, { command: "serve" });
|
|
379
|
+
|
|
380
|
+
expect(config.optimizeDeps.include).toEqual(
|
|
381
|
+
expect.arrayContaining(["react-markdown", "remark-gfm", "unified", "remark-parse"]),
|
|
382
|
+
);
|
|
383
|
+
expect(config.optimizeDeps.include).not.toContain("style-to-js");
|
|
384
|
+
expect(config.optimizeDeps.include).not.toContain("debug");
|
|
385
|
+
});
|
|
386
|
+
});
|
|
387
|
+
|
|
388
|
+
describe("vite-plugin dev server address", () => {
|
|
389
|
+
it("fails clearly when canonical Server development configuration is incomplete", () => {
|
|
390
|
+
expect(() => buildDevServer({}, {}, "test-key")).toThrow(/dev-config\.json.*serverUrl.*userId.*pageName.*appServerPort/i);
|
|
391
|
+
});
|
|
392
|
+
|
|
393
|
+
it("forces the credential-injecting Vite listener to loopback", () => {
|
|
394
|
+
const server = buildDevServer(
|
|
395
|
+
TEST_DEV_CONFIG,
|
|
396
|
+
{ host: "0.0.0.0", open: false },
|
|
397
|
+
"test-key",
|
|
398
|
+
);
|
|
399
|
+
|
|
400
|
+
expect(server).toMatchObject({
|
|
401
|
+
host: "127.0.0.1",
|
|
402
|
+
open: false,
|
|
403
|
+
port: 5182,
|
|
404
|
+
strictPort: true,
|
|
405
|
+
allowedHosts: ["localhost", "127.0.0.1"],
|
|
406
|
+
});
|
|
407
|
+
expect(server.proxy["/api"].target).toBe("http://127.0.0.1:43127");
|
|
408
|
+
});
|
|
409
|
+
|
|
410
|
+
it.each([
|
|
411
|
+
"https://127.0.0.1:43127",
|
|
412
|
+
"http://localhost:43127",
|
|
413
|
+
"http://192.0.2.10:43127",
|
|
414
|
+
"http://user:password@127.0.0.1:43127",
|
|
415
|
+
"http://127.0.0.1:43127/base",
|
|
416
|
+
"http://127.0.0.1:43127?target=remote",
|
|
417
|
+
"http://127.0.0.1:43127#fragment",
|
|
418
|
+
"http://127.0.0.1:0",
|
|
419
|
+
"http://127.0.0.1:65536",
|
|
420
|
+
"http://127.0.0.1",
|
|
421
|
+
])("rejects a non-canonical credential proxy target: %s", (serverUrl) => {
|
|
422
|
+
expect(() => buildDevServer({ ...TEST_DEV_CONFIG, serverUrl }, {}, "test-key")).toThrow(
|
|
423
|
+
/serverUrl.*http:\/\/127\.0\.0\.1:<nonzero-port>/i,
|
|
424
|
+
);
|
|
425
|
+
});
|
|
426
|
+
});
|