@headless-lms/server 0.1.0 → 0.3.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/README.md +1 -1
- package/dist/_virtual/_rolldown/runtime.js +5 -0
- package/dist/app/community-mail.d.ts +26 -0
- package/dist/app/community-mail.js +96 -0
- package/dist/app/community-mail.js.map +1 -0
- package/dist/app/container.d.ts +22 -14
- package/dist/app/container.js +186 -62
- package/dist/app/container.js.map +1 -1
- package/dist/app/mcp-endpoints.d.ts +13 -0
- package/dist/app/mcp-endpoints.js +25 -0
- package/dist/app/mcp-endpoints.js.map +1 -0
- package/dist/http/config.d.ts +2 -1
- package/dist/http/errors.d.ts +14 -0
- package/dist/http/errors.js +147 -0
- package/dist/http/errors.js.map +1 -0
- package/dist/http/mcp/catalogue.d.ts +37 -0
- package/dist/http/mcp/catalogue.js +69 -0
- package/dist/http/mcp/catalogue.js.map +1 -0
- package/dist/http/mcp/challenge.d.ts +7 -0
- package/dist/http/mcp/challenge.js +35 -0
- package/dist/http/mcp/challenge.js.map +1 -0
- package/dist/http/mcp/input-schema.d.ts +7 -0
- package/dist/http/mcp/input-schema.js +28 -0
- package/dist/http/mcp/input-schema.js.map +1 -0
- package/dist/http/mcp/route.d.ts +8 -0
- package/dist/http/mcp/route.js +75 -0
- package/dist/http/mcp/route.js.map +1 -0
- package/dist/http/mcp/server.d.ts +8 -0
- package/dist/http/mcp/server.js +31 -0
- package/dist/http/mcp/server.js.map +1 -0
- package/dist/http/mcp/test-support.d.ts +55 -0
- package/dist/http/mcp/test-support.js +151 -0
- package/dist/http/mcp/test-support.js.map +1 -0
- package/dist/http/mcp/tool.d.ts +48 -0
- package/dist/http/mcp/tool.js +58 -0
- package/dist/http/mcp/tool.js.map +1 -0
- package/dist/http/mcp/tools/automations.d.ts +6 -0
- package/dist/http/mcp/tools/automations.js +120 -0
- package/dist/http/mcp/tools/automations.js.map +1 -0
- package/dist/http/mcp/tools/catalog.d.ts +6 -0
- package/dist/http/mcp/tools/catalog.js +200 -0
- package/dist/http/mcp/tools/catalog.js.map +1 -0
- package/dist/http/mcp/tools/comments.d.ts +6 -0
- package/dist/http/mcp/tools/comments.js +70 -0
- package/dist/http/mcp/tools/comments.js.map +1 -0
- package/dist/http/mcp/tools/communities.d.ts +6 -0
- package/dist/http/mcp/tools/communities.js +175 -0
- package/dist/http/mcp/tools/communities.js.map +1 -0
- package/dist/http/mcp/tools/community-members.d.ts +6 -0
- package/dist/http/mcp/tools/community-members.js +89 -0
- package/dist/http/mcp/tools/community-members.js.map +1 -0
- package/dist/http/mcp/tools/community-moderation.d.ts +6 -0
- package/dist/http/mcp/tools/community-moderation.js +144 -0
- package/dist/http/mcp/tools/community-moderation.js.map +1 -0
- package/dist/http/mcp/tools/courses.d.ts +6 -0
- package/dist/http/mcp/tools/courses.js +121 -0
- package/dist/http/mcp/tools/courses.js.map +1 -0
- package/dist/http/mcp/tools/index.d.ts +6 -0
- package/dist/http/mcp/tools/index.js +23 -0
- package/dist/http/mcp/tools/index.js.map +1 -0
- package/dist/http/mcp/tools/people.d.ts +6 -0
- package/dist/http/mcp/tools/people.js +145 -0
- package/dist/http/mcp/tools/people.js.map +1 -0
- package/dist/http/plugins/auth.js +13 -5
- package/dist/http/plugins/auth.js.map +1 -1
- package/dist/http/plugins/error-handler.d.ts +3 -2
- package/dist/http/plugins/error-handler.js +52 -57
- package/dist/http/plugins/error-handler.js.map +1 -1
- package/dist/http/plugins/openapi.js +70 -20
- package/dist/http/plugins/openapi.js.map +1 -1
- package/dist/http/routes/access.d.ts +7 -0
- package/dist/http/routes/access.js +140 -0
- package/dist/http/routes/access.js.map +1 -0
- package/dist/http/routes/activities.js +97 -20
- package/dist/http/routes/activities.js.map +1 -1
- package/dist/http/routes/assets.js +60 -51
- package/dist/http/routes/assets.js.map +1 -1
- package/dist/http/routes/automations.js +64 -20
- package/dist/http/routes/automations.js.map +1 -1
- package/dist/http/routes/bundles.d.ts +7 -0
- package/dist/http/routes/bundles.js +181 -0
- package/dist/http/routes/bundles.js.map +1 -0
- package/dist/http/routes/communities.d.ts +7 -0
- package/dist/http/routes/communities.js +462 -0
- package/dist/http/routes/communities.js.map +1 -0
- package/dist/http/routes/community-moderation.d.ts +7 -0
- package/dist/http/routes/community-moderation.js +425 -0
- package/dist/http/routes/community-moderation.js.map +1 -0
- package/dist/http/routes/course-analytics.d.ts +7 -0
- package/dist/http/routes/course-analytics.js +60 -0
- package/dist/http/routes/course-analytics.js.map +1 -0
- package/dist/http/routes/courses.js +38 -23
- package/dist/http/routes/courses.js.map +1 -1
- package/dist/http/routes/dashboard.js +17 -8
- package/dist/http/routes/dashboard.js.map +1 -1
- package/dist/http/routes/discussion.js +35 -27
- package/dist/http/routes/discussion.js.map +1 -1
- package/dist/http/routes/downloads.js +58 -40
- package/dist/http/routes/downloads.js.map +1 -1
- package/dist/http/routes/entitlements.js +16 -7
- package/dist/http/routes/entitlements.js.map +1 -1
- package/dist/http/routes/integrations.js +38 -41
- package/dist/http/routes/integrations.js.map +1 -1
- package/dist/http/routes/member/actor.d.ts +14 -0
- package/dist/http/routes/member/actor.js +11 -0
- package/dist/http/routes/member/actor.js.map +1 -0
- package/dist/http/routes/member/assets.d.ts +7 -0
- package/dist/http/routes/member/assets.js +79 -0
- package/dist/http/routes/member/assets.js.map +1 -0
- package/dist/http/routes/member/chats.d.ts +7 -0
- package/dist/http/routes/member/chats.js +456 -0
- package/dist/http/routes/member/chats.js.map +1 -0
- package/dist/http/routes/member/comments.d.ts +7 -0
- package/dist/http/routes/member/comments.js +187 -0
- package/dist/http/routes/member/comments.js.map +1 -0
- package/dist/http/routes/member/community.d.ts +7 -0
- package/dist/http/routes/member/community.js +288 -0
- package/dist/http/routes/member/community.js.map +1 -0
- package/dist/http/routes/member/courses.d.ts +7 -0
- package/dist/http/routes/member/courses.js +101 -0
- package/dist/http/routes/member/courses.js.map +1 -0
- package/dist/http/routes/member/downloads.d.ts +7 -0
- package/dist/http/routes/member/downloads.js +56 -0
- package/dist/http/routes/member/downloads.js.map +1 -0
- package/dist/http/routes/member/files.d.ts +7 -0
- package/dist/http/routes/member/files.js +184 -0
- package/dist/http/routes/member/files.js.map +1 -0
- package/dist/http/routes/member/index.d.ts +7 -0
- package/dist/http/routes/member/index.js +31 -0
- package/dist/http/routes/member/index.js.map +1 -0
- package/dist/http/routes/member/notifications.d.ts +7 -0
- package/dist/http/routes/member/notifications.js +101 -0
- package/dist/http/routes/member/notifications.js.map +1 -0
- package/dist/http/routes/member/org.d.ts +7 -0
- package/dist/http/routes/member/org.js +56 -0
- package/dist/http/routes/member/org.js.map +1 -0
- package/dist/http/routes/member/posts.d.ts +7 -0
- package/dist/http/routes/member/posts.js +612 -0
- package/dist/http/routes/member/posts.js.map +1 -0
- package/dist/http/routes/member/profile.d.ts +7 -0
- package/dist/http/routes/member/profile.js +48 -0
- package/dist/http/routes/member/profile.js.map +1 -0
- package/dist/http/routes/member/progress.d.ts +7 -0
- package/dist/http/routes/member/progress.js +60 -0
- package/dist/http/routes/member/progress.js.map +1 -0
- package/dist/http/routes/organizations.js +49 -24
- package/dist/http/routes/organizations.js.map +1 -1
- package/dist/http/routes/students.js +43 -37
- package/dist/http/routes/students.js.map +1 -1
- package/dist/http/routes/webhooks.d.ts +7 -0
- package/dist/http/routes/webhooks.js +167 -0
- package/dist/http/routes/webhooks.js.map +1 -0
- package/dist/http/routes.js +14 -2
- package/dist/http/routes.js.map +1 -1
- package/dist/http/schemas/access.d.ts +146 -0
- package/dist/http/schemas/access.js +36 -0
- package/dist/http/schemas/access.js.map +1 -0
- package/dist/http/schemas/activities.d.ts +36 -1
- package/dist/http/schemas/activities.js +9 -4
- package/dist/http/schemas/activities.js.map +1 -1
- package/dist/http/schemas/assets.d.ts +76 -73
- package/dist/http/schemas/assets.js +23 -13
- package/dist/http/schemas/assets.js.map +1 -1
- package/dist/http/schemas/automations.d.ts +85 -8
- package/dist/http/schemas/automations.js +13 -2
- package/dist/http/schemas/automations.js.map +1 -1
- package/dist/http/schemas/bundles.d.ts +63 -0
- package/dist/http/schemas/bundles.js +23 -0
- package/dist/http/schemas/bundles.js.map +1 -0
- package/dist/http/schemas/chats.d.ts +386 -0
- package/dist/http/schemas/chats.js +58 -0
- package/dist/http/schemas/chats.js.map +1 -0
- package/dist/http/schemas/community.d.ts +537 -0
- package/dist/http/schemas/community.js +129 -0
- package/dist/http/schemas/community.js.map +1 -0
- package/dist/http/schemas/content.d.ts +22 -13
- package/dist/http/schemas/content.js +11 -9
- package/dist/http/schemas/content.js.map +1 -1
- package/dist/http/schemas/course-analytics.d.ts +29 -0
- package/dist/http/schemas/course-analytics.js +21 -0
- package/dist/http/schemas/course-analytics.js.map +1 -0
- package/dist/http/schemas/dashboard.js.map +1 -1
- package/dist/http/schemas/discussion.d.ts +85 -23
- package/dist/http/schemas/discussion.js +12 -11
- package/dist/http/schemas/discussion.js.map +1 -1
- package/dist/http/schemas/downloads.d.ts +13 -5
- package/dist/http/schemas/downloads.js +14 -11
- package/dist/http/schemas/downloads.js.map +1 -1
- package/dist/http/schemas/entitlements.d.ts +14 -6
- package/dist/http/schemas/entitlements.js +8 -6
- package/dist/http/schemas/entitlements.js.map +1 -1
- package/dist/http/schemas/files.d.ts +45 -0
- package/dist/http/schemas/files.js +25 -0
- package/dist/http/schemas/files.js.map +1 -0
- package/dist/http/schemas/index.d.ts +19 -10
- package/dist/http/schemas/index.js +19 -10
- package/dist/http/schemas/integrations.d.ts +4 -4
- package/dist/http/schemas/integrations.js.map +1 -1
- package/dist/http/schemas/invites.d.ts +4 -0
- package/dist/http/schemas/invites.js +3 -1
- package/dist/http/schemas/invites.js.map +1 -1
- package/dist/http/schemas/{learn.d.ts → member.d.ts} +42 -19
- package/dist/http/schemas/{learn.js → member.js} +17 -13
- package/dist/http/schemas/member.js.map +1 -0
- package/dist/http/schemas/members.d.ts +39 -6
- package/dist/http/schemas/members.js +17 -3
- package/dist/http/schemas/members.js.map +1 -1
- package/dist/http/schemas/notifications.d.ts +227 -0
- package/dist/http/schemas/notifications.js +44 -0
- package/dist/http/schemas/notifications.js.map +1 -0
- package/dist/http/schemas/organizations.js.map +1 -1
- package/dist/http/schemas/posts.d.ts +316 -0
- package/dist/http/schemas/posts.js +47 -0
- package/dist/http/schemas/posts.js.map +1 -0
- package/dist/http/schemas/profile.d.ts +23 -0
- package/dist/http/schemas/profile.js +15 -0
- package/dist/http/schemas/profile.js.map +1 -0
- package/dist/http/schemas/settings.js.map +1 -1
- package/dist/http/schemas/shared.d.ts +26 -1
- package/dist/http/schemas/shared.js +22 -3
- package/dist/http/schemas/shared.js.map +1 -1
- package/dist/http/schemas/students.d.ts +32 -10
- package/dist/http/schemas/students.js +19 -6
- package/dist/http/schemas/students.js.map +1 -1
- package/dist/http/scope.d.ts +2 -1
- package/dist/http/scope.js +20 -4
- package/dist/http/scope.js.map +1 -1
- package/dist/http/server.js +10 -3
- package/dist/http/server.js.map +1 -1
- package/dist/http/web-bridge.d.ts +1 -1
- package/dist/http/web-bridge.js +2 -2
- package/dist/http/web-bridge.js.map +1 -1
- package/dist/http/well-known.d.ts +7 -0
- package/dist/http/well-known.js +22 -0
- package/dist/http/well-known.js.map +1 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/node_modules/.pnpm/@jridgewell_sourcemap-codec@1.5.5/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.js +78 -0
- package/dist/node_modules/.pnpm/@jridgewell_sourcemap-codec@1.5.5/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.js.map +1 -0
- package/dist/node_modules/.pnpm/@vitest_expect@2.1.9/node_modules/@vitest/expect/dist/index.js +1267 -0
- package/dist/node_modules/.pnpm/@vitest_expect@2.1.9/node_modules/@vitest/expect/dist/index.js.map +1 -0
- package/dist/node_modules/.pnpm/@vitest_pretty-format@2.1.9/node_modules/@vitest/pretty-format/dist/index.js +814 -0
- package/dist/node_modules/.pnpm/@vitest_pretty-format@2.1.9/node_modules/@vitest/pretty-format/dist/index.js.map +1 -0
- package/dist/node_modules/.pnpm/@vitest_runner@2.1.9/node_modules/@vitest/runner/dist/chunk-tasks.js +43 -0
- package/dist/node_modules/.pnpm/@vitest_runner@2.1.9/node_modules/@vitest/runner/dist/chunk-tasks.js.map +1 -0
- package/dist/node_modules/.pnpm/@vitest_runner@2.1.9/node_modules/@vitest/runner/dist/index.js +527 -0
- package/dist/node_modules/.pnpm/@vitest_runner@2.1.9/node_modules/@vitest/runner/dist/index.js.map +1 -0
- package/dist/node_modules/.pnpm/@vitest_runner@2.1.9/node_modules/@vitest/runner/dist/utils.js +2 -0
- package/dist/node_modules/.pnpm/@vitest_snapshot@2.1.9/node_modules/@vitest/snapshot/dist/index.js +1737 -0
- package/dist/node_modules/.pnpm/@vitest_snapshot@2.1.9/node_modules/@vitest/snapshot/dist/index.js.map +1 -0
- package/dist/node_modules/.pnpm/@vitest_spy@2.1.9/node_modules/@vitest/spy/dist/index.js +137 -0
- package/dist/node_modules/.pnpm/@vitest_spy@2.1.9/node_modules/@vitest/spy/dist/index.js.map +1 -0
- package/dist/node_modules/.pnpm/@vitest_utils@2.1.9/node_modules/@vitest/utils/dist/chunk-_commonjsHelpers.js +118 -0
- package/dist/node_modules/.pnpm/@vitest_utils@2.1.9/node_modules/@vitest/utils/dist/chunk-_commonjsHelpers.js.map +1 -0
- package/dist/node_modules/.pnpm/@vitest_utils@2.1.9/node_modules/@vitest/utils/dist/diff.js +1222 -0
- package/dist/node_modules/.pnpm/@vitest_utils@2.1.9/node_modules/@vitest/utils/dist/diff.js.map +1 -0
- package/dist/node_modules/.pnpm/@vitest_utils@2.1.9/node_modules/@vitest/utils/dist/error.js +91 -0
- package/dist/node_modules/.pnpm/@vitest_utils@2.1.9/node_modules/@vitest/utils/dist/error.js.map +1 -0
- package/dist/node_modules/.pnpm/@vitest_utils@2.1.9/node_modules/@vitest/utils/dist/helpers.js +113 -0
- package/dist/node_modules/.pnpm/@vitest_utils@2.1.9/node_modules/@vitest/utils/dist/helpers.js.map +1 -0
- package/dist/node_modules/.pnpm/@vitest_utils@2.1.9/node_modules/@vitest/utils/dist/index.js +449 -0
- package/dist/node_modules/.pnpm/@vitest_utils@2.1.9/node_modules/@vitest/utils/dist/index.js.map +1 -0
- package/dist/node_modules/.pnpm/@vitest_utils@2.1.9/node_modules/@vitest/utils/dist/source-map.js +163 -0
- package/dist/node_modules/.pnpm/@vitest_utils@2.1.9/node_modules/@vitest/utils/dist/source-map.js.map +1 -0
- package/dist/node_modules/.pnpm/chai@5.3.3/node_modules/chai/index.js +3187 -0
- package/dist/node_modules/.pnpm/chai@5.3.3/node_modules/chai/index.js.map +1 -0
- package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/arguments.js +11 -0
- package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/arguments.js.map +1 -0
- package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/array.js +16 -0
- package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/array.js.map +1 -0
- package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/bigint.js +11 -0
- package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/bigint.js.map +1 -0
- package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/class.js +15 -0
- package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/class.js.map +1 -0
- package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/date.js +13 -0
- package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/date.js.map +1 -0
- package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/error.js +34 -0
- package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/error.js.map +1 -0
- package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/function.js +12 -0
- package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/function.js.map +1 -0
- package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/helpers.js +122 -0
- package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/helpers.js.map +1 -0
- package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/html.js +39 -0
- package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/html.js.map +1 -0
- package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/index.js +99 -0
- package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/index.js.map +1 -0
- package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/map.js +25 -0
- package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/map.js.map +1 -0
- package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/number.js +14 -0
- package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/number.js.map +1 -0
- package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/object.js +21 -0
- package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/object.js.map +1 -0
- package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/promise.js +6 -0
- package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/promise.js.map +1 -0
- package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/regexp.js +12 -0
- package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/regexp.js.map +1 -0
- package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/set.js +18 -0
- package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/set.js.map +1 -0
- package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/string.js +24 -0
- package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/string.js.map +1 -0
- package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/symbol.js +9 -0
- package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/symbol.js.map +1 -0
- package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/typedarray.js +30 -0
- package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/typedarray.js.map +1 -0
- package/dist/node_modules/.pnpm/magic-string@0.30.21/node_modules/magic-string/dist/magic-string.es.js +939 -0
- package/dist/node_modules/.pnpm/magic-string@0.30.21/node_modules/magic-string/dist/magic-string.es.js.map +1 -0
- package/dist/node_modules/.pnpm/pathe@1.1.2/node_modules/pathe/dist/shared/pathe.ff20891b.js +82 -0
- package/dist/node_modules/.pnpm/pathe@1.1.2/node_modules/pathe/dist/shared/pathe.ff20891b.js.map +1 -0
- package/dist/node_modules/.pnpm/tinyrainbow@1.2.0/node_modules/tinyrainbow/dist/chunk-BVHSVHOK.js +82 -0
- package/dist/node_modules/.pnpm/tinyrainbow@1.2.0/node_modules/tinyrainbow/dist/chunk-BVHSVHOK.js.map +1 -0
- package/dist/node_modules/.pnpm/tinyrainbow@1.2.0/node_modules/tinyrainbow/dist/node.js +8 -0
- package/dist/node_modules/.pnpm/tinyrainbow@1.2.0/node_modules/tinyrainbow/dist/node.js.map +1 -0
- package/dist/node_modules/.pnpm/tinyspy@3.0.2/node_modules/tinyspy/dist/index.js +83 -0
- package/dist/node_modules/.pnpm/tinyspy@3.0.2/node_modules/tinyspy/dist/index.js.map +1 -0
- package/dist/node_modules/.pnpm/vitest@2.1.9_@types_node@22.20.0_jsdom@25.0.1_lightningcss@1.32.0/node_modules/vitest/dist/chunks/_commonjsHelpers.BFTU3MAI.js +9 -0
- package/dist/node_modules/.pnpm/vitest@2.1.9_@types_node@22.20.0_jsdom@25.0.1_lightningcss@1.32.0/node_modules/vitest/dist/chunks/_commonjsHelpers.BFTU3MAI.js.map +1 -0
- package/dist/node_modules/.pnpm/vitest@2.1.9_@types_node@22.20.0_jsdom@25.0.1_lightningcss@1.32.0/node_modules/vitest/dist/chunks/date.W2xKR2qe.js +51 -0
- package/dist/node_modules/.pnpm/vitest@2.1.9_@types_node@22.20.0_jsdom@25.0.1_lightningcss@1.32.0/node_modules/vitest/dist/chunks/date.W2xKR2qe.js.map +1 -0
- package/dist/node_modules/.pnpm/vitest@2.1.9_@types_node@22.20.0_jsdom@25.0.1_lightningcss@1.32.0/node_modules/vitest/dist/chunks/utils.C8RiOc4B.js +48 -0
- package/dist/node_modules/.pnpm/vitest@2.1.9_@types_node@22.20.0_jsdom@25.0.1_lightningcss@1.32.0/node_modules/vitest/dist/chunks/utils.C8RiOc4B.js.map +1 -0
- package/dist/node_modules/.pnpm/vitest@2.1.9_@types_node@22.20.0_jsdom@25.0.1_lightningcss@1.32.0/node_modules/vitest/dist/chunks/vi.DgezovHB.js +2426 -0
- package/dist/node_modules/.pnpm/vitest@2.1.9_@types_node@22.20.0_jsdom@25.0.1_lightningcss@1.32.0/node_modules/vitest/dist/chunks/vi.DgezovHB.js.map +1 -0
- package/dist/packages/server/package.js +6 -0
- package/dist/packages/server/package.js.map +1 -0
- package/package.json +9 -7
- package/dist/app/notifications.d.ts +0 -7
- package/dist/app/notifications.js +0 -23
- package/dist/app/notifications.js.map +0 -1
- package/dist/http/routes/learn/assets.d.ts +0 -8
- package/dist/http/routes/learn/assets.js +0 -32
- package/dist/http/routes/learn/assets.js.map +0 -1
- package/dist/http/routes/learn/comments.d.ts +0 -7
- package/dist/http/routes/learn/comments.js +0 -175
- package/dist/http/routes/learn/comments.js.map +0 -1
- package/dist/http/routes/learn/courses.d.ts +0 -7
- package/dist/http/routes/learn/courses.js +0 -75
- package/dist/http/routes/learn/courses.js.map +0 -1
- package/dist/http/routes/learn/downloads.d.ts +0 -7
- package/dist/http/routes/learn/downloads.js +0 -76
- package/dist/http/routes/learn/downloads.js.map +0 -1
- package/dist/http/routes/learn/index.d.ts +0 -7
- package/dist/http/routes/learn/index.js +0 -19
- package/dist/http/routes/learn/index.js.map +0 -1
- package/dist/http/routes/learn/org.d.ts +0 -7
- package/dist/http/routes/learn/org.js +0 -50
- package/dist/http/routes/learn/org.js.map +0 -1
- package/dist/http/routes/learn/progress.d.ts +0 -7
- package/dist/http/routes/learn/progress.js +0 -63
- package/dist/http/routes/learn/progress.js.map +0 -1
- package/dist/http/schemas/learn.js.map +0 -1
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { mcpEndpoints } from "../../app/mcp-endpoints.js";
|
|
2
|
+
import { toToolResult } from "./tool.js";
|
|
3
|
+
import { createToolServer } from "./server.js";
|
|
4
|
+
import { TOOLS } from "./tools/index.js";
|
|
5
|
+
import { a as globalExpect } from "../../node_modules/.pnpm/vitest@2.1.9_@types_node@22.20.0_jsdom@25.0.1_lightningcss@1.32.0/node_modules/vitest/dist/chunks/vi.DgezovHB.js";
|
|
6
|
+
import { ACCESS_SCOPES } from "@headless-lms/core/organizations";
|
|
7
|
+
import { createMcpHandler } from "@modelcontextprotocol/server";
|
|
8
|
+
//#region src/http/mcp/test-support.ts
|
|
9
|
+
const ORG = {
|
|
10
|
+
id: "org_1",
|
|
11
|
+
name: "Acme",
|
|
12
|
+
slug: "acme",
|
|
13
|
+
externalId: "org_1"
|
|
14
|
+
};
|
|
15
|
+
const USER = {
|
|
16
|
+
id: "usr_1",
|
|
17
|
+
email: "owner@acme.test",
|
|
18
|
+
firstName: "Ada",
|
|
19
|
+
lastName: "Lovelace",
|
|
20
|
+
externalId: "usr_1"
|
|
21
|
+
};
|
|
22
|
+
const ORG_USER = {
|
|
23
|
+
id: "ou_1",
|
|
24
|
+
orgId: "org_1",
|
|
25
|
+
userId: "usr_1",
|
|
26
|
+
role: "owner"
|
|
27
|
+
};
|
|
28
|
+
function fakeContainer(overrides = {}) {
|
|
29
|
+
const logger = {
|
|
30
|
+
debug: () => {},
|
|
31
|
+
info: () => {},
|
|
32
|
+
warn: () => {},
|
|
33
|
+
error: () => {},
|
|
34
|
+
child: () => logger
|
|
35
|
+
};
|
|
36
|
+
const base = {
|
|
37
|
+
mcp: mcpEndpoints({
|
|
38
|
+
authBaseURL: "http://localhost:8100",
|
|
39
|
+
adminAppUrl: "http://localhost:8101"
|
|
40
|
+
}),
|
|
41
|
+
logger,
|
|
42
|
+
requestContext: {
|
|
43
|
+
set: () => {},
|
|
44
|
+
run: (_ctx, fn) => fn()
|
|
45
|
+
},
|
|
46
|
+
auth: { verifyAccess: async () => ({
|
|
47
|
+
userId: USER.id,
|
|
48
|
+
orgId: ORG.id,
|
|
49
|
+
scopes: [...ACCESS_SCOPES],
|
|
50
|
+
clientId: "client_1"
|
|
51
|
+
}) },
|
|
52
|
+
organizations: {
|
|
53
|
+
getById: async (id) => id === ORG.id ? ORG : null,
|
|
54
|
+
getByExternalId: async (id) => id === ORG.externalId ? ORG : null,
|
|
55
|
+
getOrgUser: async (orgId, userId) => orgId === ORG.id && userId === USER.id ? ORG_USER : null
|
|
56
|
+
},
|
|
57
|
+
identity: {
|
|
58
|
+
getUserByExternalId: async (id) => id === USER.id ? USER : null,
|
|
59
|
+
getUserById: async (id) => id === USER.id ? USER : null
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
for (const [key, value] of Object.entries(overrides)) {
|
|
63
|
+
const current = base[key];
|
|
64
|
+
base[key] = current && typeof current === "object" && value && typeof value === "object" && !Array.isArray(value) ? {
|
|
65
|
+
...current,
|
|
66
|
+
...value
|
|
67
|
+
} : value;
|
|
68
|
+
}
|
|
69
|
+
return base;
|
|
70
|
+
}
|
|
71
|
+
function toolContext(container, role = "owner") {
|
|
72
|
+
return {
|
|
73
|
+
container,
|
|
74
|
+
scope: {
|
|
75
|
+
orgId: ORG.id,
|
|
76
|
+
userId: USER.id,
|
|
77
|
+
orgUserId: ORG_USER.id,
|
|
78
|
+
role,
|
|
79
|
+
authOrgId: ORG.id
|
|
80
|
+
},
|
|
81
|
+
requestId: "req_test"
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
const MODERN_META = {
|
|
85
|
+
"io.modelcontextprotocol/protocolVersion": "2026-07-28",
|
|
86
|
+
"io.modelcontextprotocol/clientCapabilities": {}
|
|
87
|
+
};
|
|
88
|
+
async function rpc(ctx, tools, method, params, name) {
|
|
89
|
+
const handler = createMcpHandler(() => createToolServer(ctx, tools));
|
|
90
|
+
const headers = {
|
|
91
|
+
"content-type": "application/json",
|
|
92
|
+
"mcp-protocol-version": "2026-07-28",
|
|
93
|
+
"mcp-method": method
|
|
94
|
+
};
|
|
95
|
+
if (name) headers["mcp-name"] = name;
|
|
96
|
+
const body = await (await handler.fetch(new Request("http://localhost:8100/mcp", {
|
|
97
|
+
method: "POST",
|
|
98
|
+
headers,
|
|
99
|
+
body: JSON.stringify({
|
|
100
|
+
jsonrpc: "2.0",
|
|
101
|
+
id: 1,
|
|
102
|
+
method,
|
|
103
|
+
params: {
|
|
104
|
+
...params,
|
|
105
|
+
_meta: MODERN_META
|
|
106
|
+
}
|
|
107
|
+
})
|
|
108
|
+
}))).json();
|
|
109
|
+
if (body.error) throw new Error(body.error.message);
|
|
110
|
+
return body.result;
|
|
111
|
+
}
|
|
112
|
+
async function listTools(ctx, tools = TOOLS) {
|
|
113
|
+
return (await rpc(ctx, tools, "tools/list", {})).tools;
|
|
114
|
+
}
|
|
115
|
+
async function callTool(name, args, ctx, tools = TOOLS) {
|
|
116
|
+
return await rpc(ctx, tools, "tools/call", {
|
|
117
|
+
name,
|
|
118
|
+
arguments: args
|
|
119
|
+
}, name);
|
|
120
|
+
}
|
|
121
|
+
function toolSpecs(tools) {
|
|
122
|
+
return tools.map((tool) => [
|
|
123
|
+
tool.name,
|
|
124
|
+
tool.scope,
|
|
125
|
+
tool.kind,
|
|
126
|
+
tool.idempotent,
|
|
127
|
+
tool.openWorld
|
|
128
|
+
]);
|
|
129
|
+
}
|
|
130
|
+
function serviceFake(path, returns, calls) {
|
|
131
|
+
const keys = path.split(".");
|
|
132
|
+
let node = { [keys.pop() ?? ""]: async (...args) => {
|
|
133
|
+
calls.push(args);
|
|
134
|
+
return returns;
|
|
135
|
+
} };
|
|
136
|
+
for (const key of keys.reverse()) node = { [key]: node };
|
|
137
|
+
return node;
|
|
138
|
+
}
|
|
139
|
+
async function runCase(tools, c) {
|
|
140
|
+
const calls = [];
|
|
141
|
+
const returns = "returns" in c ? c.returns : { id: "result" };
|
|
142
|
+
const ctx = toolContext(fakeContainer(serviceFake(c.service, returns, calls)));
|
|
143
|
+
const result = await callTool(c.tool, c.args, ctx, tools);
|
|
144
|
+
globalExpect(result.isError ?? false).toBe(false);
|
|
145
|
+
globalExpect(calls).toEqual([c.expected]);
|
|
146
|
+
globalExpect(result.structuredContent).toEqual(toToolResult("shown" in c ? c.shown : returns).structuredContent);
|
|
147
|
+
}
|
|
148
|
+
//#endregion
|
|
149
|
+
export { ORG, ORG_USER, USER, callTool, fakeContainer, listTools, runCase, toolContext, toolSpecs };
|
|
150
|
+
|
|
151
|
+
//# sourceMappingURL=test-support.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-support.js","names":[],"sources":["../../../src/http/mcp/test-support.ts"],"sourcesContent":["import { expect } from 'vitest';\nimport { createMcpHandler } from '@modelcontextprotocol/server';\nimport { ACCESS_SCOPES, type AccessScope, type StaffRole } from '@headless-lms/core/organizations';\nimport type { Container } from '../../app/container.js';\nimport { mcpEndpoints } from '../../app/mcp-endpoints.js';\nimport { createToolServer } from './server.js';\nimport { toToolResult, type Tool, type ToolContext, type ToolKind } from './tool.js';\nimport { TOOLS } from './tools/index.js';\n\nexport const ORG = { id: 'org_1', name: 'Acme', slug: 'acme', externalId: 'org_1' };\nexport const USER = {\n id: 'usr_1',\n email: 'owner@acme.test',\n firstName: 'Ada',\n lastName: 'Lovelace',\n externalId: 'usr_1',\n};\nexport const ORG_USER = { id: 'ou_1', orgId: 'org_1', userId: 'usr_1', role: 'owner' };\n\nexport function fakeContainer(overrides: Record<string, unknown> = {}): Container {\n const logger = {\n debug: () => {},\n info: () => {},\n warn: () => {},\n error: () => {},\n child: () => logger,\n };\n const base: Record<string, unknown> = {\n mcp: mcpEndpoints({\n authBaseURL: 'http://localhost:8100',\n adminAppUrl: 'http://localhost:8101',\n }),\n logger,\n requestContext: { set: () => {}, run: (_ctx: unknown, fn: () => void) => fn() },\n auth: {\n verifyAccess: async () => ({\n userId: USER.id,\n orgId: ORG.id,\n scopes: [...ACCESS_SCOPES],\n clientId: 'client_1',\n }),\n },\n organizations: {\n getById: async (id: string) => (id === ORG.id ? ORG : null),\n getByExternalId: async (id: string) => (id === ORG.externalId ? ORG : null),\n getOrgUser: async (orgId: string, userId: string) =>\n orgId === ORG.id && userId === USER.id ? ORG_USER : null,\n },\n identity: {\n getUserByExternalId: async (id: string) => (id === USER.id ? USER : null),\n getUserById: async (id: string) => (id === USER.id ? USER : null),\n },\n };\n for (const [key, value] of Object.entries(overrides)) {\n const current = base[key];\n base[key] =\n current &&\n typeof current === 'object' &&\n value &&\n typeof value === 'object' &&\n !Array.isArray(value)\n ? { ...(current as object), ...(value as object) }\n : value;\n }\n return base as unknown as Container;\n}\n\nexport function toolContext(container: Container, role: StaffRole = 'owner'): ToolContext {\n return {\n container,\n scope: { orgId: ORG.id, userId: USER.id, orgUserId: ORG_USER.id, role, authOrgId: ORG.id },\n requestId: 'req_test',\n };\n}\n\nconst MODERN_META = {\n 'io.modelcontextprotocol/protocolVersion': '2026-07-28',\n 'io.modelcontextprotocol/clientCapabilities': {},\n};\n\nasync function rpc(\n ctx: ToolContext,\n tools: readonly Tool[],\n method: string,\n params: Record<string, unknown>,\n name?: string,\n) {\n const handler = createMcpHandler(() => createToolServer(ctx, tools));\n const headers: Record<string, string> = {\n 'content-type': 'application/json',\n 'mcp-protocol-version': '2026-07-28',\n 'mcp-method': method,\n };\n if (name) {\n headers['mcp-name'] = name;\n }\n const response = await handler.fetch(\n new Request('http://localhost:8100/mcp', {\n method: 'POST',\n headers,\n body: JSON.stringify({\n jsonrpc: '2.0',\n id: 1,\n method,\n params: { ...params, _meta: MODERN_META },\n }),\n }),\n );\n const body = (await response.json()) as {\n result?: Record<string, unknown>;\n error?: { message: string };\n };\n if (body.error) {\n throw new Error(body.error.message);\n }\n return body.result as Record<string, unknown>;\n}\n\nexport async function listTools(ctx: ToolContext, tools: readonly Tool[] = TOOLS) {\n const result = await rpc(ctx, tools, 'tools/list', {});\n return result.tools as Array<{\n name: string;\n annotations?: Record<string, unknown>;\n inputSchema: { type?: string; properties?: Record<string, unknown> };\n }>;\n}\n\nexport async function callTool(\n name: string,\n args: unknown,\n ctx: ToolContext,\n tools: readonly Tool[] = TOOLS,\n) {\n return (await rpc(ctx, tools, 'tools/call', { name, arguments: args }, name)) as {\n isError?: boolean;\n structuredContent?: Record<string, unknown>;\n content: Array<{ type: string; text?: string }>;\n };\n}\n\nexport type ToolSpec = [\n name: string,\n scope: AccessScope,\n kind: ToolKind,\n idempotent: boolean,\n openWorld: boolean,\n];\n\nexport function toolSpecs(tools: readonly Tool[]): ToolSpec[] {\n return tools.map((tool) => [tool.name, tool.scope, tool.kind, tool.idempotent, tool.openWorld]);\n}\n\nexport type ToolCase = {\n tool: string;\n args: Record<string, unknown>;\n service: string;\n expected: unknown[];\n returns?: unknown;\n shown?: unknown;\n};\n\nfunction serviceFake(path: string, returns: unknown, calls: unknown[][]): Record<string, unknown> {\n const keys = path.split('.');\n const method = keys.pop() ?? '';\n let node: Record<string, unknown> = {\n [method]: async (...args: unknown[]) => {\n calls.push(args);\n return returns;\n },\n };\n for (const key of keys.reverse()) {\n node = { [key]: node };\n }\n return node;\n}\n\nexport async function runCase(tools: readonly Tool[], c: ToolCase): Promise<void> {\n const calls: unknown[][] = [];\n const returns = 'returns' in c ? c.returns : { id: 'result' };\n const ctx = toolContext(fakeContainer(serviceFake(c.service, returns, calls)));\n const result = await callTool(c.tool, c.args, ctx, tools);\n expect(result.isError ?? false).toBe(false);\n expect(calls).toEqual([c.expected]);\n expect(result.structuredContent).toEqual(\n toToolResult('shown' in c ? c.shown : returns).structuredContent,\n );\n}\n"],"mappings":";;;;;;;;AASA,MAAa,MAAM;CAAE,IAAI;CAAS,MAAM;CAAQ,MAAM;CAAQ,YAAY;AAAQ;AAClF,MAAa,OAAO;CAClB,IAAI;CACJ,OAAO;CACP,WAAW;CACX,UAAU;CACV,YAAY;AACd;AACA,MAAa,WAAW;CAAE,IAAI;CAAQ,OAAO;CAAS,QAAQ;CAAS,MAAM;AAAQ;AAErF,SAAgB,cAAc,YAAqC,CAAC,GAAc;CAChF,MAAM,SAAS;EACb,aAAa,CAAC;EACd,YAAY,CAAC;EACb,YAAY,CAAC;EACb,aAAa,CAAC;EACd,aAAa;CACf;CACA,MAAM,OAAgC;EACpC,KAAK,aAAa;GAChB,aAAa;GACb,aAAa;EACf,CAAC;EACD;EACA,gBAAgB;GAAE,WAAW,CAAC;GAAG,MAAM,MAAe,OAAmB,GAAG;EAAE;EAC9E,MAAM,EACJ,cAAc,aAAa;GACzB,QAAQ,KAAK;GACb,OAAO,IAAI;GACX,QAAQ,CAAC,GAAG,aAAa;GACzB,UAAU;EACZ,GACF;EACA,eAAe;GACb,SAAS,OAAO,OAAgB,OAAO,IAAI,KAAK,MAAM;GACtD,iBAAiB,OAAO,OAAgB,OAAO,IAAI,aAAa,MAAM;GACtE,YAAY,OAAO,OAAe,WAChC,UAAU,IAAI,MAAM,WAAW,KAAK,KAAK,WAAW;EACxD;EACA,UAAU;GACR,qBAAqB,OAAO,OAAgB,OAAO,KAAK,KAAK,OAAO;GACpE,aAAa,OAAO,OAAgB,OAAO,KAAK,KAAK,OAAO;EAC9D;CACF;CACA,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,SAAS,GAAG;EACpD,MAAM,UAAU,KAAK;EACrB,KAAK,OACH,WACA,OAAO,YAAY,YACnB,SACA,OAAO,UAAU,YACjB,CAAC,MAAM,QAAQ,KAAK,IAChB;GAAE,GAAI;GAAoB,GAAI;EAAiB,IAC/C;CACR;CACA,OAAO;AACT;AAEA,SAAgB,YAAY,WAAsB,OAAkB,SAAsB;CACxF,OAAO;EACL;EACA,OAAO;GAAE,OAAO,IAAI;GAAI,QAAQ,KAAK;GAAI,WAAW,SAAS;GAAI;GAAM,WAAW,IAAI;EAAG;EACzF,WAAW;CACb;AACF;AAEA,MAAM,cAAc;CAClB,2CAA2C;CAC3C,8CAA8C,CAAC;AACjD;AAEA,eAAe,IACb,KACA,OACA,QACA,QACA,MACA;CACA,MAAM,UAAU,uBAAuB,iBAAiB,KAAK,KAAK,CAAC;CACnE,MAAM,UAAkC;EACtC,gBAAgB;EAChB,wBAAwB;EACxB,cAAc;CAChB;CACA,IAAI,MACF,QAAQ,cAAc;CAcxB,MAAM,OAAQ,OAAM,MAZG,QAAQ,MAC7B,IAAI,QAAQ,6BAA6B;EACvC,QAAQ;EACR;EACA,MAAM,KAAK,UAAU;GACnB,SAAS;GACT,IAAI;GACJ;GACA,QAAQ;IAAE,GAAG;IAAQ,OAAO;GAAY;EAC1C,CAAC;CACH,CAAC,CACH,EAAA,CAC6B,KAAK;CAIlC,IAAI,KAAK,OACP,MAAM,IAAI,MAAM,KAAK,MAAM,OAAO;CAEpC,OAAO,KAAK;AACd;AAEA,eAAsB,UAAU,KAAkB,QAAyB,OAAO;CAEhF,QAAO,MADc,IAAI,KAAK,OAAO,cAAc,CAAC,CAAC,EAAA,CACvC;AAKhB;AAEA,eAAsB,SACpB,MACA,MACA,KACA,QAAyB,OACzB;CACA,OAAQ,MAAM,IAAI,KAAK,OAAO,cAAc;EAAE;EAAM,WAAW;CAAK,GAAG,IAAI;AAK7E;AAUA,SAAgB,UAAU,OAAoC;CAC5D,OAAO,MAAM,KAAK,SAAS;EAAC,KAAK;EAAM,KAAK;EAAO,KAAK;EAAM,KAAK;EAAY,KAAK;CAAS,CAAC;AAChG;AAWA,SAAS,YAAY,MAAc,SAAkB,OAA6C;CAChG,MAAM,OAAO,KAAK,MAAM,GAAG;CAE3B,IAAI,OAAgC,GADrB,KAAK,IAAI,KAAK,KAEjB,OAAO,GAAG,SAAoB;EACtC,MAAM,KAAK,IAAI;EACf,OAAO;CACT,EACF;CACA,KAAK,MAAM,OAAO,KAAK,QAAQ,GAC7B,OAAO,GAAG,MAAM,KAAK;CAEvB,OAAO;AACT;AAEA,eAAsB,QAAQ,OAAwB,GAA4B;CAChF,MAAM,QAAqB,CAAC;CAC5B,MAAM,UAAU,aAAa,IAAI,EAAE,UAAU,EAAE,IAAI,SAAS;CAC5D,MAAM,MAAM,YAAY,cAAc,YAAY,EAAE,SAAS,SAAS,KAAK,CAAC,CAAC;CAC7E,MAAM,SAAS,MAAM,SAAS,EAAE,MAAM,EAAE,MAAM,KAAK,KAAK;CACxD,aAAO,OAAO,WAAW,KAAK,CAAC,CAAC,KAAK,KAAK;CAC1C,aAAO,KAAK,CAAC,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC;CAClC,aAAO,OAAO,iBAAiB,CAAC,CAAC,QAC/B,aAAa,WAAW,IAAI,EAAE,QAAQ,OAAO,CAAC,CAAC,iBACjD;AACF"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Container } from "../../app/container.js";
|
|
2
|
+
import { OrgScope } from "../scope.js";
|
|
3
|
+
import { AccessScope } from "@headless-lms/core/organizations";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
//#region src/http/mcp/tool.d.ts
|
|
6
|
+
interface ToolContext {
|
|
7
|
+
container: Container;
|
|
8
|
+
scope: OrgScope;
|
|
9
|
+
requestId: string;
|
|
10
|
+
}
|
|
11
|
+
type ToolKind = 'read' | 'write' | 'destructive';
|
|
12
|
+
interface Tool {
|
|
13
|
+
name: string;
|
|
14
|
+
title: string;
|
|
15
|
+
description: string;
|
|
16
|
+
scope: AccessScope;
|
|
17
|
+
kind: ToolKind;
|
|
18
|
+
idempotent: boolean;
|
|
19
|
+
openWorld: boolean;
|
|
20
|
+
input: z.ZodObject;
|
|
21
|
+
output?: z.ZodType;
|
|
22
|
+
call(input: unknown, ctx: ToolContext): unknown;
|
|
23
|
+
}
|
|
24
|
+
interface ToolDef<Input extends z.ZodObject> extends Omit<Tool, 'input' | 'call'> {
|
|
25
|
+
input: Input;
|
|
26
|
+
call(input: z.output<Input>, ctx: ToolContext): unknown;
|
|
27
|
+
}
|
|
28
|
+
declare const noInput: z.ZodObject<{}, z.core.$strip>;
|
|
29
|
+
declare const actor: (scope: OrgScope) => {
|
|
30
|
+
id: string;
|
|
31
|
+
role: import("@headless-lms/core/organizations").StaffRole;
|
|
32
|
+
};
|
|
33
|
+
declare function defineTool<Input extends z.ZodObject>(def: ToolDef<Input>): Tool;
|
|
34
|
+
interface ToolResult {
|
|
35
|
+
[key: string]: unknown;
|
|
36
|
+
content: Array<{
|
|
37
|
+
type: 'text';
|
|
38
|
+
text: string;
|
|
39
|
+
}>;
|
|
40
|
+
structuredContent?: Record<string, unknown>;
|
|
41
|
+
isError?: boolean;
|
|
42
|
+
}
|
|
43
|
+
declare function toolError(message: string): ToolResult;
|
|
44
|
+
declare function toToolResult(data: unknown): ToolResult;
|
|
45
|
+
declare function runTool(tool: Tool, args: unknown, ctx: ToolContext): Promise<ToolResult>;
|
|
46
|
+
//#endregion
|
|
47
|
+
export { Tool, ToolContext, ToolDef, ToolKind, ToolResult, actor, defineTool, noInput, runTool, toToolResult, toolError };
|
|
48
|
+
//# sourceMappingURL=tool.d.ts.map
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { classifyError } from "../errors.js";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
//#region src/http/mcp/tool.ts
|
|
4
|
+
const noInput = z.object({});
|
|
5
|
+
const actor = (scope) => ({
|
|
6
|
+
id: scope.orgUserId,
|
|
7
|
+
role: scope.role
|
|
8
|
+
});
|
|
9
|
+
function defineTool(def) {
|
|
10
|
+
return {
|
|
11
|
+
...def,
|
|
12
|
+
call: (input, ctx) => def.call(input, ctx)
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
function toolError(message) {
|
|
16
|
+
return {
|
|
17
|
+
content: [{
|
|
18
|
+
type: "text",
|
|
19
|
+
text: message
|
|
20
|
+
}],
|
|
21
|
+
isError: true
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
function toToolResult(data) {
|
|
25
|
+
const plain = JSON.parse(JSON.stringify(data === void 0 ? { ok: true } : data));
|
|
26
|
+
const structuredContent = plain !== null && typeof plain === "object" && !Array.isArray(plain) ? plain : { result: plain };
|
|
27
|
+
return {
|
|
28
|
+
content: [{
|
|
29
|
+
type: "text",
|
|
30
|
+
text: JSON.stringify(structuredContent)
|
|
31
|
+
}],
|
|
32
|
+
structuredContent
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
function describeFailure(error, tool, ctx) {
|
|
36
|
+
const known = classifyError(error);
|
|
37
|
+
if (known) return known.message;
|
|
38
|
+
ctx.container.logger.error("mcp tool failed", {
|
|
39
|
+
err: error instanceof Error ? error : new Error(String(error)),
|
|
40
|
+
tool: tool.name
|
|
41
|
+
});
|
|
42
|
+
return `Internal error (request ${ctx.requestId})`;
|
|
43
|
+
}
|
|
44
|
+
async function runTool(tool, args, ctx) {
|
|
45
|
+
const input = tool.input.safeParse(args);
|
|
46
|
+
if (!input.success) return toolError(`Invalid input: ${z.prettifyError(input.error)}`);
|
|
47
|
+
try {
|
|
48
|
+
const result = await tool.call(input.data, ctx);
|
|
49
|
+
if (result === null || result === false) return toolError("Not found.");
|
|
50
|
+
return toToolResult(tool.output && result !== void 0 ? tool.output.parse(result) : result);
|
|
51
|
+
} catch (error) {
|
|
52
|
+
return toolError(describeFailure(error, tool, ctx));
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
//#endregion
|
|
56
|
+
export { actor, defineTool, noInput, runTool, toToolResult, toolError };
|
|
57
|
+
|
|
58
|
+
//# sourceMappingURL=tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool.js","names":[],"sources":["../../../src/http/mcp/tool.ts"],"sourcesContent":["import { z } from 'zod';\nimport type { AccessScope } from '@headless-lms/core/organizations';\nimport type { Container } from '../../app/container.js';\nimport { classifyError } from '../errors.js';\nimport type { OrgScope } from '../scope.js';\n\nexport interface ToolContext {\n container: Container;\n scope: OrgScope;\n requestId: string;\n}\n\nexport type ToolKind = 'read' | 'write' | 'destructive';\n\nexport interface Tool {\n name: string;\n title: string;\n description: string;\n scope: AccessScope;\n kind: ToolKind;\n idempotent: boolean;\n openWorld: boolean;\n input: z.ZodObject;\n output?: z.ZodType;\n call(input: unknown, ctx: ToolContext): unknown;\n}\n\nexport interface ToolDef<Input extends z.ZodObject> extends Omit<Tool, 'input' | 'call'> {\n input: Input;\n call(input: z.output<Input>, ctx: ToolContext): unknown;\n}\n\nexport const noInput = z.object({});\n\nexport const actor = (scope: OrgScope) => ({ id: scope.orgUserId, role: scope.role });\n\nexport function defineTool<Input extends z.ZodObject>(def: ToolDef<Input>): Tool {\n return { ...def, call: (input, ctx) => def.call(input as z.output<Input>, ctx) };\n}\n\nexport interface ToolResult {\n [key: string]: unknown;\n content: Array<{ type: 'text'; text: string }>;\n structuredContent?: Record<string, unknown>;\n isError?: boolean;\n}\n\nexport function toolError(message: string): ToolResult {\n return { content: [{ type: 'text', text: message }], isError: true };\n}\n\nexport function toToolResult(data: unknown): ToolResult {\n const plain: unknown = JSON.parse(JSON.stringify(data === undefined ? { ok: true } : data));\n const structuredContent =\n plain !== null && typeof plain === 'object' && !Array.isArray(plain)\n ? (plain as Record<string, unknown>)\n : { result: plain };\n return {\n content: [{ type: 'text', text: JSON.stringify(structuredContent) }],\n structuredContent,\n };\n}\n\nfunction describeFailure(error: unknown, tool: Tool, ctx: ToolContext): string {\n const known = classifyError(error);\n if (known) {\n return known.message;\n }\n ctx.container.logger.error('mcp tool failed', {\n err: error instanceof Error ? error : new Error(String(error)),\n tool: tool.name,\n });\n return `Internal error (request ${ctx.requestId})`;\n}\n\nexport async function runTool(tool: Tool, args: unknown, ctx: ToolContext): Promise<ToolResult> {\n const input = tool.input.safeParse(args);\n if (!input.success) {\n return toolError(`Invalid input: ${z.prettifyError(input.error)}`);\n }\n try {\n const result = await tool.call(input.data, ctx);\n if (result === null || result === false) {\n return toolError('Not found.');\n }\n return toToolResult(tool.output && result !== undefined ? tool.output.parse(result) : result);\n } catch (error) {\n return toolError(describeFailure(error, tool, ctx));\n }\n}\n"],"mappings":";;;AAgCA,MAAa,UAAU,EAAE,OAAO,CAAC,CAAC;AAElC,MAAa,SAAS,WAAqB;CAAE,IAAI,MAAM;CAAW,MAAM,MAAM;AAAK;AAEnF,SAAgB,WAAsC,KAA2B;CAC/E,OAAO;EAAE,GAAG;EAAK,OAAO,OAAO,QAAQ,IAAI,KAAK,OAA0B,GAAG;CAAE;AACjF;AASA,SAAgB,UAAU,SAA6B;CACrD,OAAO;EAAE,SAAS,CAAC;GAAE,MAAM;GAAQ,MAAM;EAAQ,CAAC;EAAG,SAAS;CAAK;AACrE;AAEA,SAAgB,aAAa,MAA2B;CACtD,MAAM,QAAiB,KAAK,MAAM,KAAK,UAAU,SAAS,KAAA,IAAY,EAAE,IAAI,KAAK,IAAI,IAAI,CAAC;CAC1F,MAAM,oBACJ,UAAU,QAAQ,OAAO,UAAU,YAAY,CAAC,MAAM,QAAQ,KAAK,IAC9D,QACD,EAAE,QAAQ,MAAM;CACtB,OAAO;EACL,SAAS,CAAC;GAAE,MAAM;GAAQ,MAAM,KAAK,UAAU,iBAAiB;EAAE,CAAC;EACnE;CACF;AACF;AAEA,SAAS,gBAAgB,OAAgB,MAAY,KAA0B;CAC7E,MAAM,QAAQ,cAAc,KAAK;CACjC,IAAI,OACF,OAAO,MAAM;CAEf,IAAI,UAAU,OAAO,MAAM,mBAAmB;EAC5C,KAAK,iBAAiB,QAAQ,QAAQ,IAAI,MAAM,OAAO,KAAK,CAAC;EAC7D,MAAM,KAAK;CACb,CAAC;CACD,OAAO,2BAA2B,IAAI,UAAU;AAClD;AAEA,eAAsB,QAAQ,MAAY,MAAe,KAAuC;CAC9F,MAAM,QAAQ,KAAK,MAAM,UAAU,IAAI;CACvC,IAAI,CAAC,MAAM,SACT,OAAO,UAAU,kBAAkB,EAAE,cAAc,MAAM,KAAK,GAAG;CAEnE,IAAI;EACF,MAAM,SAAS,MAAM,KAAK,KAAK,MAAM,MAAM,GAAG;EAC9C,IAAI,WAAW,QAAQ,WAAW,OAChC,OAAO,UAAU,YAAY;EAE/B,OAAO,aAAa,KAAK,UAAU,WAAW,KAAA,IAAY,KAAK,OAAO,MAAM,MAAM,IAAI,MAAM;CAC9F,SAAS,OAAO;EACd,OAAO,UAAU,gBAAgB,OAAO,MAAM,GAAG,CAAC;CACpD;AACF"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { AutomationIdParam, AutomationRunParams, AutomationRunsQuery, AutomationsQuery, CreateAutomationBody, UpdateAutomationBody, UpdateWebhookBody } from "../../schemas/automations.js";
|
|
2
|
+
import "../../schemas/index.js";
|
|
3
|
+
import { defineTool, noInput } from "../tool.js";
|
|
4
|
+
//#region src/http/mcp/tools/automations.ts
|
|
5
|
+
const automationTools = [
|
|
6
|
+
defineTool({
|
|
7
|
+
name: "list_automation_triggers",
|
|
8
|
+
title: "List workflow triggers",
|
|
9
|
+
description: "The events that can start a workflow.",
|
|
10
|
+
scope: "automations:read",
|
|
11
|
+
kind: "read",
|
|
12
|
+
idempotent: true,
|
|
13
|
+
openWorld: false,
|
|
14
|
+
input: noInput,
|
|
15
|
+
call: (_input, { container }) => container.automations.availableTriggers()
|
|
16
|
+
}),
|
|
17
|
+
defineTool({
|
|
18
|
+
name: "list_automation_actions",
|
|
19
|
+
title: "List workflow actions",
|
|
20
|
+
description: "The actions a workflow can run, with the settings each one takes.",
|
|
21
|
+
scope: "automations:read",
|
|
22
|
+
kind: "read",
|
|
23
|
+
idempotent: true,
|
|
24
|
+
openWorld: false,
|
|
25
|
+
input: noInput,
|
|
26
|
+
call: (_input, { container }) => container.automations.availableActions()
|
|
27
|
+
}),
|
|
28
|
+
defineTool({
|
|
29
|
+
name: "list_automations",
|
|
30
|
+
title: "List workflows and webhooks",
|
|
31
|
+
description: "Workflows and webhooks with their triggers, ordered actions and enabled state. Filter by kind (workflow or webhook).",
|
|
32
|
+
scope: "automations:read",
|
|
33
|
+
kind: "read",
|
|
34
|
+
idempotent: true,
|
|
35
|
+
openWorld: false,
|
|
36
|
+
input: AutomationsQuery,
|
|
37
|
+
call: (input, { container, scope }) => container.automations.list(scope.orgId, input)
|
|
38
|
+
}),
|
|
39
|
+
defineTool({
|
|
40
|
+
name: "list_automation_runs",
|
|
41
|
+
title: "List workflow and webhook runs",
|
|
42
|
+
description: "Runs of one workflow or webhook, newest first, with the trigger event as a webhook would receive it and each action result.",
|
|
43
|
+
scope: "automations:read",
|
|
44
|
+
kind: "read",
|
|
45
|
+
idempotent: true,
|
|
46
|
+
openWorld: false,
|
|
47
|
+
input: AutomationRunsQuery.extend(AutomationIdParam.shape),
|
|
48
|
+
call: ({ id, ...query }, { container, scope }) => container.automations.listRuns(scope.orgId, id, query)
|
|
49
|
+
}),
|
|
50
|
+
defineTool({
|
|
51
|
+
name: "create_automation",
|
|
52
|
+
title: "Create workflow",
|
|
53
|
+
description: "Create a workflow from triggers and ordered actions. Use list_automation_triggers and list_automation_actions for valid values.",
|
|
54
|
+
scope: "automations:write",
|
|
55
|
+
kind: "write",
|
|
56
|
+
idempotent: false,
|
|
57
|
+
openWorld: false,
|
|
58
|
+
input: CreateAutomationBody,
|
|
59
|
+
call: (input, { container, scope }) => container.automations.create(scope.orgId, input)
|
|
60
|
+
}),
|
|
61
|
+
defineTool({
|
|
62
|
+
name: "update_automation",
|
|
63
|
+
title: "Update workflow",
|
|
64
|
+
description: "Change a workflow name, description, triggers or actions, or turn it on and off with enabled. Fields left out stay as they are.",
|
|
65
|
+
scope: "automations:write",
|
|
66
|
+
kind: "write",
|
|
67
|
+
idempotent: true,
|
|
68
|
+
openWorld: false,
|
|
69
|
+
input: UpdateAutomationBody.extend(AutomationIdParam.shape),
|
|
70
|
+
call: ({ id, ...patch }, { container, scope }) => container.automations.update(scope.orgId, id, patch)
|
|
71
|
+
}),
|
|
72
|
+
defineTool({
|
|
73
|
+
name: "rerun_automation_run",
|
|
74
|
+
title: "Re-run workflow or webhook run",
|
|
75
|
+
description: "Run a finished workflow or webhook run again with its original trigger event, using the automation's current actions. Emails and webhook deliveries are sent again. The new outcome replaces the run's previous one. A run still in progress can't be re-run.",
|
|
76
|
+
scope: "automations:write",
|
|
77
|
+
kind: "write",
|
|
78
|
+
idempotent: false,
|
|
79
|
+
openWorld: true,
|
|
80
|
+
input: AutomationRunParams,
|
|
81
|
+
call: ({ id, runId }, { container, scope }) => container.automations.rerun(scope.orgId, id, runId)
|
|
82
|
+
}),
|
|
83
|
+
defineTool({
|
|
84
|
+
name: "delete_automation",
|
|
85
|
+
title: "Delete workflow",
|
|
86
|
+
description: "Permanently delete a workflow.",
|
|
87
|
+
scope: "automations:delete",
|
|
88
|
+
kind: "destructive",
|
|
89
|
+
idempotent: true,
|
|
90
|
+
openWorld: false,
|
|
91
|
+
input: AutomationIdParam,
|
|
92
|
+
call: ({ id }, { container, scope }) => container.automations.delete(scope.orgId, id)
|
|
93
|
+
}),
|
|
94
|
+
defineTool({
|
|
95
|
+
name: "update_webhook",
|
|
96
|
+
title: "Update webhook",
|
|
97
|
+
description: "Change a webhook URL, events or description, or turn it on and off with enabled. Fields left out stay as they are.",
|
|
98
|
+
scope: "automations:write",
|
|
99
|
+
kind: "write",
|
|
100
|
+
idempotent: true,
|
|
101
|
+
openWorld: false,
|
|
102
|
+
input: UpdateWebhookBody.extend(AutomationIdParam.shape),
|
|
103
|
+
call: ({ id, ...patch }, { container, scope }) => container.automations.updateWebhook(scope.orgId, id, patch)
|
|
104
|
+
}),
|
|
105
|
+
defineTool({
|
|
106
|
+
name: "delete_webhook",
|
|
107
|
+
title: "Delete webhook",
|
|
108
|
+
description: "Permanently delete a webhook and its signing secret. Its delivery history is kept.",
|
|
109
|
+
scope: "automations:delete",
|
|
110
|
+
kind: "destructive",
|
|
111
|
+
idempotent: true,
|
|
112
|
+
openWorld: false,
|
|
113
|
+
input: AutomationIdParam,
|
|
114
|
+
call: ({ id }, { container, scope }) => container.automations.deleteWebhook(scope.orgId, id)
|
|
115
|
+
})
|
|
116
|
+
];
|
|
117
|
+
//#endregion
|
|
118
|
+
export { automationTools };
|
|
119
|
+
|
|
120
|
+
//# sourceMappingURL=automations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"automations.js","names":[],"sources":["../../../../src/http/mcp/tools/automations.ts"],"sourcesContent":["import {\n AutomationIdParam,\n AutomationRunParams,\n AutomationRunsQuery,\n AutomationsQuery,\n CreateAutomationBody,\n UpdateAutomationBody,\n UpdateWebhookBody,\n} from '../../schemas/index.js';\nimport { defineTool, noInput, type Tool } from '../tool.js';\n\nexport const automationTools: Tool[] = [\n defineTool({\n name: 'list_automation_triggers',\n title: 'List workflow triggers',\n description: 'The events that can start a workflow.',\n scope: 'automations:read',\n kind: 'read',\n idempotent: true,\n openWorld: false,\n input: noInput,\n call: (_input, { container }) => container.automations.availableTriggers(),\n }),\n defineTool({\n name: 'list_automation_actions',\n title: 'List workflow actions',\n description: 'The actions a workflow can run, with the settings each one takes.',\n scope: 'automations:read',\n kind: 'read',\n idempotent: true,\n openWorld: false,\n input: noInput,\n call: (_input, { container }) => container.automations.availableActions(),\n }),\n defineTool({\n name: 'list_automations',\n title: 'List workflows and webhooks',\n description:\n 'Workflows and webhooks with their triggers, ordered actions and enabled state. Filter by kind (workflow or webhook).',\n scope: 'automations:read',\n kind: 'read',\n idempotent: true,\n openWorld: false,\n input: AutomationsQuery,\n call: (input, { container, scope }) => container.automations.list(scope.orgId, input),\n }),\n defineTool({\n name: 'list_automation_runs',\n title: 'List workflow and webhook runs',\n description:\n 'Runs of one workflow or webhook, newest first, with the trigger event as a webhook would receive it and each action result.',\n scope: 'automations:read',\n kind: 'read',\n idempotent: true,\n openWorld: false,\n input: AutomationRunsQuery.extend(AutomationIdParam.shape),\n call: ({ id, ...query }, { container, scope }) =>\n container.automations.listRuns(scope.orgId, id, query),\n }),\n defineTool({\n name: 'create_automation',\n title: 'Create workflow',\n description:\n 'Create a workflow from triggers and ordered actions. Use list_automation_triggers and list_automation_actions for valid values.',\n scope: 'automations:write',\n kind: 'write',\n idempotent: false,\n openWorld: false,\n input: CreateAutomationBody,\n call: (input, { container, scope }) => container.automations.create(scope.orgId, input),\n }),\n defineTool({\n name: 'update_automation',\n title: 'Update workflow',\n description:\n 'Change a workflow name, description, triggers or actions, or turn it on and off with enabled. Fields left out stay as they are.',\n scope: 'automations:write',\n kind: 'write',\n idempotent: true,\n openWorld: false,\n input: UpdateAutomationBody.extend(AutomationIdParam.shape),\n call: ({ id, ...patch }, { container, scope }) =>\n container.automations.update(scope.orgId, id, patch),\n }),\n defineTool({\n name: 'rerun_automation_run',\n title: 'Re-run workflow or webhook run',\n description:\n \"Run a finished workflow or webhook run again with its original trigger event, using the automation's current actions. Emails and webhook deliveries are sent again. The new outcome replaces the run's previous one. A run still in progress can't be re-run.\",\n scope: 'automations:write',\n kind: 'write',\n idempotent: false,\n openWorld: true,\n input: AutomationRunParams,\n call: ({ id, runId }, { container, scope }) =>\n container.automations.rerun(scope.orgId, id, runId),\n }),\n defineTool({\n name: 'delete_automation',\n title: 'Delete workflow',\n description: 'Permanently delete a workflow.',\n scope: 'automations:delete',\n kind: 'destructive',\n idempotent: true,\n openWorld: false,\n input: AutomationIdParam,\n call: ({ id }, { container, scope }) => container.automations.delete(scope.orgId, id),\n }),\n defineTool({\n name: 'update_webhook',\n title: 'Update webhook',\n description:\n 'Change a webhook URL, events or description, or turn it on and off with enabled. Fields left out stay as they are.',\n scope: 'automations:write',\n kind: 'write',\n idempotent: true,\n openWorld: false,\n input: UpdateWebhookBody.extend(AutomationIdParam.shape),\n call: ({ id, ...patch }, { container, scope }) =>\n container.automations.updateWebhook(scope.orgId, id, patch),\n }),\n defineTool({\n name: 'delete_webhook',\n title: 'Delete webhook',\n description:\n 'Permanently delete a webhook and its signing secret. Its delivery history is kept.',\n scope: 'automations:delete',\n kind: 'destructive',\n idempotent: true,\n openWorld: false,\n input: AutomationIdParam,\n call: ({ id }, { container, scope }) => container.automations.deleteWebhook(scope.orgId, id),\n }),\n];\n"],"mappings":";;;;AAWA,MAAa,kBAA0B;CACrC,WAAW;EACT,MAAM;EACN,OAAO;EACP,aAAa;EACb,OAAO;EACP,MAAM;EACN,YAAY;EACZ,WAAW;EACX,OAAO;EACP,OAAO,QAAQ,EAAE,gBAAgB,UAAU,YAAY,kBAAkB;CAC3E,CAAC;CACD,WAAW;EACT,MAAM;EACN,OAAO;EACP,aAAa;EACb,OAAO;EACP,MAAM;EACN,YAAY;EACZ,WAAW;EACX,OAAO;EACP,OAAO,QAAQ,EAAE,gBAAgB,UAAU,YAAY,iBAAiB;CAC1E,CAAC;CACD,WAAW;EACT,MAAM;EACN,OAAO;EACP,aACE;EACF,OAAO;EACP,MAAM;EACN,YAAY;EACZ,WAAW;EACX,OAAO;EACP,OAAO,OAAO,EAAE,WAAW,YAAY,UAAU,YAAY,KAAK,MAAM,OAAO,KAAK;CACtF,CAAC;CACD,WAAW;EACT,MAAM;EACN,OAAO;EACP,aACE;EACF,OAAO;EACP,MAAM;EACN,YAAY;EACZ,WAAW;EACX,OAAO,oBAAoB,OAAO,kBAAkB,KAAK;EACzD,OAAO,EAAE,IAAI,GAAG,SAAS,EAAE,WAAW,YACpC,UAAU,YAAY,SAAS,MAAM,OAAO,IAAI,KAAK;CACzD,CAAC;CACD,WAAW;EACT,MAAM;EACN,OAAO;EACP,aACE;EACF,OAAO;EACP,MAAM;EACN,YAAY;EACZ,WAAW;EACX,OAAO;EACP,OAAO,OAAO,EAAE,WAAW,YAAY,UAAU,YAAY,OAAO,MAAM,OAAO,KAAK;CACxF,CAAC;CACD,WAAW;EACT,MAAM;EACN,OAAO;EACP,aACE;EACF,OAAO;EACP,MAAM;EACN,YAAY;EACZ,WAAW;EACX,OAAO,qBAAqB,OAAO,kBAAkB,KAAK;EAC1D,OAAO,EAAE,IAAI,GAAG,SAAS,EAAE,WAAW,YACpC,UAAU,YAAY,OAAO,MAAM,OAAO,IAAI,KAAK;CACvD,CAAC;CACD,WAAW;EACT,MAAM;EACN,OAAO;EACP,aACE;EACF,OAAO;EACP,MAAM;EACN,YAAY;EACZ,WAAW;EACX,OAAO;EACP,OAAO,EAAE,IAAI,SAAS,EAAE,WAAW,YACjC,UAAU,YAAY,MAAM,MAAM,OAAO,IAAI,KAAK;CACtD,CAAC;CACD,WAAW;EACT,MAAM;EACN,OAAO;EACP,aAAa;EACb,OAAO;EACP,MAAM;EACN,YAAY;EACZ,WAAW;EACX,OAAO;EACP,OAAO,EAAE,MAAM,EAAE,WAAW,YAAY,UAAU,YAAY,OAAO,MAAM,OAAO,EAAE;CACtF,CAAC;CACD,WAAW;EACT,MAAM;EACN,OAAO;EACP,aACE;EACF,OAAO;EACP,MAAM;EACN,YAAY;EACZ,WAAW;EACX,OAAO,kBAAkB,OAAO,kBAAkB,KAAK;EACvD,OAAO,EAAE,IAAI,GAAG,SAAS,EAAE,WAAW,YACpC,UAAU,YAAY,cAAc,MAAM,OAAO,IAAI,KAAK;CAC9D,CAAC;CACD,WAAW;EACT,MAAM;EACN,OAAO;EACP,aACE;EACF,OAAO;EACP,MAAM;EACN,YAAY;EACZ,WAAW;EACX,OAAO;EACP,OAAO,EAAE,MAAM,EAAE,WAAW,YAAY,UAAU,YAAY,cAAc,MAAM,OAAO,EAAE;CAC7F,CAAC;AACH"}
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import { AddDownloadAsset, CreateDownload, DownloadAssetParams, DownloadIdParam, DownloadsQuery, RenameDownloadAsset, ReorderDownloadAssets, UpdateDownload } from "../../schemas/downloads.js";
|
|
2
|
+
import { AddBundleItem, BundleIdParam, BundleItemParams, BundlesQuery, CreateBundle, UpdateBundle } from "../../schemas/bundles.js";
|
|
3
|
+
import { AssetsPage, AssetsQuery } from "../../schemas/assets.js";
|
|
4
|
+
import "../../schemas/index.js";
|
|
5
|
+
import { actor, defineTool } from "../tool.js";
|
|
6
|
+
//#region src/http/mcp/tools/catalog.ts
|
|
7
|
+
const catalogTools = [
|
|
8
|
+
defineTool({
|
|
9
|
+
name: "list_downloads",
|
|
10
|
+
title: "List downloads",
|
|
11
|
+
description: "Search and page through downloads: file collections a student can be granted. Filter by status or category.",
|
|
12
|
+
scope: "downloads:read",
|
|
13
|
+
kind: "read",
|
|
14
|
+
idempotent: true,
|
|
15
|
+
openWorld: false,
|
|
16
|
+
input: DownloadsQuery,
|
|
17
|
+
call: (input, { container, scope }) => container.content.listDownloads(scope.orgId, input)
|
|
18
|
+
}),
|
|
19
|
+
defineTool({
|
|
20
|
+
name: "list_download_files",
|
|
21
|
+
title: "List download files",
|
|
22
|
+
description: "The files of a download, in order, with their display names.",
|
|
23
|
+
scope: "downloads:read",
|
|
24
|
+
kind: "read",
|
|
25
|
+
idempotent: true,
|
|
26
|
+
openWorld: false,
|
|
27
|
+
input: DownloadIdParam,
|
|
28
|
+
call: ({ downloadId }, { container, scope }) => container.content.listDownloadAssets(scope.orgId, downloadId)
|
|
29
|
+
}),
|
|
30
|
+
defineTool({
|
|
31
|
+
name: "create_download",
|
|
32
|
+
title: "Create download",
|
|
33
|
+
description: "Create a draft download. Add files with add_download_file and publish it with update_download.",
|
|
34
|
+
scope: "downloads:write",
|
|
35
|
+
kind: "write",
|
|
36
|
+
idempotent: false,
|
|
37
|
+
openWorld: false,
|
|
38
|
+
input: CreateDownload,
|
|
39
|
+
call: (input, { container, scope }) => container.content.createDownload(scope.orgId, input)
|
|
40
|
+
}),
|
|
41
|
+
defineTool({
|
|
42
|
+
name: "update_download",
|
|
43
|
+
title: "Update download",
|
|
44
|
+
description: "Change a download title, description, category or cover image, or publish and unpublish it with status. Fields left out stay as they are.",
|
|
45
|
+
scope: "downloads:write",
|
|
46
|
+
kind: "write",
|
|
47
|
+
idempotent: true,
|
|
48
|
+
openWorld: false,
|
|
49
|
+
input: UpdateDownload.extend(DownloadIdParam.shape),
|
|
50
|
+
call: ({ downloadId, ...patch }, { container, scope }) => container.content.updateDownload(scope.orgId, downloadId, patch)
|
|
51
|
+
}),
|
|
52
|
+
defineTool({
|
|
53
|
+
name: "add_download_file",
|
|
54
|
+
title: "Add file to download",
|
|
55
|
+
description: "Add an uploaded file to the end of a download. Find file ids with list_media.",
|
|
56
|
+
scope: "downloads:write",
|
|
57
|
+
kind: "write",
|
|
58
|
+
idempotent: false,
|
|
59
|
+
openWorld: false,
|
|
60
|
+
input: AddDownloadAsset.extend(DownloadIdParam.shape),
|
|
61
|
+
call: ({ downloadId, ...file }, { container, scope }) => container.content.addDownloadAsset(scope.orgId, downloadId, file)
|
|
62
|
+
}),
|
|
63
|
+
defineTool({
|
|
64
|
+
name: "rename_download_file",
|
|
65
|
+
title: "Rename download file",
|
|
66
|
+
description: "Set the name a file shows under in a download. null shows the file name.",
|
|
67
|
+
scope: "downloads:write",
|
|
68
|
+
kind: "write",
|
|
69
|
+
idempotent: true,
|
|
70
|
+
openWorld: false,
|
|
71
|
+
input: RenameDownloadAsset.extend(DownloadAssetParams.shape),
|
|
72
|
+
call: ({ downloadId, assetId, displayName }, { container, scope }) => container.content.renameDownloadAsset(scope.orgId, downloadId, assetId, displayName)
|
|
73
|
+
}),
|
|
74
|
+
defineTool({
|
|
75
|
+
name: "reorder_download_files",
|
|
76
|
+
title: "Reorder download files",
|
|
77
|
+
description: "Set the file order of a download. Pass every file id of the download in the new order.",
|
|
78
|
+
scope: "downloads:write",
|
|
79
|
+
kind: "write",
|
|
80
|
+
idempotent: true,
|
|
81
|
+
openWorld: false,
|
|
82
|
+
input: ReorderDownloadAssets.extend(DownloadIdParam.shape),
|
|
83
|
+
call: ({ downloadId, assetIds }, { container, scope }) => container.content.reorderDownloadAssets(scope.orgId, downloadId, assetIds)
|
|
84
|
+
}),
|
|
85
|
+
defineTool({
|
|
86
|
+
name: "remove_download_file",
|
|
87
|
+
title: "Remove file from download",
|
|
88
|
+
description: "Take a file out of a download. The uploaded file itself is kept.",
|
|
89
|
+
scope: "downloads:write",
|
|
90
|
+
kind: "destructive",
|
|
91
|
+
idempotent: true,
|
|
92
|
+
openWorld: false,
|
|
93
|
+
input: DownloadAssetParams,
|
|
94
|
+
call: ({ downloadId, assetId }, { container, scope }) => container.content.removeDownloadAsset(scope.orgId, downloadId, assetId)
|
|
95
|
+
}),
|
|
96
|
+
defineTool({
|
|
97
|
+
name: "delete_download",
|
|
98
|
+
title: "Delete download",
|
|
99
|
+
description: "Permanently delete a download. The uploaded files are kept.",
|
|
100
|
+
scope: "downloads:delete",
|
|
101
|
+
kind: "destructive",
|
|
102
|
+
idempotent: true,
|
|
103
|
+
openWorld: false,
|
|
104
|
+
input: DownloadIdParam,
|
|
105
|
+
call: ({ downloadId }, { container, scope }) => container.content.removeDownload(scope.orgId, downloadId, actor(scope))
|
|
106
|
+
}),
|
|
107
|
+
defineTool({
|
|
108
|
+
name: "list_bundles",
|
|
109
|
+
title: "List bundles",
|
|
110
|
+
description: "Search and page through bundles: sets of courses, downloads and communities granted together.",
|
|
111
|
+
scope: "bundles:read",
|
|
112
|
+
kind: "read",
|
|
113
|
+
idempotent: true,
|
|
114
|
+
openWorld: false,
|
|
115
|
+
input: BundlesQuery,
|
|
116
|
+
call: (input, { container, scope }) => container.content.listBundles(scope.orgId, input)
|
|
117
|
+
}),
|
|
118
|
+
defineTool({
|
|
119
|
+
name: "list_bundle_items",
|
|
120
|
+
title: "List bundle items",
|
|
121
|
+
description: "The courses, downloads and communities in a bundle.",
|
|
122
|
+
scope: "bundles:read",
|
|
123
|
+
kind: "read",
|
|
124
|
+
idempotent: true,
|
|
125
|
+
openWorld: false,
|
|
126
|
+
input: BundleIdParam,
|
|
127
|
+
call: ({ bundleId }, { container, scope }) => container.content.listBundleItems(scope.orgId, bundleId)
|
|
128
|
+
}),
|
|
129
|
+
defineTool({
|
|
130
|
+
name: "create_bundle",
|
|
131
|
+
title: "Create bundle",
|
|
132
|
+
description: "Create a bundle, optionally with the course, download and community ids it starts with.",
|
|
133
|
+
scope: "bundles:write",
|
|
134
|
+
kind: "write",
|
|
135
|
+
idempotent: false,
|
|
136
|
+
openWorld: false,
|
|
137
|
+
input: CreateBundle,
|
|
138
|
+
call: (input, { container, scope }) => container.content.createBundle(scope.orgId, input)
|
|
139
|
+
}),
|
|
140
|
+
defineTool({
|
|
141
|
+
name: "rename_bundle",
|
|
142
|
+
title: "Rename bundle",
|
|
143
|
+
description: "Rename a bundle.",
|
|
144
|
+
scope: "bundles:write",
|
|
145
|
+
kind: "write",
|
|
146
|
+
idempotent: true,
|
|
147
|
+
openWorld: false,
|
|
148
|
+
input: UpdateBundle.extend(BundleIdParam.shape),
|
|
149
|
+
call: ({ bundleId, ...patch }, { container, scope }) => container.content.updateBundle(scope.orgId, bundleId, patch)
|
|
150
|
+
}),
|
|
151
|
+
defineTool({
|
|
152
|
+
name: "add_bundle_item",
|
|
153
|
+
title: "Add to bundle",
|
|
154
|
+
description: "Add a course, download or community to a bundle. Returns the bundle items.",
|
|
155
|
+
scope: "bundles:write",
|
|
156
|
+
kind: "write",
|
|
157
|
+
idempotent: false,
|
|
158
|
+
openWorld: false,
|
|
159
|
+
input: AddBundleItem.extend(BundleIdParam.shape),
|
|
160
|
+
call: ({ bundleId, contentId }, { container, scope }) => container.content.addBundleItem(scope.orgId, bundleId, contentId)
|
|
161
|
+
}),
|
|
162
|
+
defineTool({
|
|
163
|
+
name: "remove_bundle_item",
|
|
164
|
+
title: "Remove from bundle",
|
|
165
|
+
description: "Take a course, download or community out of a bundle. Returns the remaining items.",
|
|
166
|
+
scope: "bundles:write",
|
|
167
|
+
kind: "destructive",
|
|
168
|
+
idempotent: true,
|
|
169
|
+
openWorld: false,
|
|
170
|
+
input: BundleItemParams,
|
|
171
|
+
call: ({ bundleId, contentId }, { container, scope }) => container.content.removeBundleItem(scope.orgId, bundleId, contentId)
|
|
172
|
+
}),
|
|
173
|
+
defineTool({
|
|
174
|
+
name: "delete_bundle",
|
|
175
|
+
title: "Delete bundle",
|
|
176
|
+
description: "Permanently delete a bundle. Its courses, downloads and communities are kept.",
|
|
177
|
+
scope: "bundles:delete",
|
|
178
|
+
kind: "destructive",
|
|
179
|
+
idempotent: true,
|
|
180
|
+
openWorld: false,
|
|
181
|
+
input: BundleIdParam,
|
|
182
|
+
call: ({ bundleId }, { container, scope }) => container.content.deleteBundle(scope.orgId, bundleId)
|
|
183
|
+
}),
|
|
184
|
+
defineTool({
|
|
185
|
+
name: "list_media",
|
|
186
|
+
title: "List media",
|
|
187
|
+
description: "Search and page through uploaded files, to use in downloads or as cover images of courses, downloads and communities. Uploading is done in the admin app.",
|
|
188
|
+
scope: "media:read",
|
|
189
|
+
kind: "read",
|
|
190
|
+
idempotent: true,
|
|
191
|
+
openWorld: false,
|
|
192
|
+
input: AssetsQuery,
|
|
193
|
+
output: AssetsPage,
|
|
194
|
+
call: (input, { container, scope }) => container.assets.list(scope.orgId, input)
|
|
195
|
+
})
|
|
196
|
+
];
|
|
197
|
+
//#endregion
|
|
198
|
+
export { catalogTools };
|
|
199
|
+
|
|
200
|
+
//# sourceMappingURL=catalog.js.map
|