@agilesyndrome/cf-genai-base 5.0.2 → 6.0.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/CHANGELOG.md +99 -0
- package/CLI.md +9 -13
- package/CONTRACT.md +32 -15
- package/README.md +95 -28
- package/bin/cf-genai.js +24 -8
- package/dist/admin/auth.d.ts +12 -0
- package/dist/admin/auth.d.ts.map +1 -0
- package/dist/admin/auth.js +103 -0
- package/dist/admin/auth.js.map +1 -0
- package/dist/admin/index.d.ts +2 -0
- package/dist/admin/index.d.ts.map +1 -0
- package/dist/admin/index.js +2 -0
- package/dist/admin/index.js.map +1 -0
- package/dist/admin/router.d.ts +4 -0
- package/dist/admin/router.d.ts.map +1 -0
- package/dist/admin/router.js +24 -0
- package/dist/admin/router.js.map +1 -0
- package/dist/admin/types.d.ts +43 -0
- package/dist/admin/types.d.ts.map +1 -0
- package/dist/admin/types.js +2 -0
- package/dist/admin/types.js.map +1 -0
- package/dist/api/client.d.ts +34 -0
- package/dist/api/client.d.ts.map +1 -0
- package/dist/api/client.js +59 -0
- package/dist/api/client.js.map +1 -0
- package/dist/api/contracts.d.ts +31 -0
- package/dist/api/contracts.d.ts.map +1 -0
- package/dist/api/contracts.js +101 -0
- package/dist/api/contracts.js.map +1 -0
- package/dist/api/http.d.ts +12 -0
- package/dist/api/http.d.ts.map +1 -0
- package/dist/api/http.js +36 -0
- package/dist/api/http.js.map +1 -0
- package/dist/api/index.d.ts +14 -0
- package/dist/api/index.d.ts.map +1 -0
- package/dist/api/index.js +11 -0
- package/dist/api/index.js.map +1 -0
- package/dist/api/testing.d.ts +10 -0
- package/dist/api/testing.d.ts.map +1 -0
- package/dist/api/testing.js +26 -0
- package/dist/api/testing.js.map +1 -0
- package/dist/app.d.ts +21 -0
- package/dist/app.d.ts.map +1 -0
- package/dist/app.js +23 -0
- package/dist/app.js.map +1 -0
- package/dist/auth/constants.d.ts +9 -0
- package/dist/auth/constants.d.ts.map +1 -0
- package/{src → dist}/auth/constants.js +2 -2
- package/dist/auth/constants.js.map +1 -0
- package/dist/auth/domains.d.ts +3 -0
- package/dist/auth/domains.d.ts.map +1 -0
- package/dist/auth/domains.js +8 -0
- package/dist/auth/domains.js.map +1 -0
- package/dist/auth/encoding.d.ts +7 -0
- package/dist/auth/encoding.d.ts.map +1 -0
- package/dist/auth/encoding.js +41 -0
- package/dist/auth/encoding.js.map +1 -0
- package/dist/auth/groups/d1.d.ts +16 -0
- package/dist/auth/groups/d1.d.ts.map +1 -0
- package/dist/auth/groups/d1.js +66 -0
- package/dist/auth/groups/d1.js.map +1 -0
- package/dist/auth/groups/domain.d.ts +8 -0
- package/dist/auth/groups/domain.d.ts.map +1 -0
- package/dist/auth/groups/domain.js +99 -0
- package/dist/auth/groups/domain.js.map +1 -0
- package/dist/auth/groups/index.d.ts +7 -0
- package/dist/auth/groups/index.d.ts.map +1 -0
- package/dist/auth/groups/index.js +7 -0
- package/dist/auth/groups/index.js.map +1 -0
- package/dist/auth/groups/model.d.ts +38 -0
- package/dist/auth/groups/model.d.ts.map +1 -0
- package/dist/auth/groups/model.js +2 -0
- package/dist/auth/groups/model.js.map +1 -0
- package/dist/auth/groups/policy.d.ts +5 -0
- package/dist/auth/groups/policy.d.ts.map +1 -0
- package/dist/auth/groups/policy.js +8 -0
- package/dist/auth/groups/policy.js.map +1 -0
- package/dist/auth/groups/service.d.ts +20 -0
- package/dist/auth/groups/service.d.ts.map +1 -0
- package/dist/auth/groups/service.js +40 -0
- package/dist/auth/groups/service.js.map +1 -0
- package/dist/auth/groups/validation.d.ts +5 -0
- package/dist/auth/groups/validation.d.ts.map +1 -0
- package/dist/auth/groups/validation.js +22 -0
- package/dist/auth/groups/validation.js.map +1 -0
- package/dist/auth/groups/views/list.d.ts +10 -0
- package/dist/auth/groups/views/list.d.ts.map +1 -0
- package/dist/auth/groups/views/list.js +4 -0
- package/dist/auth/groups/views/list.js.map +1 -0
- package/dist/auth/identity/index.d.ts +58 -0
- package/dist/auth/identity/index.d.ts.map +1 -0
- package/dist/auth/identity/index.js +58 -0
- package/dist/auth/identity/index.js.map +1 -0
- package/dist/auth/impersonation/constants.d.ts +2 -0
- package/dist/auth/impersonation/constants.d.ts.map +1 -0
- package/dist/auth/impersonation/constants.js +2 -0
- package/dist/auth/impersonation/constants.js.map +1 -0
- package/dist/auth/impersonation/domain.d.ts +6 -0
- package/dist/auth/impersonation/domain.d.ts.map +1 -0
- package/dist/auth/impersonation/domain.js +16 -0
- package/dist/auth/impersonation/domain.js.map +1 -0
- package/dist/auth/impersonation/index.d.ts +6 -0
- package/dist/auth/impersonation/index.d.ts.map +1 -0
- package/dist/auth/impersonation/index.js +6 -0
- package/dist/auth/impersonation/index.js.map +1 -0
- package/dist/auth/impersonation/model.d.ts +12 -0
- package/dist/auth/impersonation/model.d.ts.map +1 -0
- package/dist/auth/impersonation/model.js +2 -0
- package/dist/auth/impersonation/model.js.map +1 -0
- package/dist/auth/impersonation/service.d.ts +4 -0
- package/dist/auth/impersonation/service.d.ts.map +1 -0
- package/dist/auth/impersonation/service.js +32 -0
- package/dist/auth/impersonation/service.js.map +1 -0
- package/dist/auth/impersonation/validation.d.ts +4 -0
- package/dist/auth/impersonation/validation.d.ts.map +1 -0
- package/dist/auth/impersonation/validation.js +14 -0
- package/dist/auth/impersonation/validation.js.map +1 -0
- package/dist/auth/index.d.ts +13 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +13 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/auth/oauth-single/constants.d.ts +4 -0
- package/dist/auth/oauth-single/constants.d.ts.map +1 -0
- package/dist/auth/oauth-single/constants.js +5 -0
- package/dist/auth/oauth-single/constants.js.map +1 -0
- package/dist/auth/oauth-single/cookies.d.ts +10 -0
- package/dist/auth/oauth-single/cookies.d.ts.map +1 -0
- package/dist/auth/oauth-single/cookies.js +59 -0
- package/dist/auth/oauth-single/cookies.js.map +1 -0
- package/dist/auth/oauth-single/domain.d.ts +14 -0
- package/dist/auth/oauth-single/domain.d.ts.map +1 -0
- package/dist/auth/oauth-single/domain.js +12 -0
- package/dist/auth/oauth-single/domain.js.map +1 -0
- package/dist/auth/oauth-single/index.d.ts +31 -0
- package/dist/auth/oauth-single/index.d.ts.map +1 -0
- package/dist/auth/oauth-single/index.js +215 -0
- package/dist/auth/oauth-single/index.js.map +1 -0
- package/dist/auth/oauth-single/model.d.ts +75 -0
- package/dist/auth/oauth-single/model.d.ts.map +1 -0
- package/dist/auth/oauth-single/model.js +2 -0
- package/dist/auth/oauth-single/model.js.map +1 -0
- package/dist/auth/oauth-single/protocol.d.ts +9 -0
- package/dist/auth/oauth-single/protocol.d.ts.map +1 -0
- package/dist/auth/oauth-single/protocol.js +190 -0
- package/dist/auth/oauth-single/protocol.js.map +1 -0
- package/dist/auth/oauth-single/session.d.ts +7 -0
- package/dist/auth/oauth-single/session.d.ts.map +1 -0
- package/dist/auth/oauth-single/session.js +78 -0
- package/dist/auth/oauth-single/session.js.map +1 -0
- package/dist/auth/repositories.d.ts +58 -0
- package/dist/auth/repositories.d.ts.map +1 -0
- package/dist/auth/repositories.js +31 -0
- package/dist/auth/repositories.js.map +1 -0
- package/dist/auth/scopes/d1.d.ts +17 -0
- package/dist/auth/scopes/d1.d.ts.map +1 -0
- package/dist/auth/scopes/d1.js +54 -0
- package/dist/auth/scopes/d1.js.map +1 -0
- package/dist/auth/scopes/domain.d.ts +7 -0
- package/dist/auth/scopes/domain.d.ts.map +1 -0
- package/dist/auth/scopes/domain.js +25 -0
- package/dist/auth/scopes/domain.js.map +1 -0
- package/dist/auth/scopes/index.d.ts +4 -0
- package/dist/auth/scopes/index.d.ts.map +1 -0
- package/dist/auth/scopes/index.js +4 -0
- package/dist/auth/scopes/index.js.map +1 -0
- package/dist/auth/scopes/model.d.ts +26 -0
- package/dist/auth/scopes/model.d.ts.map +1 -0
- package/dist/auth/scopes/model.js +2 -0
- package/dist/auth/scopes/model.js.map +1 -0
- package/dist/auth/scopes/policy.d.ts +3 -0
- package/dist/auth/scopes/policy.d.ts.map +1 -0
- package/dist/auth/scopes/policy.js +4 -0
- package/dist/auth/scopes/policy.js.map +1 -0
- package/dist/auth/scopes/service.d.ts +4 -0
- package/dist/auth/scopes/service.d.ts.map +1 -0
- package/dist/auth/scopes/service.js +4 -0
- package/dist/auth/scopes/service.js.map +1 -0
- package/dist/auth/scopes/validation.d.ts +6 -0
- package/dist/auth/scopes/validation.d.ts.map +1 -0
- package/dist/auth/scopes/validation.js +33 -0
- package/dist/auth/scopes/validation.js.map +1 -0
- package/dist/auth/scopes/views/list.d.ts +9 -0
- package/dist/auth/scopes/views/list.d.ts.map +1 -0
- package/dist/auth/scopes/views/list.js +4 -0
- package/dist/auth/scopes/views/list.js.map +1 -0
- package/dist/auth/subscriptions/d1.d.ts +10 -0
- package/dist/auth/subscriptions/d1.d.ts.map +1 -0
- package/dist/auth/subscriptions/d1.js +86 -0
- package/dist/auth/subscriptions/d1.js.map +1 -0
- package/dist/auth/subscriptions/domain.d.ts +10 -0
- package/dist/auth/subscriptions/domain.d.ts.map +1 -0
- package/dist/auth/subscriptions/domain.js +33 -0
- package/dist/auth/subscriptions/domain.js.map +1 -0
- package/dist/auth/subscriptions/index.d.ts +6 -0
- package/dist/auth/subscriptions/index.d.ts.map +1 -0
- package/dist/auth/subscriptions/index.js +6 -0
- package/dist/auth/subscriptions/index.js.map +1 -0
- package/dist/auth/subscriptions/model.d.ts +20 -0
- package/dist/auth/subscriptions/model.d.ts.map +1 -0
- package/dist/auth/subscriptions/model.js +2 -0
- package/dist/auth/subscriptions/model.js.map +1 -0
- package/dist/auth/subscriptions/service.d.ts +12 -0
- package/dist/auth/subscriptions/service.d.ts.map +1 -0
- package/dist/auth/subscriptions/service.js +71 -0
- package/dist/auth/subscriptions/service.js.map +1 -0
- package/dist/auth/subscriptions/validation.d.ts +3 -0
- package/dist/auth/subscriptions/validation.d.ts.map +1 -0
- package/dist/auth/subscriptions/validation.js +21 -0
- package/dist/auth/subscriptions/validation.js.map +1 -0
- package/dist/auth/tenants/d1.d.ts +12 -0
- package/dist/auth/tenants/d1.d.ts.map +1 -0
- package/dist/auth/tenants/d1.js +40 -0
- package/dist/auth/tenants/d1.js.map +1 -0
- package/dist/auth/tenants/delete.d.ts +3 -0
- package/dist/auth/tenants/delete.d.ts.map +1 -0
- package/dist/auth/tenants/delete.js +28 -0
- package/dist/auth/tenants/delete.js.map +1 -0
- package/dist/auth/tenants/domain.d.ts +8 -0
- package/dist/auth/tenants/domain.d.ts.map +1 -0
- package/dist/auth/tenants/domain.js +64 -0
- package/dist/auth/tenants/domain.js.map +1 -0
- package/dist/auth/tenants/index.d.ts +7 -0
- package/dist/auth/tenants/index.d.ts.map +1 -0
- package/dist/auth/tenants/index.js +7 -0
- package/dist/auth/tenants/index.js.map +1 -0
- package/dist/auth/tenants/model.d.ts +28 -0
- package/dist/auth/tenants/model.d.ts.map +1 -0
- package/dist/auth/tenants/model.js +2 -0
- package/dist/auth/tenants/model.js.map +1 -0
- package/dist/auth/tenants/policy.d.ts +3 -0
- package/dist/auth/tenants/policy.d.ts.map +1 -0
- package/dist/auth/tenants/policy.js +4 -0
- package/dist/auth/tenants/policy.js.map +1 -0
- package/dist/auth/tenants/service.d.ts +14 -0
- package/dist/auth/tenants/service.d.ts.map +1 -0
- package/dist/auth/tenants/service.js +37 -0
- package/dist/auth/tenants/service.js.map +1 -0
- package/dist/auth/tenants/validation.d.ts +5 -0
- package/dist/auth/tenants/validation.d.ts.map +1 -0
- package/dist/auth/tenants/validation.js +21 -0
- package/dist/auth/tenants/validation.js.map +1 -0
- package/dist/auth/tenants/views/list.d.ts +8 -0
- package/dist/auth/tenants/views/list.d.ts.map +1 -0
- package/dist/auth/tenants/views/list.js +3 -0
- package/dist/auth/tenants/views/list.js.map +1 -0
- package/dist/auth/users/access.d.ts +9 -0
- package/dist/auth/users/access.d.ts.map +1 -0
- package/dist/auth/users/access.js +53 -0
- package/dist/auth/users/access.js.map +1 -0
- package/dist/auth/users/d1.d.ts +19 -0
- package/dist/auth/users/d1.d.ts.map +1 -0
- package/dist/auth/users/d1.js +68 -0
- package/dist/auth/users/d1.js.map +1 -0
- package/dist/auth/users/domain.d.ts +13 -0
- package/dist/auth/users/domain.d.ts.map +1 -0
- package/dist/auth/users/domain.js +129 -0
- package/dist/auth/users/domain.js.map +1 -0
- package/dist/auth/users/index.d.ts +7 -0
- package/dist/auth/users/index.d.ts.map +1 -0
- package/dist/auth/users/index.js +7 -0
- package/dist/auth/users/index.js.map +1 -0
- package/dist/auth/users/model.d.ts +44 -0
- package/dist/auth/users/model.d.ts.map +1 -0
- package/dist/auth/users/model.js +2 -0
- package/dist/auth/users/model.js.map +1 -0
- package/dist/auth/users/service.d.ts +8 -0
- package/dist/auth/users/service.d.ts.map +1 -0
- package/dist/auth/users/service.js +62 -0
- package/dist/auth/users/service.js.map +1 -0
- package/dist/auth/users/validation.d.ts +4 -0
- package/dist/auth/users/validation.d.ts.map +1 -0
- package/dist/auth/users/validation.js +23 -0
- package/dist/auth/users/validation.js.map +1 -0
- package/dist/cli/cli.d.ts +9 -0
- package/dist/cli/cli.d.ts.map +1 -0
- package/dist/cli/cli.js +201 -0
- package/dist/cli/cli.js.map +1 -0
- package/dist/cli/d1.d.ts +24 -0
- package/dist/cli/d1.d.ts.map +1 -0
- package/dist/cli/d1.js +175 -0
- package/dist/cli/d1.js.map +1 -0
- package/dist/cli/operations.d.ts +3 -0
- package/dist/cli/operations.d.ts.map +1 -0
- package/dist/cli/operations.js +63 -0
- package/dist/cli/operations.js.map +1 -0
- package/dist/cli/project.d.ts +136 -0
- package/dist/cli/project.d.ts.map +1 -0
- package/dist/cli/project.js +738 -0
- package/dist/cli/project.js.map +1 -0
- package/dist/cli/status.d.ts +24 -0
- package/dist/cli/status.d.ts.map +1 -0
- package/dist/cli/status.js +55 -0
- package/dist/cli/status.js.map +1 -0
- package/dist/cli/tenants.d.ts +9 -0
- package/dist/cli/tenants.d.ts.map +1 -0
- package/dist/cli/tenants.js +32 -0
- package/dist/cli/tenants.js.map +1 -0
- package/dist/cli/types.d.ts +43 -0
- package/dist/cli/types.d.ts.map +1 -0
- package/dist/cli/types.js +2 -0
- package/dist/cli/types.js.map +1 -0
- package/dist/cli/users.d.ts +8 -0
- package/dist/cli/users.d.ts.map +1 -0
- package/dist/cli/users.js +74 -0
- package/dist/cli/users.js.map +1 -0
- package/dist/cli/version.d.ts +12 -0
- package/dist/cli/version.d.ts.map +1 -0
- package/dist/cli/version.js +60 -0
- package/dist/cli/version.js.map +1 -0
- package/dist/core/circuits/availability.d.ts +48 -0
- package/dist/core/circuits/availability.d.ts.map +1 -0
- package/dist/core/circuits/availability.js +87 -0
- package/dist/core/circuits/availability.js.map +1 -0
- package/dist/core/circuits/d1.d.ts +11 -0
- package/dist/core/circuits/d1.d.ts.map +1 -0
- package/dist/core/circuits/d1.js +83 -0
- package/dist/core/circuits/d1.js.map +1 -0
- package/dist/core/circuits/domain.d.ts +7 -0
- package/dist/core/circuits/domain.d.ts.map +1 -0
- package/dist/core/circuits/domain.js +36 -0
- package/dist/core/circuits/domain.js.map +1 -0
- package/dist/core/circuits/index.d.ts +6 -0
- package/dist/core/circuits/index.d.ts.map +1 -0
- package/dist/core/circuits/index.js +6 -0
- package/dist/core/circuits/index.js.map +1 -0
- package/dist/core/circuits/model.d.ts +50 -0
- package/dist/core/circuits/model.d.ts.map +1 -0
- package/dist/core/circuits/model.js +2 -0
- package/dist/core/circuits/model.js.map +1 -0
- package/dist/core/circuits/service.d.ts +9 -0
- package/dist/core/circuits/service.d.ts.map +1 -0
- package/dist/core/circuits/service.js +63 -0
- package/dist/core/circuits/service.js.map +1 -0
- package/dist/core/circuits/validation.d.ts +4 -0
- package/dist/core/circuits/validation.d.ts.map +1 -0
- package/dist/core/circuits/validation.js +35 -0
- package/dist/core/circuits/validation.js.map +1 -0
- package/dist/core/constants.d.ts +9 -0
- package/dist/core/constants.d.ts.map +1 -0
- package/{src → dist}/core/constants.js +2 -1
- package/dist/core/constants.js.map +1 -0
- package/dist/core/database/index.d.ts +14 -0
- package/dist/core/database/index.d.ts.map +1 -0
- package/dist/core/database/index.js +65 -0
- package/dist/core/database/index.js.map +1 -0
- package/dist/core/domains.d.ts +2 -0
- package/dist/core/domains.d.ts.map +1 -0
- package/dist/core/domains.js +7 -0
- package/dist/core/domains.js.map +1 -0
- package/dist/core/events/audit.d.ts +8 -0
- package/dist/core/events/audit.d.ts.map +1 -0
- package/dist/core/events/audit.js +27 -0
- package/dist/core/events/audit.js.map +1 -0
- package/dist/core/events/domain.d.ts +19 -0
- package/dist/core/events/domain.d.ts.map +1 -0
- package/dist/core/events/domain.js +39 -0
- package/dist/core/events/domain.js.map +1 -0
- package/dist/core/events/hub.d.ts +10 -0
- package/dist/core/events/hub.d.ts.map +1 -0
- package/dist/core/events/hub.js +56 -0
- package/dist/core/events/hub.js.map +1 -0
- package/dist/core/events/index.d.ts +57 -0
- package/dist/core/events/index.d.ts.map +1 -0
- package/dist/core/events/index.js +170 -0
- package/dist/core/events/index.js.map +1 -0
- package/dist/core/healthchecks/d1.d.ts +7 -0
- package/dist/core/healthchecks/d1.d.ts.map +1 -0
- package/dist/core/healthchecks/d1.js +43 -0
- package/dist/core/healthchecks/d1.js.map +1 -0
- package/dist/core/healthchecks/domain.d.ts +7 -0
- package/dist/core/healthchecks/domain.d.ts.map +1 -0
- package/dist/core/healthchecks/domain.js +51 -0
- package/dist/core/healthchecks/domain.js.map +1 -0
- package/dist/core/healthchecks/features.d.ts +19 -0
- package/dist/core/healthchecks/features.d.ts.map +1 -0
- package/dist/core/healthchecks/features.js +100 -0
- package/dist/core/healthchecks/features.js.map +1 -0
- package/dist/core/healthchecks/index.d.ts +6 -0
- package/dist/core/healthchecks/index.d.ts.map +1 -0
- package/dist/core/healthchecks/index.js +6 -0
- package/dist/core/healthchecks/index.js.map +1 -0
- package/dist/core/healthchecks/model.d.ts +64 -0
- package/dist/core/healthchecks/model.d.ts.map +1 -0
- package/dist/core/healthchecks/model.js +2 -0
- package/dist/core/healthchecks/model.js.map +1 -0
- package/dist/core/healthchecks/service.d.ts +8 -0
- package/dist/core/healthchecks/service.d.ts.map +1 -0
- package/dist/core/healthchecks/service.js +29 -0
- package/dist/core/healthchecks/service.js.map +1 -0
- package/dist/core/healthchecks/validation.d.ts +5 -0
- package/dist/core/healthchecks/validation.d.ts.map +1 -0
- package/dist/core/healthchecks/validation.js +51 -0
- package/dist/core/healthchecks/validation.js.map +1 -0
- package/dist/core/index.d.ts +9 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +9 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/jobs/d1.d.ts +19 -0
- package/dist/core/jobs/d1.d.ts.map +1 -0
- package/dist/core/jobs/d1.js +139 -0
- package/dist/core/jobs/d1.js.map +1 -0
- package/dist/core/jobs/domain.d.ts +8 -0
- package/dist/core/jobs/domain.d.ts.map +1 -0
- package/dist/core/jobs/domain.js +59 -0
- package/dist/core/jobs/domain.js.map +1 -0
- package/dist/core/jobs/events.d.ts +3 -0
- package/dist/core/jobs/events.d.ts.map +1 -0
- package/dist/core/jobs/events.js +25 -0
- package/dist/core/jobs/events.js.map +1 -0
- package/dist/core/jobs/index.d.ts +7 -0
- package/dist/core/jobs/index.d.ts.map +1 -0
- package/dist/core/jobs/index.js +7 -0
- package/dist/core/jobs/index.js.map +1 -0
- package/dist/core/jobs/model.d.ts +86 -0
- package/dist/core/jobs/model.d.ts.map +1 -0
- package/dist/core/jobs/model.js +2 -0
- package/dist/core/jobs/model.js.map +1 -0
- package/dist/core/jobs/service.d.ts +39 -0
- package/dist/core/jobs/service.d.ts.map +1 -0
- package/dist/core/jobs/service.js +84 -0
- package/dist/core/jobs/service.js.map +1 -0
- package/dist/core/jobs/validation.d.ts +8 -0
- package/dist/core/jobs/validation.d.ts.map +1 -0
- package/dist/core/jobs/validation.js +39 -0
- package/dist/core/jobs/validation.js.map +1 -0
- package/dist/core/security/index.d.ts +30 -0
- package/dist/core/security/index.d.ts.map +1 -0
- package/dist/core/security/index.js +138 -0
- package/dist/core/security/index.js.map +1 -0
- package/dist/data/context.d.ts +20 -0
- package/dist/data/context.d.ts.map +1 -0
- package/dist/data/context.js +65 -0
- package/dist/data/context.js.map +1 -0
- package/dist/data/index.d.ts +5 -0
- package/dist/data/index.d.ts.map +1 -0
- package/{src → dist}/data/index.js +2 -0
- package/dist/data/index.js.map +1 -0
- package/dist/data/json.d.ts +3 -0
- package/dist/data/json.d.ts.map +1 -0
- package/dist/data/json.js +14 -0
- package/dist/data/json.js.map +1 -0
- package/dist/data/model.d.ts +96 -0
- package/dist/data/model.d.ts.map +1 -0
- package/dist/data/model.js +3 -0
- package/dist/data/model.js.map +1 -0
- package/dist/data/policy.d.ts +14 -0
- package/dist/data/policy.d.ts.map +1 -0
- package/dist/data/policy.js +89 -0
- package/dist/data/policy.js.map +1 -0
- package/dist/data/reader.d.ts +9 -0
- package/dist/data/reader.d.ts.map +1 -0
- package/dist/data/reader.js +203 -0
- package/dist/data/reader.js.map +1 -0
- package/dist/data/resources.d.ts +9 -0
- package/dist/data/resources.d.ts.map +1 -0
- package/dist/data/resources.js +129 -0
- package/dist/data/resources.js.map +1 -0
- package/dist/domain/app-domain.d.ts +36 -0
- package/dist/domain/app-domain.d.ts.map +1 -0
- package/dist/domain/app-domain.js +79 -0
- package/dist/domain/app-domain.js.map +1 -0
- package/dist/domain/index.d.ts +3 -0
- package/dist/domain/index.d.ts.map +1 -0
- package/dist/domain/index.js +3 -0
- package/dist/domain/index.js.map +1 -0
- package/dist/domain/model.d.ts +37 -0
- package/dist/domain/model.d.ts.map +1 -0
- package/dist/domain/model.js +2 -0
- package/dist/domain/model.js.map +1 -0
- package/dist/features/index.d.ts +25 -0
- package/dist/features/index.d.ts.map +1 -0
- package/dist/features/index.js +61 -0
- package/dist/features/index.js.map +1 -0
- package/dist/features/llm/client.d.ts +3 -0
- package/dist/features/llm/client.d.ts.map +1 -0
- package/dist/features/llm/client.js +327 -0
- package/dist/features/llm/client.js.map +1 -0
- package/dist/features/llm/config.d.ts +7 -0
- package/dist/features/llm/config.d.ts.map +1 -0
- package/dist/features/llm/config.js +93 -0
- package/dist/features/llm/config.js.map +1 -0
- package/dist/features/llm/constants.d.ts +5 -0
- package/dist/features/llm/constants.d.ts.map +1 -0
- package/dist/features/llm/constants.js +6 -0
- package/dist/features/llm/constants.js.map +1 -0
- package/dist/features/llm/errors.d.ts +12 -0
- package/dist/features/llm/errors.d.ts.map +1 -0
- package/dist/features/llm/errors.js +19 -0
- package/dist/features/llm/errors.js.map +1 -0
- package/dist/features/llm/feature.d.ts +6 -0
- package/dist/features/llm/feature.d.ts.map +1 -0
- package/dist/features/llm/feature.js +37 -0
- package/dist/features/llm/feature.js.map +1 -0
- package/dist/features/llm/index.d.ts +9 -0
- package/dist/features/llm/index.d.ts.map +1 -0
- package/dist/features/llm/index.js +6 -0
- package/dist/features/llm/index.js.map +1 -0
- package/dist/features/llm/model.d.ts +171 -0
- package/dist/features/llm/model.d.ts.map +1 -0
- package/dist/features/llm/model.js +2 -0
- package/dist/features/llm/model.js.map +1 -0
- package/dist/features/llm/schema.d.ts +4 -0
- package/dist/features/llm/schema.d.ts.map +1 -0
- package/dist/features/llm/schema.js +82 -0
- package/dist/features/llm/schema.js.map +1 -0
- package/dist/features/llm/service.d.ts +29 -0
- package/dist/features/llm/service.d.ts.map +1 -0
- package/dist/features/llm/service.js +55 -0
- package/dist/features/llm/service.js.map +1 -0
- package/dist/features/messaging/constants.d.ts +3 -0
- package/dist/features/messaging/constants.d.ts.map +1 -0
- package/dist/features/messaging/constants.js +4 -0
- package/dist/features/messaging/constants.js.map +1 -0
- package/dist/features/messaging/domain.d.ts +9 -0
- package/dist/features/messaging/domain.d.ts.map +1 -0
- package/dist/features/messaging/domain.js +14 -0
- package/dist/features/messaging/domain.js.map +1 -0
- package/dist/features/messaging/feature.d.ts +7 -0
- package/dist/features/messaging/feature.d.ts.map +1 -0
- package/dist/features/messaging/feature.js +23 -0
- package/dist/features/messaging/feature.js.map +1 -0
- package/dist/features/messaging/index.d.ts +12 -0
- package/dist/features/messaging/index.d.ts.map +1 -0
- package/dist/features/messaging/index.js +8 -0
- package/dist/features/messaging/index.js.map +1 -0
- package/dist/features/messaging/jobs.d.ts +38 -0
- package/dist/features/messaging/jobs.d.ts.map +1 -0
- package/dist/features/messaging/jobs.js +40 -0
- package/dist/features/messaging/jobs.js.map +1 -0
- package/dist/features/messaging/models.d.ts +65 -0
- package/dist/features/messaging/models.d.ts.map +1 -0
- package/dist/features/messaging/models.js +97 -0
- package/dist/features/messaging/models.js.map +1 -0
- package/dist/features/messaging/resources.d.ts +8 -0
- package/dist/features/messaging/resources.d.ts.map +1 -0
- package/dist/features/messaging/resources.js +11 -0
- package/dist/features/messaging/resources.js.map +1 -0
- package/dist/features/messaging/store.d.ts +46 -0
- package/dist/features/messaging/store.d.ts.map +1 -0
- package/dist/features/messaging/store.js +208 -0
- package/dist/features/messaging/store.js.map +1 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.d.ts.map +1 -0
- package/{src → dist}/index.js +7 -2
- package/dist/index.js.map +1 -0
- package/dist/input.d.ts +18 -0
- package/dist/input.d.ts.map +1 -0
- package/dist/input.js +49 -0
- package/dist/input.js.map +1 -0
- package/dist/repository/model.d.ts +61 -0
- package/dist/repository/model.d.ts.map +1 -0
- package/dist/repository/model.js +2 -0
- package/dist/repository/model.js.map +1 -0
- package/dist/repository.d.ts +11 -0
- package/dist/repository.d.ts.map +1 -0
- package/dist/repository.js +118 -0
- package/dist/repository.js.map +1 -0
- package/dist/runtime/domains.d.ts +14 -0
- package/dist/runtime/domains.d.ts.map +1 -0
- package/dist/runtime/domains.js +42 -0
- package/dist/runtime/domains.js.map +1 -0
- package/dist/runtime/features.d.ts +10 -0
- package/dist/runtime/features.d.ts.map +1 -0
- package/dist/runtime/features.js +37 -0
- package/dist/runtime/features.js.map +1 -0
- package/dist/runtime/health.d.ts +6 -0
- package/dist/runtime/health.d.ts.map +1 -0
- package/dist/runtime/health.js +28 -0
- package/dist/runtime/health.js.map +1 -0
- package/dist/runtime/hono.d.ts +30 -0
- package/dist/runtime/hono.d.ts.map +1 -0
- package/dist/runtime/hono.js +50 -0
- package/dist/runtime/hono.js.map +1 -0
- package/dist/runtime/model.d.ts +133 -0
- package/dist/runtime/model.d.ts.map +1 -0
- package/dist/runtime/model.js +2 -0
- package/dist/runtime/model.js.map +1 -0
- package/dist/runtime/responses.d.ts +9 -0
- package/dist/runtime/responses.d.ts.map +1 -0
- package/dist/runtime/responses.js +14 -0
- package/dist/runtime/responses.js.map +1 -0
- package/dist/runtime/worker.d.ts +10 -0
- package/dist/runtime/worker.d.ts.map +1 -0
- package/dist/runtime/worker.js +216 -0
- package/dist/runtime/worker.js.map +1 -0
- package/dist/ui/index.d.ts +3 -0
- package/dist/ui/index.d.ts.map +1 -0
- package/dist/ui/index.js +3 -0
- package/dist/ui/index.js.map +1 -0
- package/dist/ui/react/admin-access.d.ts +2 -0
- package/dist/ui/react/admin-access.d.ts.map +1 -0
- package/dist/ui/react/admin-access.js +47 -0
- package/dist/ui/react/admin-access.js.map +1 -0
- package/dist/ui/react/admin-audit.d.ts +2 -0
- package/dist/ui/react/admin-audit.d.ts.map +1 -0
- package/dist/ui/react/admin-audit.js +13 -0
- package/dist/ui/react/admin-audit.js.map +1 -0
- package/dist/ui/react/admin-catalogs.d.ts +6 -0
- package/dist/ui/react/admin-catalogs.d.ts.map +1 -0
- package/dist/ui/react/admin-catalogs.js +37 -0
- package/dist/ui/react/admin-catalogs.js.map +1 -0
- package/dist/ui/react/admin-dashboard.d.ts +39 -0
- package/dist/ui/react/admin-dashboard.d.ts.map +1 -0
- package/dist/ui/react/admin-dashboard.js +135 -0
- package/dist/ui/react/admin-dashboard.js.map +1 -0
- package/dist/ui/react/admin-details.d.ts +27 -0
- package/dist/ui/react/admin-details.d.ts.map +1 -0
- package/dist/ui/react/admin-details.js +82 -0
- package/dist/ui/react/admin-details.js.map +1 -0
- package/dist/ui/react/admin-shell.d.ts +20 -0
- package/dist/ui/react/admin-shell.d.ts.map +1 -0
- package/dist/ui/react/admin-shell.js +24 -0
- package/dist/ui/react/admin-shell.js.map +1 -0
- package/dist/ui/react/bootstrap.d.ts +9 -0
- package/dist/ui/react/bootstrap.d.ts.map +1 -0
- package/dist/ui/react/bootstrap.js +45 -0
- package/dist/ui/react/bootstrap.js.map +1 -0
- package/dist/ui/react/foundation.d.ts +35 -0
- package/dist/ui/react/foundation.d.ts.map +1 -0
- package/dist/ui/react/foundation.js +62 -0
- package/dist/ui/react/foundation.js.map +1 -0
- package/dist/ui/react/index.d.ts +12 -0
- package/dist/ui/react/index.d.ts.map +1 -0
- package/dist/ui/react/index.js +12 -0
- package/dist/ui/react/index.js.map +1 -0
- package/dist/ui/react/jobs.d.ts +62 -0
- package/dist/ui/react/jobs.d.ts.map +1 -0
- package/dist/ui/react/jobs.js +114 -0
- package/dist/ui/react/jobs.js.map +1 -0
- package/dist/ui/react/live-events.d.ts +18 -0
- package/dist/ui/react/live-events.d.ts.map +1 -0
- package/dist/ui/react/live-events.js +94 -0
- package/dist/ui/react/live-events.js.map +1 -0
- package/dist/ui/react/types.d.ts +79 -0
- package/dist/ui/react/types.d.ts.map +1 -0
- package/dist/ui/react/types.js +32 -0
- package/dist/ui/react/types.js.map +1 -0
- package/dist/ui/ssr.d.ts +55 -0
- package/dist/ui/ssr.d.ts.map +1 -0
- package/dist/ui/ssr.js +30 -0
- package/dist/ui/ssr.js.map +1 -0
- package/{src → dist}/ui/styles.css +22 -1
- package/migrations/0007_messaging.sql +52 -0
- package/migrations/0008_messaging_tenant_integrity.sql +44 -0
- package/migrations/0009_healthcheck_measurements.sql +3 -0
- package/migrations/0010_admin_dashboard_refinements.sql +24 -0
- package/package.json +162 -21
- package/changelog.md +0 -25
- package/src/admin/index.js +0 -1
- package/src/admin/routes.js +0 -64
- package/src/api/client.js +0 -8
- package/src/api/contracts.js +0 -24
- package/src/api/index.js +0 -7
- package/src/api/jobs.js +0 -37
- package/src/api/testing.js +0 -13
- package/src/app.js +0 -5
- package/src/auth/encoding.js +0 -6
- package/src/auth/groups.js +0 -5
- package/src/auth/impersonation.js +0 -15
- package/src/auth/index.js +0 -8
- package/src/auth/oauth-single.js +0 -204
- package/src/auth/scopes.js +0 -32
- package/src/auth/subscriptions.js +0 -42
- package/src/auth/tenants.js +0 -34
- package/src/auth/users.js +0 -40
- package/src/cli/cli.js +0 -133
- package/src/cli/d1.js +0 -165
- package/src/cli/operations.js +0 -34
- package/src/cli/project.js +0 -560
- package/src/cli/status.js +0 -46
- package/src/cli/tenants.js +0 -16
- package/src/cli/users.js +0 -34
- package/src/cli/version.js +0 -54
- package/src/core/circuits.js +0 -134
- package/src/core/d1.js +0 -54
- package/src/core/event-hub.js +0 -29
- package/src/core/events.js +0 -63
- package/src/core/identity.js +0 -39
- package/src/core/index.js +0 -7
- package/src/core/jobs.js +0 -185
- package/src/core/security.js +0 -88
- package/src/data/context.js +0 -16
- package/src/data/reader.js +0 -63
- package/src/data/resources.js +0 -42
- package/src/repository.js +0 -63
- package/src/runtime/features.js +0 -17
- package/src/runtime/health.js +0 -17
- package/src/runtime/worker.js +0 -58
- package/src/ui/index.js +0 -1
- package/src/ui/react/admin-access.jsx +0 -29
- package/src/ui/react/admin-catalogs.jsx +0 -39
- package/src/ui/react/admin-shell.jsx +0 -17
- package/src/ui/react/foundation.jsx +0 -40
- package/src/ui/react/index.jsx +0 -6
- package/src/ui/react/jobs.jsx +0 -63
- package/src/ui/react/live-events.jsx +0 -55
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 5.0.3
|
|
4
|
+
|
|
5
|
+
This release intentionally removes legacy compatibility paths. Applications
|
|
6
|
+
must migrate to the single v5 contract; no aliases or fallback behavior are
|
|
7
|
+
retained.
|
|
8
|
+
|
|
9
|
+
### Consolidation
|
|
10
|
+
|
|
11
|
+
- `cf-genai-llm`, `cf-genai-messaging`, and `cf-genai-cli` are no longer
|
|
12
|
+
runtime dependencies. LLM and messaging now ship from
|
|
13
|
+
`@agilesyndrome/cf-genai-base/features/llm` and `/features/messaging`; the
|
|
14
|
+
`cf-genai` executable ships from base.
|
|
15
|
+
- Messaging storage is now base migration `0007_messaging.sql`. Vendor and
|
|
16
|
+
apply the base migrations, then remove separately vendored messaging schema
|
|
17
|
+
migrations when they are redundant for a new installation.
|
|
18
|
+
- Messaging tables and the built-in resource manifest are tenant-scoped by
|
|
19
|
+
default. Remove application-owned messaging resource declarations; existing
|
|
20
|
+
installations must add and backfill `tenant_id` before adopting the base
|
|
21
|
+
migration contract.
|
|
22
|
+
- The changelog filename is now `CHANGELOG.md`.
|
|
23
|
+
- Core operational code is divided into owned segments: `circuits/`,
|
|
24
|
+
`healthchecks/`, `events/`, `jobs/`, `database/`, and `security/`. Request
|
|
25
|
+
identity now lives under `auth/identity/`. Internal modules use these narrow
|
|
26
|
+
boundaries instead of the broad core barrel.
|
|
27
|
+
- Built-in features now use folder entrypoints. LLM code is divided into
|
|
28
|
+
client, configuration, schema, error, and manifest modules under
|
|
29
|
+
`features/llm/`; messaging code is divided into model, resource, store, job,
|
|
30
|
+
and manifest modules under `features/messaging/`.
|
|
31
|
+
|
|
32
|
+
### Required application changes
|
|
33
|
+
|
|
34
|
+
- Replace imports of removed flat source modules with package segment exports:
|
|
35
|
+
`core/circuits.js` becomes `/core/circuits`, `core/events.js` becomes
|
|
36
|
+
`/core/events`, `core/jobs.js` becomes `/core/jobs`, `core/d1.js` becomes
|
|
37
|
+
`/core/database`, `core/security.js` becomes `/core/security`, and
|
|
38
|
+
`core/identity.js` becomes `/auth/identity`. The old source files and their
|
|
39
|
+
compatibility facades do not exist in v5.
|
|
40
|
+
- Replace direct source imports of `src/features/llm.js` and
|
|
41
|
+
`src/features/messaging.js` with their folder `index.js` files. Package
|
|
42
|
+
consumers continue to use `/features/llm` and `/features/messaging`; those
|
|
43
|
+
package paths now resolve to the folder entrypoints.
|
|
44
|
+
|
|
45
|
+
- Move every feature registration into `defineApp({ features: [...] })`.
|
|
46
|
+
Remove `createWorker.features` and `createWorker.featureOptions`. Configure a
|
|
47
|
+
built-in with `defineFeature("llm", options)` or
|
|
48
|
+
`defineFeature("messaging", options)`; put external feature objects such as
|
|
49
|
+
auth directly in the same application feature array.
|
|
50
|
+
- Remove `createWorker.auth` and `createWorker.repositories`. Register auth as
|
|
51
|
+
an application feature and repositories through `defineApp({ repositories })`.
|
|
52
|
+
- Replace `createFeature` imports with `createLLMFeature` or
|
|
53
|
+
`createMessagingFeature`. `createMessagingFeature` is no longer an alias.
|
|
54
|
+
- LLM clients expose only `generate`, `generateJob`, `generateMulti`, `review`,
|
|
55
|
+
`reviewMulti`, and `listModels`. Remove the `*WithSchema` method aliases.
|
|
56
|
+
- Use the fixed LLM signatures `(prompt, schema, options)`,
|
|
57
|
+
`(jobId, prompt, schema, options)`, and
|
|
58
|
+
`(originalText, prompts, schema, options)`. Object-wrapped requests and
|
|
59
|
+
schema-inside-options overloads are removed.
|
|
60
|
+
- Configure LLM credentials only with `apiToken` or `LLM_API_TOKEN`. Remove
|
|
61
|
+
`apiKey`, `LLM_API_KEY`, and `OPENAI_API_KEY`. Use `featureName`; the old
|
|
62
|
+
client `feature` option is removed.
|
|
63
|
+
- Messaging participants must be `{ type, key, name, metadata? }` objects.
|
|
64
|
+
Remove string participants and the `participantType`, `participantKey`,
|
|
65
|
+
`displayName`, `id`, `senderType`, `senderKey`, `senderName`, `recipients`,
|
|
66
|
+
and `kind` input aliases. Reply generators must return a message object, not
|
|
67
|
+
a string.
|
|
68
|
+
- Messaging stores now accept only a scoped data reader:
|
|
69
|
+
`createMessagingStore(env.data.tenant)`. Remove raw D1 bindings, table
|
|
70
|
+
prefixes, and authorization callbacks from store construction.
|
|
71
|
+
- Feature manifests now accept only `name`, `displayName`, `packageName`,
|
|
72
|
+
`version`, `healthchecks`, and `circuitBreakers` in their canonical casing.
|
|
73
|
+
Remove nested manifests, `id` names, snake-case manifest properties,
|
|
74
|
+
`healthChecks`, `circuit_breakers`, and circuit `dependencies`.
|
|
75
|
+
- Configure both an exact HTTPS `OIDC_DISCOVERY_URL` and `OIDC_ISSUER`. The
|
|
76
|
+
issuer-to-discovery fallback and automatic well-known URL construction are
|
|
77
|
+
removed.
|
|
78
|
+
- Use only the CLI forms `healthchecks ...`, `circuit-breakers ...`, and
|
|
79
|
+
`--env production`. Colon commands, singular domains, `circuit`, `update`
|
|
80
|
+
action aliases, `rename`, and `prod` are removed. `cf-genai upgrade` accepts
|
|
81
|
+
only `base` or `auth`; it no longer treats `llm` and `messaging` as aliases.
|
|
82
|
+
Top-level `backup` and `restore` aliases are removed; use `d1 backup` and
|
|
83
|
+
`d1 restore`.
|
|
84
|
+
- Read request IDs from the `X-Request-ID` response header. The browser client
|
|
85
|
+
no longer falls back to a `request_id` JSON field.
|
|
86
|
+
|
|
87
|
+
## 5.0.0
|
|
88
|
+
|
|
89
|
+
- Replace `@agilesyndrome/cf-genai-base/authorization` imports with `/auth`.
|
|
90
|
+
- Replace direct `src/core.js` imports with `src/core/index.js` or the package `/core` entrypoint.
|
|
91
|
+
- Replace direct `src/data.js` imports with `src/data/index.js` or the package `/data` entrypoint.
|
|
92
|
+
- Replace direct `src/api/router.js` imports with `src/api/contracts.js` for route definitions and dispatch.
|
|
93
|
+
- Update internal imports to the canonical folder modules; the old facade files are removed.
|
|
94
|
+
- Update package consumers and lockfiles to version `5.0.0`.
|
|
95
|
+
- Replace server-rendered admin HTML and custom elements with the React UI entrypoint; apps own the shell and theme around base's admin components.
|
|
96
|
+
- Apply `migrations/0006_jobs.sql`; features now use generic durable job helpers and `GET /api/jobs` instead of inventing job tables and status endpoints.
|
|
97
|
+
- Configure an `EVENT_HUB` Durable Object and export `EventHub` from `@agilesyndrome/cf-genai-base/event-hub` to enable authenticated live job events over WebSockets.
|
|
98
|
+
- Dispatch long-running work through a Cloudflare Workflow with `dispatchJob`; execute its durable lifecycle with `executeJob` instead of relying on request-lifetime background work.
|
|
99
|
+
- Remove the lowercase `admin_token` environment alias; use `ADMIN_TOKEN` only.
|
package/CLI.md
CHANGED
|
@@ -5,10 +5,6 @@ provides safe operational commands for Cloudflare Worker repositories using
|
|
|
5
5
|
Wrangler and D1. The refresh command surface contains only local and staging
|
|
6
6
|
targets.
|
|
7
7
|
|
|
8
|
-
Projects that previously installed `@agilesyndrome/cf-genai-cli` should remove
|
|
9
|
-
that dependency. Installing `@agilesyndrome/cf-genai-base` now installs the
|
|
10
|
-
same `cf-genai` executable.
|
|
11
|
-
|
|
12
8
|
Automation can import the command runner from
|
|
13
9
|
`@agilesyndrome/cf-genai-base/cli`. The migrated helper modules remain
|
|
14
10
|
available through subpaths such as `@agilesyndrome/cf-genai-base/cli/d1` and
|
|
@@ -23,14 +19,14 @@ cf-genai lint data-access
|
|
|
23
19
|
cf-genai test
|
|
24
20
|
cf-genai ci
|
|
25
21
|
cf-genai dev
|
|
22
|
+
cf-genai storybook
|
|
26
23
|
cf-genai upgrade base latest
|
|
27
24
|
cf-genai upgrade auth latest
|
|
28
|
-
cf-genai upgrade llm 5.0.0
|
|
29
|
-
cf-genai upgrade messaging latest
|
|
30
25
|
cf-genai release --confirm
|
|
31
26
|
cf-genai release --first --confirm
|
|
32
27
|
cf-genai release --add-trust --confirm
|
|
33
28
|
cf-genai release --dry-run
|
|
29
|
+
cf-genai release --pre --confirm
|
|
34
30
|
cf-genai release --version 4.1 --confirm
|
|
35
31
|
cf-genai release-status
|
|
36
32
|
cf-genai release-status --wait 3 --json
|
|
@@ -87,17 +83,17 @@ clean checkout on `main`, fetches and compares `origin/main`, pushes and
|
|
|
87
83
|
verifies the release commit before creating the tag, and only then pushes the
|
|
88
84
|
tag that triggers npm publishing. The release tag publishes the package through GitHub Actions with provenance. `config check` runs a Wrangler deploy dry-run. Production refresh remains intentionally unavailable; backups and restores are available with explicit file paths.
|
|
89
85
|
|
|
90
|
-
`upgrade PACKAGE VERSION` upgrades the first-party `base
|
|
91
|
-
|
|
86
|
+
`upgrade PACKAGE VERSION` upgrades the first-party `base` or `auth` package
|
|
87
|
+
with npm and vendors package migrations not already represented in the repository's
|
|
92
88
|
`migrations/` directory. The generated files are ordinary committed Wrangler
|
|
93
89
|
migrations, so the same schema change is applied consistently to local,
|
|
94
90
|
staging, and production D1 databases. Review and commit the package files,
|
|
95
91
|
`package.json`, `package-lock.json`, and generated migrations together.
|
|
96
92
|
Operational status can be read directly from the current site directory through Wrangler (no CLI login prompt):
|
|
97
|
-
cf-genai
|
|
98
|
-
cf-genai
|
|
99
|
-
cf-genai circuit-
|
|
100
|
-
cf-genai circuit-
|
|
93
|
+
cf-genai healthchecks list --env local
|
|
94
|
+
cf-genai healthchecks list --env staging
|
|
95
|
+
cf-genai circuit-breakers list --env production
|
|
96
|
+
cf-genai circuit-breakers set llm:openai-models on --env staging
|
|
101
97
|
The standardized admin surface mirrors cf-genai-base and uses Wrangler authentication from the current machine:
|
|
102
98
|
cf-genai admin status --env staging
|
|
103
99
|
cf-genai admin features --env staging
|
|
@@ -118,4 +114,4 @@ The standardized admin surface mirrors cf-genai-base and uses Wrangler authentic
|
|
|
118
114
|
Back up and restore a complete D1 database with explicit files:
|
|
119
115
|
cf-genai d1 backup production --output ./backup.sql --confirm-production
|
|
120
116
|
cf-genai d1 restore staging --file ./backup.sql --yes
|
|
121
|
-
`release` creates the version commit and tag; the tag-triggered workflow publishes to npm. `release-status` verifies a clean, pushed workspace, the remote release tag, successful GitHub Actions runs for that tag, npm publication, and whether the declared `cf-genai-base` version is current. An older base version is shown in yellow with an upgrade command. `--wait` is one total timeout in minutes shared by GitHub Actions and npm polling; the default is five minutes. Use `release --version MAJOR.MINOR` to explicitly jump to a version such as `5.0`; the CLI assigns patch `0`, accepts an equal prepared manifest version when its tag and npm version do not exist, rejects older versions, and refuses any version already present on npm or GitHub. This is useful for synchronizing packages onto a common release line.
|
|
117
|
+
`release` creates the version commit and tag; the tag-triggered workflow publishes to npm. Use `release --pre --confirm` for a prerelease build: each run creates a new monotonic version such as `<version>-pre.0`, `<version>-pre.1`, and an immutable release tag. `release-status` verifies a clean, pushed workspace, the remote release tag, successful GitHub Actions runs for that tag, npm publication, and whether the declared `cf-genai-base` version is current. An older base version is shown in yellow with an upgrade command. `--wait` is one total timeout in minutes shared by GitHub Actions and npm polling; the default is five minutes. Use `release --version MAJOR.MINOR` to explicitly jump to a version such as `5.0`; the CLI assigns patch `0`, accepts an equal prepared manifest version when its tag and npm version do not exist, rejects older versions, and refuses any version already present on npm or GitHub. This is useful for synchronizing packages onto a common release line.
|
package/CONTRACT.md
CHANGED
|
@@ -4,20 +4,35 @@ Every site built from this foundation follows the same edge contract.
|
|
|
4
4
|
|
|
5
5
|
## API, UI, and repositories
|
|
6
6
|
|
|
7
|
-
`
|
|
8
|
-
|
|
9
|
-
base
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
`AppDomain` owns route contracts alongside a concept's model, views, data
|
|
8
|
+
resources, and repositories. Applications register domains through
|
|
9
|
+
`defineApp({ domains })`; base gives every domain route to Hono and enforces
|
|
10
|
+
authentication, administrator status, same-origin mutation rules, custom
|
|
11
|
+
policies, and scope checks before invoking the handler. `defineRoute` remains
|
|
12
|
+
the low-level contract helper used by the domain dispatcher.
|
|
13
|
+
|
|
14
|
+
`defineApp` snapshots and freezes its manifest arrays. TypeScript consumers
|
|
15
|
+
retain the concrete domain and feature registration types, and built-in
|
|
16
|
+
`defineFeature` options are selected from the feature name.
|
|
17
|
+
|
|
18
|
+
The `/api` browser client returns `JsonValue | Response`: empty, `null`, or
|
|
19
|
+
non-JSON success bodies preserve the original unread `Response`. Callers that
|
|
20
|
+
need a narrower JSON result pass a `validateJson` type guard, which both checks
|
|
21
|
+
the untrusted payload and infers the result type. `ApiError` exposes only the
|
|
22
|
+
safe server message, HTTP `status`, and `X-Request-ID` as `requestId`.
|
|
23
|
+
|
|
24
|
+
Core security helpers expose typed same-origin inputs, bounded JSON-object
|
|
25
|
+
reading results, status-bearing request errors, and secure response helpers;
|
|
26
|
+
JSON parsing remains runtime-validated and request bodies are read from clones.
|
|
27
|
+
|
|
28
|
+
`createRepositories(env, definitions)` creates named application or domain
|
|
14
29
|
repositories over the request-scoped data reader. Definitions may declare
|
|
15
30
|
relations to other repositories. Repositories must not expose raw D1 or accept
|
|
16
31
|
unvalidated table, column, or SQL fragments from callers.
|
|
17
32
|
|
|
18
33
|
## Worker entrypoint
|
|
19
34
|
|
|
20
|
-
`createWorker({ fetch,
|
|
35
|
+
`createWorker({ fetch, app, middleware?, authorize?, scheduled?, security? })` owns the Worker lifecycle and reserved admin boundary. An application requests built-ins with `defineApp({ name, features: [defineFeature("llm", options), defineFeature("messaging", options)] })`; base resolves only those registrations and ignores every unrequested built-in. External feature objects are registered in the same `app.features` array. Business APIs, views, data resources, and repositories are composed through `AppDomain` instances registered in `app.domains` or `feature.domains`. Duplicate and unknown features fail during Worker construction. Feature middleware runs in declaration order and may call `next()` or return a response; feature endpoints must be domains so Hono remains the only route matcher. The site router owns pages that are not supplied by a domain. `scheduled`
|
|
21
36
|
is optional and must use `ctx.waitUntil` for background work.
|
|
22
37
|
|
|
23
38
|
## Routes
|
|
@@ -28,18 +43,19 @@ is optional and must use `ctx.waitUntil` for background work.
|
|
|
28
43
|
- `/admin` and `/admin/*` are browser admin routes; `/api/admin` and `/api/admin/*` are admin API routes.
|
|
29
44
|
- Admin routes use `AUTH_STRATEGY`; omitted or empty means `http_basic`. Basic auth accepts username `admin` and the value of `ADMIN_TOKEN`. Missing token means all admin routes return 401.
|
|
30
45
|
- `AUTH_STRATEGY=oauth` delegates identity establishment to the configured auth provider and uses `authorize` for admin policy.
|
|
31
|
-
- `scopes`
|
|
32
|
-
- Base protects `/admin` and `/api/admin`; browser pages are React applications that consume the JSON admin APIs.
|
|
33
|
-
- Base provides
|
|
46
|
+
- Domain route `scopes` register the application scope manifest and enforce access at the exact Hono route. Use `scopeMode: "any"` when any declared scope is sufficient; the default requires all declared scopes.
|
|
47
|
+
- Base protects `/admin` and `/api/admin`; browser pages are React applications that consume the JSON admin APIs. `AdminDashboard` is the complete single-route administration UI; it includes all platform catalogs and owns internal list/detail navigation. `AdminShell` and the individual components remain available for custom routed interfaces.
|
|
48
|
+
- Base provides list/detail APIs for users, groups, tenants, features, healthchecks, and circuit breakers, plus relationship replacement for user scopes, groups, and tenants. Built-in admin domains declare delegated `users:*`, `groups:*`, `tenants:*`, `operations:*`, `subscriptions:*`, and `impersonation:start` capabilities; platform administrators satisfy all route capabilities. It also provides short-lived impersonation controls. `GET /api/tenant` returns the authenticated active tenant and validated memberships; invalid `X-Tenant-ID` values return 400. React platform components consume these JSON APIs.
|
|
34
49
|
- Public APIs must be explicitly listed in provider-specific auth configuration.
|
|
35
50
|
- Mutating `/api/*` requests require a same-origin `Origin` header.
|
|
36
51
|
- `createWorker` supplies request-scoped `data`, `user`, `authUser`, `userId`, `context`, `event`, and audited D1 access to route handlers. `Event(who, what, where, when, details)` creates normalized events; installed features may consume them through `eventHandler`.
|
|
37
|
-
- `migrations/0006_jobs.sql` adds generic durable jobs and job events. Features create and update jobs with the exported lifecycle helpers; `GET /api/jobs`, `GET /api/jobs/:id`, and `GET /api/jobs/:id/events` expose only the authenticated owner's records. `GET /api/events` is an optional authenticated WebSocket stream backed by the configured `EVENT_HUB` Durable Object.
|
|
52
|
+
- `migrations/0006_jobs.sql` adds generic durable jobs and job events. Features create and update jobs with the exported lifecycle helpers; `GET /api/jobs`, `GET /api/jobs/:id`, and `GET /api/jobs/:id/events` expose only the authenticated owner's records, while `POST /api/jobs/:id/cancel` cancels an owned queued/running job. Administrators may request `GET /api/jobs?all=true`. `GET /api/events` is an optional authenticated WebSocket stream backed by the configured `EVENT_HUB` Durable Object.
|
|
38
53
|
|
|
39
54
|
## Environment and bindings
|
|
40
55
|
|
|
41
56
|
Required OIDC secrets for the standard auth plugin:
|
|
42
57
|
|
|
58
|
+
- `OIDC_DISCOVERY_URL`
|
|
43
59
|
- `OIDC_ISSUER`
|
|
44
60
|
- `OIDC_CLIENT_ID`
|
|
45
61
|
- `OIDC_CLIENT_SECRET`
|
|
@@ -56,7 +72,8 @@ Build metadata is optional: `BUILD_SHA` and `BUILD_NUMBER`.
|
|
|
56
72
|
The package includes ordered migrations. Each site must apply
|
|
57
73
|
`migrations/0001_authorization.sql` before enabling the generic user/scope APIs,
|
|
58
74
|
`migrations/0004_tenants.sql` for tenant membership and subscriptions, and
|
|
59
|
-
`migrations/0006_jobs.sql` before creating or reading durable jobs.
|
|
75
|
+
`migrations/0006_jobs.sql` before creating or reading durable jobs. Apps that
|
|
76
|
+
request messaging also apply `migrations/0007_messaging.sql`.
|
|
60
77
|
The tenant migration seeds the `Easley Family` tenant and `VIP` subscription,
|
|
61
78
|
and migrates existing authorization users into that tenant.
|
|
62
79
|
|
|
@@ -72,8 +89,8 @@ must remain in the application router rather than in the shared auth package.
|
|
|
72
89
|
|
|
73
90
|
## Scoped data contract
|
|
74
91
|
|
|
75
|
-
|
|
76
|
-
|
|
92
|
+
Domains expose persistence manifests through `domain.dataResources` and
|
|
93
|
+
`domain.repositories`; apps and features register those domains. Each resource must declare a safe
|
|
77
94
|
name, table, explicit columns, and one scope: `user`, `tenant`, `public`, or
|
|
78
95
|
`system`. Public resources are read-only and predicate on the worker's
|
|
79
96
|
`publicTenantId`, including for authenticated users.
|
package/README.md
CHANGED
|
@@ -10,6 +10,18 @@ The base owns the shared security boundary as well as Worker lifecycle concerns.
|
|
|
10
10
|
Use D1 bindings for durable application data and R2 bindings for binary assets;
|
|
11
11
|
do not put either into module-level state.
|
|
12
12
|
|
|
13
|
+
The Worker transport is built on [Hono](https://hono.dev/): middleware ordering,
|
|
14
|
+
HTTP method/path matching, and admin/API dispatch all use Hono's runtime. Existing
|
|
15
|
+
feature middleware keeps the package's compatibility signature while new integrations
|
|
16
|
+
can use Hono middleware directly. For Worker-rendered documents, import
|
|
17
|
+
`createSsrRenderer`, `SiteDocument`, or `renderSiteDocument` from
|
|
18
|
+
`@agilesyndrome/cf-genai-base/ui/ssr`; the interactive admin components remain
|
|
19
|
+
React-based and are intentionally separate from Hono JSX SSR.
|
|
20
|
+
|
|
21
|
+
The site document contract owns safe metadata, canonical URLs, Open Graph
|
|
22
|
+
fields, theme color, stylesheets, scripts, and body data attributes. A site
|
|
23
|
+
supplies its own children, theme CSS, navigation, and content components.
|
|
24
|
+
|
|
13
25
|
Base also provides provider-neutral authorization helpers and browser components
|
|
14
26
|
through `@agilesyndrome/cf-genai-base/auth` and
|
|
15
27
|
`@agilesyndrome/cf-genai-base/ui`. Applications declare their scope manifest,
|
|
@@ -18,24 +30,66 @@ API. The UI components are themeable with CSS custom properties and do not
|
|
|
18
30
|
contain application-specific components.
|
|
19
31
|
|
|
20
32
|
```js
|
|
21
|
-
import { createWorker,
|
|
33
|
+
import { createWorker, defineApp, defineFeature } from "@agilesyndrome/cf-genai-base";
|
|
22
34
|
|
|
23
35
|
export default createWorker({
|
|
24
|
-
|
|
36
|
+
app: defineApp({
|
|
37
|
+
name: "cookbook",
|
|
38
|
+
features: [
|
|
39
|
+
auth,
|
|
40
|
+
defineFeature("llm", { apiToken: (env) => env.LLM_API_TOKEN }),
|
|
41
|
+
defineFeature("messaging", { displayName: "Cookbook chat" }),
|
|
42
|
+
],
|
|
43
|
+
}),
|
|
25
44
|
fetch: async (request, env) => {
|
|
26
|
-
if (new URL(request.url).pathname === "/health") return healthResponse(env);
|
|
27
45
|
return router(request, env);
|
|
28
46
|
},
|
|
29
47
|
});
|
|
30
48
|
```
|
|
31
49
|
|
|
32
|
-
|
|
50
|
+
Built-in features are inert unless an application registers them in
|
|
51
|
+
`app.features`. Feature-specific APIs use explicit subpaths:
|
|
52
|
+
|
|
53
|
+
```js
|
|
54
|
+
import { createLLM } from "@agilesyndrome/cf-genai-base/features/llm";
|
|
55
|
+
import { createMessagingStore } from "@agilesyndrome/cf-genai-base/features/messaging";
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
The LLM feature provides OpenAI-compatible generation, typed JSON repair,
|
|
59
|
+
review, model healthchecks, circuit breakers, and durable job integration. The
|
|
60
|
+
`/features/llm` entrypoint exports its complete TypeScript contract, including
|
|
61
|
+
`LLMEnvironment`, client and request options, provider configuration, JSON
|
|
62
|
+
Schema inputs and `InferJSONSchema`, token usage, generation/review inputs,
|
|
63
|
+
job options, loggers, and callbacks. Pass a literal schema with `as const` (or
|
|
64
|
+
`satisfies JSONSchemaInput`) to preserve the generated value type.
|
|
65
|
+
The messaging feature provides conversations, participants, messages, scoped and
|
|
66
|
+
tenant-isolated stores, and durable reply jobs. Construct the store with the
|
|
67
|
+
request-scoped reader, for example `createMessagingStore(env.data.tenant)`. Apply
|
|
68
|
+
`migrations/0007_messaging.sql` when messaging is requested.
|
|
69
|
+
|
|
70
|
+
Features expose `middleware(request, env, ctx, next, state)` and may
|
|
71
|
+
short-circuit routes, attach request state, or call `next()`.
|
|
33
72
|
|
|
34
73
|
Base protects `/admin` and `/api/admin`; the React UI package owns the browser
|
|
35
|
-
pages.
|
|
74
|
+
pages. For a complete single-route UI, import `AdminDashboard` from
|
|
75
|
+
`@agilesyndrome/cf-genai-base/ui` and mount `<AdminDashboard />`, or use
|
|
76
|
+
`mountAdminDashboards` for declarative roots. It includes
|
|
77
|
+
users and access assignments, tenants, user groups, scopes, subscriptions,
|
|
78
|
+
jobs, features, health checks, and circuit breakers with internal list/detail
|
|
79
|
+
navigation. Use `enabledSections` to hide an unavailable optional domain and
|
|
80
|
+
`applicationSections` to add site-owned panels. Import `AdminShell` and the platform catalogs from
|
|
36
81
|
`@agilesyndrome/cf-genai-base/ui`. Sites provide their own application links and
|
|
37
82
|
theme while the base components consume the shared JSON admin APIs.
|
|
38
83
|
|
|
84
|
+
```jsx
|
|
85
|
+
import { AdminDashboard } from "@agilesyndrome/cf-genai-base/ui";
|
|
86
|
+
import "@agilesyndrome/cf-genai-base/ui/styles.css";
|
|
87
|
+
|
|
88
|
+
export function AdminPage() {
|
|
89
|
+
return <AdminDashboard />;
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
|
|
39
93
|
## Command-line tools
|
|
40
94
|
|
|
41
95
|
Install base in a project (or globally) and use the bundled executable:
|
|
@@ -48,21 +102,23 @@ cf-genai check
|
|
|
48
102
|
cf-genai test
|
|
49
103
|
cf-genai ci
|
|
50
104
|
cf-genai dev
|
|
105
|
+
cf-genai storybook
|
|
51
106
|
cf-genai upgrade base latest
|
|
52
107
|
cf-genai release --confirm
|
|
53
108
|
cf-genai release-status --wait 3
|
|
54
109
|
```
|
|
55
110
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
The CLI includes all commands formerly published by
|
|
61
|
-
`@agilesyndrome/cf-genai-cli`: project checks and releases, scoped-data linting,
|
|
62
|
-
package upgrades with migration vendoring, D1 refresh/backup/restore/migration,
|
|
63
|
-
site status, and user, tenant, healthcheck, circuit-breaker, and platform admin
|
|
111
|
+
The CLI includes project checks and releases, scoped-data linting, package
|
|
112
|
+
upgrades with migration vendoring, D1 refresh/backup/restore/migration, site
|
|
113
|
+
status, and user, tenant, healthcheck, circuit-breaker, and platform admin
|
|
64
114
|
operations.
|
|
65
115
|
|
|
116
|
+
In this repository, `npm install` activates the checked-in Git hooks. Each
|
|
117
|
+
commit runs `cf-genai ci`, the same full verification command used by GitHub
|
|
118
|
+
Actions. Verification includes typechecking, source whitespace/unsafe-type
|
|
119
|
+
checks, compilation, unit tests, the example integration suite, export checks,
|
|
120
|
+
and package assembly.
|
|
121
|
+
|
|
66
122
|
```sh
|
|
67
123
|
cf-genai status --env staging
|
|
68
124
|
cf-genai d1 refresh local
|
|
@@ -92,15 +148,17 @@ Cloudflare configuration is incomplete.
|
|
|
92
148
|
## Core operational services
|
|
93
149
|
|
|
94
150
|
The package is organized by responsibility: `runtime` composes Workers,
|
|
95
|
-
`core` owns
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
151
|
+
`core` owns operational primitives, `auth` owns identity and authorization,
|
|
152
|
+
`api` owns route contracts and the browser client, `admin` owns platform
|
|
153
|
+
administration, and `ui` owns shared browser components. Core services have
|
|
154
|
+
focused package entrypoints: `/core/circuits`, `/core/healthchecks`,
|
|
155
|
+
`/core/events`, `/core/jobs`, `/core/database`, and `/core/security`; request
|
|
156
|
+
identity is `/auth/identity`. Prefer these narrow imports when an app needs one
|
|
157
|
+
concern. The root package remains the application-composition surface.
|
|
100
158
|
|
|
101
159
|
Apply `migrations/0002_core.sql` and `migrations/0006_jobs.sql` after the authorization migration. The package exports `registerHealthcheck`, `updateHealthcheck`, `registerCircuitBreaker`, `setCircuitBreaker`, `evaluateCircuitBreaker`, and generic job lifecycle helpers from `/cf-genai-base`. Healthchecks use `red`, `yellow` (unknown/transient), or `green`; breakers use `off`, `tripped`, or `on`, with `any` or `all` healthcheck evaluation. Automated evaluation may only move `on` to `tripped`, or self-healing `tripped` to `on`; admin API writes are the human control plane for the `off` state.
|
|
102
160
|
|
|
103
|
-
Admin APIs are `GET /api/admin/healthchecks`, `PUT /api/admin/healthchecks/:id`, `GET /api/admin/circuit-breakers`, `GET|PUT /api/admin/circuit-breakers/:id`, and `GET /api/admin/features`. React platform components
|
|
161
|
+
Admin APIs are `GET /api/admin/healthchecks`, `GET|PUT /api/admin/healthchecks/:id`, `GET /api/admin/circuit-breakers`, `GET|PUT /api/admin/circuit-breakers/:id`, and `GET /api/admin/features`. Reads require `operations:read`; mutations require `operations:manage`, while platform administrators bypass capability checks. React platform components provide both catalog and detail views. The catalog lists each installed runtime feature, its `packageName` and `version`, its most severe healthcheck state, all feature healthchecks, and its circuit breakers. Use `createD1(env, { who })` for downstream D1 calls; it emits EventLog and AuditLog records with the requesting actor.
|
|
104
162
|
|
|
105
163
|
|
|
106
164
|
## User administration
|
|
@@ -116,11 +174,11 @@ Use the selected D1 target (local by default) to inspect and update users:
|
|
|
116
174
|
cf-genai user get someone.com --target staging
|
|
117
175
|
cf-genai user update someone.com --roles admin --target production
|
|
118
176
|
|
|
119
|
-
`user:get` also reports scopes, groups, and tenant memberships. The shared admin
|
|
177
|
+
`user:get` also reports scopes, groups, and tenant memberships. The shared admin UI provides list and detail views and atomically replaces a user’s complete access assignment through `PUT /api/admin/users/:id/access`; individual relationship endpoints remain available. The admin API also exposes `GET /api/admin/users/:id`, `GET|POST /api/admin/tenants`, and `GET|PUT|PATCH|DELETE /api/admin/tenants/:id`. The default tenant cannot be deleted, and other tenants must first have no users, subscriptions, or messaging conversations. Tenant deletion also requires an `X-Confirm-Delete` header equal to the tenant ID. Production commands should be run through the repository credentials wrapper and reviewed as an administrative change.
|
|
120
178
|
|
|
121
179
|
## Scoped data access
|
|
122
180
|
|
|
123
|
-
|
|
181
|
+
Domains may register D1 resources with `dataResources` and receive the
|
|
124
182
|
scoped reader on the request state as `state.data`. Resources declare `user`,
|
|
125
183
|
`tenant`, `public`, or `system` scope, their physical table, and an explicit column
|
|
126
184
|
allowlist. Use `state.data.tenant`, `state.data.public`, `state.data.user`, or
|
|
@@ -128,7 +186,8 @@ allowlist. Use `state.data.tenant`, `state.data.public`, `state.data.user`, or
|
|
|
128
186
|
the reader applies ownership predicates, supports bounded native pagination via
|
|
129
187
|
page with limit/offset, count, and safe bulk updateWhere/deleteWhere
|
|
130
188
|
operations, and never accepts raw SQL. Resources can explicitly restrict
|
|
131
|
-
their operations to read, create, update, and delete
|
|
189
|
+
their operations to read, create, update, and delete, require capabilities per
|
|
190
|
+
operation with `operationScopes`, and protect columns with `columnScopes`.
|
|
132
191
|
|
|
133
192
|
Anonymous tenant reads require both publicTenantId on createWorker and a
|
|
134
193
|
resource-level publicRead declaration. Use publicRead true only when the
|
|
@@ -138,8 +197,10 @@ system access. A `public` resource is read-only and always predicates on the
|
|
|
138
197
|
worker's `publicTenantId`, including authenticated users; use it for shared
|
|
139
198
|
catalog data such as GTA's `gta-public` tenant.
|
|
140
199
|
|
|
141
|
-
Applications
|
|
142
|
-
own subscription IDs and entitlement values.
|
|
200
|
+
Applications register `new AuthSubscriptionsDomain(manifest)` in
|
|
201
|
+
`defineApp({ domains })` to own their subscription IDs and entitlement values.
|
|
202
|
+
That domain exposes catalog/detail APIs at `/api/admin/subscriptions` and tenant
|
|
203
|
+
assignment at `/api/admin/tenants/:id/subscriptions`. Base also exposes
|
|
143
204
|
requireSubscription and requireEntitlement but does not know any
|
|
144
205
|
product-specific subscription such as VIP. Authenticated users can inspect
|
|
145
206
|
their validated active tenant at GET /api/tenant.
|
|
@@ -149,6 +210,12 @@ POST /api/admin/users/:id/impersonate and clear it with
|
|
|
149
210
|
POST /api/admin/impersonate/clear. Impersonation affects scoped data context
|
|
150
211
|
only and does not grant the target user administrator permissions.
|
|
151
212
|
|
|
213
|
+
The messaging store derives user senders from the scoped reader context and
|
|
214
|
+
limits conversations to their creator, participants, and system actors.
|
|
215
|
+
Creator-only operations manage participants, titles, messages, and deletion.
|
|
216
|
+
Trusted host adapters without an actor context remain responsible for their
|
|
217
|
+
own authorization.
|
|
218
|
+
|
|
152
219
|
For example, a tenant-owned resource registers its `tenant_id` column with
|
|
153
220
|
base, while feature code calls `state.data.tenant.list("recipes")` without
|
|
154
221
|
passing a tenant ID. The active tenant must be a validated membership. A
|
|
@@ -185,9 +252,9 @@ are the shared identity, request, security, and feature-gating contracts.
|
|
|
185
252
|
The layered web surface is React-first: `/api` exports route contracts, scoped
|
|
186
253
|
repositories, the browser `apiFetch`/`apiJson` client, and job/event endpoints;
|
|
187
254
|
`/ui` exports React admin primitives, live event hooks, and durable job
|
|
188
|
-
notifications. Repositories are registered
|
|
189
|
-
`
|
|
190
|
-
|
|
191
|
-
|
|
255
|
+
notifications. Repositories are registered by `AppDomain` instances in
|
|
256
|
+
`defineApp({ domains })` or `feature.domains`; they may declare links to other
|
|
257
|
+
repositories while remaining behind the scoped data reader. `GET /api/jobs`
|
|
258
|
+
and `GET /api/jobs/:id` expose an authenticated
|
|
192
259
|
user's durable job records. `GET /api/events` upgrades to the authenticated live
|
|
193
260
|
event stream when the optional `EVENT_HUB` Durable Object binding is configured.
|
package/bin/cf-genai.js
CHANGED
|
@@ -1,11 +1,27 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
3
|
+
import { existsSync } from "node:fs";
|
|
4
|
+
import { spawnSync } from "node:child_process";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
6
|
+
|
|
7
|
+
// Keep this JavaScript launcher as the npm bin compatibility boundary. Published
|
|
8
|
+
// packages load compiled TypeScript output; source checkouts run the TypeScript
|
|
9
|
+
// entrypoint through the development dependency installed by npm ci/install.
|
|
10
|
+
const builtEntrypoint = new URL("../dist/cli/cli.js", import.meta.url);
|
|
11
|
+
const sourceEntrypoint = new URL("../src/cli/cli.ts", import.meta.url);
|
|
12
|
+
|
|
13
|
+
if (!existsSync(builtEntrypoint)) {
|
|
14
|
+
const sourceRunner = new URL("../scripts/run-cli.mjs", import.meta.url);
|
|
15
|
+
const result = spawnSync(process.execPath, ["--import", "tsx", fileURLToPath(sourceRunner), ...process.argv.slice(2)], { stdio: "inherit" });
|
|
16
|
+
process.exitCode = result.status ?? 1;
|
|
17
|
+
} else {
|
|
18
|
+
const { main } = await import(builtEntrypoint.href);
|
|
19
|
+
|
|
20
|
+
try {
|
|
21
|
+
const result = await main(process.argv.slice(2));
|
|
22
|
+
if (result?.ok === false) process.exitCode = 1;
|
|
23
|
+
} catch (error) {
|
|
24
|
+
console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);
|
|
25
|
+
process.exitCode = 1;
|
|
26
|
+
}
|
|
11
27
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { AdminBindings, AdminIdentity, AdminRequestState, AdminUserProvider } from "./types.js";
|
|
2
|
+
export declare function authenticateAdminRequest<Env extends AdminBindings, User extends AdminIdentity, State extends AdminRequestState<User>>(request: Request, env: Env, url: URL, state: State, provider?: AdminUserProvider<Env, User> | null): Promise<Response | null>;
|
|
3
|
+
export declare function requireSameOriginMutation(request: Request, url: URL): Response | null;
|
|
4
|
+
export declare function actorFor(user: AdminIdentity): string;
|
|
5
|
+
export declare function isPlatformAdministrator(state: AdminRequestState): boolean;
|
|
6
|
+
export declare function isAdminPath(pathname: string): boolean;
|
|
7
|
+
export declare function administratorRequired(url: URL): Response;
|
|
8
|
+
export declare function authenticationRequired(request: Request): Response;
|
|
9
|
+
export declare function oauthAuthenticationRequired(url: URL): Response;
|
|
10
|
+
export declare function safeReturnTo(value: string): string;
|
|
11
|
+
export declare function prepareAdminState<Env extends AdminBindings, User extends AdminIdentity, State extends AdminRequestState<User>>(env: Env, user: User, state: State): Promise<void>;
|
|
12
|
+
//# sourceMappingURL=auth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/admin/auth.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,aAAa,EACb,aAAa,EACb,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,YAAY,CAAC;AAIpB,wBAAsB,wBAAwB,CAC5C,GAAG,SAAS,aAAa,EACzB,IAAI,SAAS,aAAa,EAC1B,KAAK,SAAS,iBAAiB,CAAC,IAAI,CAAC,EAErC,OAAO,EAAE,OAAO,EAChB,GAAG,EAAE,GAAG,EACR,GAAG,EAAE,GAAG,EACR,KAAK,EAAE,KAAK,EACZ,QAAQ,CAAC,EAAE,iBAAiB,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,IAAI,GAC7C,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,CAyB1B;AAED,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,GAAG,QAAQ,GAAG,IAAI,CASrF;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,aAAa,GAAG,MAAM,CAEpD;AAED,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAEzE;AAED,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAErD;AAED,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,GAAG,GAAG,QAAQ,CAIxD;AAED,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,OAAO,GAAG,QAAQ,CAKjE;AAED,wBAAgB,2BAA2B,CAAC,GAAG,EAAE,GAAG,GAAG,QAAQ,CAG9D;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAElD;AA2BD,wBAAsB,iBAAiB,CACrC,GAAG,SAAS,aAAa,EACzB,IAAI,SAAS,aAAa,EAC1B,KAAK,SAAS,iBAAiB,CAAC,IAAI,CAAC,EACrC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,CAInD"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { ensureUser } from "../auth/index.js";
|
|
2
|
+
import { requestActor } from "../auth/identity/index.js";
|
|
3
|
+
import { jsonError, NO_STORE_HEADERS } from "../api/http.js";
|
|
4
|
+
const MUTATING_METHODS = new Set(["POST", "PUT", "PATCH", "DELETE"]);
|
|
5
|
+
export async function authenticateAdminRequest(request, env, url, state, provider) {
|
|
6
|
+
const strategy = String(env.AUTH_STRATEGY ?? "http_basic").trim().toLowerCase();
|
|
7
|
+
if (strategy === "http_basic") {
|
|
8
|
+
const user = basicUser(request, env);
|
|
9
|
+
if (!user)
|
|
10
|
+
return authenticationRequired(request);
|
|
11
|
+
state.user = user;
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
if (strategy === "oauth") {
|
|
15
|
+
const user = Object.hasOwn(state, "user")
|
|
16
|
+
? state.user
|
|
17
|
+
: provider
|
|
18
|
+
? await provider.getUser(request, env)
|
|
19
|
+
: null;
|
|
20
|
+
if (!user)
|
|
21
|
+
return oauthAuthenticationRequired(url);
|
|
22
|
+
state.user = user;
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
return new Response("Unsupported AUTH_STRATEGY", {
|
|
26
|
+
status: 500,
|
|
27
|
+
headers: NO_STORE_HEADERS,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
export function requireSameOriginMutation(request, url) {
|
|
31
|
+
if (!MUTATING_METHODS.has(request.method) || !url.pathname.startsWith("/api/"))
|
|
32
|
+
return null;
|
|
33
|
+
const origin = request.headers.get("Origin");
|
|
34
|
+
try {
|
|
35
|
+
if (origin && new URL(origin).origin === url.origin)
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
// A malformed Origin is untrusted just like a cross-origin value.
|
|
40
|
+
}
|
|
41
|
+
return jsonError("A same-origin request is required.", 403);
|
|
42
|
+
}
|
|
43
|
+
export function actorFor(user) {
|
|
44
|
+
return user.auth_strategy === "http_basic" ? "user:admin" : `user:${user.sub || "unknown"}`;
|
|
45
|
+
}
|
|
46
|
+
export function isPlatformAdministrator(state) {
|
|
47
|
+
return state.user?.auth_strategy === "http_basic" || Boolean(state.authUser?.is_admin);
|
|
48
|
+
}
|
|
49
|
+
export function isAdminPath(pathname) {
|
|
50
|
+
return pathname === "/admin" || pathname.startsWith("/admin/") || pathname === "/api/admin" || pathname.startsWith("/api/admin/");
|
|
51
|
+
}
|
|
52
|
+
export function administratorRequired(url) {
|
|
53
|
+
return url.pathname.startsWith("/api/")
|
|
54
|
+
? jsonError("Administrator access is required.", 403)
|
|
55
|
+
: new Response("Administrator access is required.", { status: 403, headers: NO_STORE_HEADERS });
|
|
56
|
+
}
|
|
57
|
+
export function authenticationRequired(request) {
|
|
58
|
+
const headers = { ...NO_STORE_HEADERS, "WWW-Authenticate": 'Basic realm="admin", charset="UTF-8"' };
|
|
59
|
+
return new URL(request.url).pathname.startsWith("/api/")
|
|
60
|
+
? Response.json({ error: "Authentication is required." }, { status: 401, headers })
|
|
61
|
+
: new Response("Authentication is required.", { status: 401, headers });
|
|
62
|
+
}
|
|
63
|
+
export function oauthAuthenticationRequired(url) {
|
|
64
|
+
if (url.pathname.startsWith("/api/"))
|
|
65
|
+
return jsonError("Authentication is required.", 401);
|
|
66
|
+
return Response.redirect(`${url.origin}/auth/login?return_to=${encodeURIComponent(safeReturnTo(url.pathname + url.search))}`, 302);
|
|
67
|
+
}
|
|
68
|
+
export function safeReturnTo(value) {
|
|
69
|
+
return value.startsWith("/") && !value.startsWith("//") && !value.startsWith("/auth/") ? value : "/";
|
|
70
|
+
}
|
|
71
|
+
function basicUser(request, env) {
|
|
72
|
+
const token = String(env.ADMIN_TOKEN ?? "");
|
|
73
|
+
if (!token)
|
|
74
|
+
return null;
|
|
75
|
+
const header = request.headers.get("Authorization") ?? "";
|
|
76
|
+
if (!header.toLowerCase().startsWith("basic "))
|
|
77
|
+
return null;
|
|
78
|
+
let decoded;
|
|
79
|
+
try {
|
|
80
|
+
decoded = atob(header.slice(6).trim());
|
|
81
|
+
}
|
|
82
|
+
catch {
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
const separator = decoded.indexOf(":");
|
|
86
|
+
if (separator < 0 || !constantTimeEqual(decoded.slice(0, separator), "admin") || !constantTimeEqual(decoded.slice(separator + 1), token))
|
|
87
|
+
return null;
|
|
88
|
+
return { sub: "basic:admin", email: "", name: "admin", roles: ["admin"], auth_strategy: "http_basic" };
|
|
89
|
+
}
|
|
90
|
+
function constantTimeEqual(a, b) {
|
|
91
|
+
const aa = new TextEncoder().encode(a);
|
|
92
|
+
const bb = new TextEncoder().encode(b);
|
|
93
|
+
let difference = aa.length ^ bb.length;
|
|
94
|
+
for (let index = 0; index < Math.max(aa.length, bb.length); index += 1)
|
|
95
|
+
difference |= (aa[index] ?? 0) ^ (bb[index] ?? 0);
|
|
96
|
+
return difference === 0;
|
|
97
|
+
}
|
|
98
|
+
export async function prepareAdminState(env, user, state) {
|
|
99
|
+
const actor = actorFor(user);
|
|
100
|
+
state.authUser = user.authUser ?? (await ensureUser(env, user, { who: actor }));
|
|
101
|
+
state.requestedBy = requestActor(state);
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=auth.js.map
|