@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
|
@@ -0,0 +1,738 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, readFileSync, readdirSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { createHash } from "node:crypto";
|
|
3
|
+
import { spawnSync } from "node:child_process";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
import { migrateD1, shellCommand } from "./d1.js";
|
|
6
|
+
import { compareVersions } from "./version.js";
|
|
7
|
+
const packagePath = "package.json";
|
|
8
|
+
const basePackageName = "@agilesyndrome/cf-genai-base";
|
|
9
|
+
const upgradePackages = Object.freeze({
|
|
10
|
+
base: basePackageName,
|
|
11
|
+
auth: "@agilesyndrome/cf-genai-auth",
|
|
12
|
+
});
|
|
13
|
+
const npmRegistry = "https://registry.npmjs.org";
|
|
14
|
+
const releaseStatusCommandTimeout = 10_000;
|
|
15
|
+
const DATA_ACCESS_EXTENSIONS = new Set([".js", ".mjs", ".cjs", ".ts", ".tsx", ".jsx"]);
|
|
16
|
+
const DATA_ACCESS_DIRECT = /\b(?:env|environment)\s*\.\s*DB\s*\.\s*prepare\s*\(|\bDB\s*\.\s*prepare\s*\(/;
|
|
17
|
+
function run(command, args, { inherit = true, failOnError = true, timeout, env } = {}) {
|
|
18
|
+
const result = spawnSync(command, args, {
|
|
19
|
+
stdio: inherit ? "inherit" : ["ignore", "pipe", "pipe"],
|
|
20
|
+
encoding: "utf8",
|
|
21
|
+
...(timeout === undefined ? {} : { timeout }),
|
|
22
|
+
...(env === undefined ? {} : { env }),
|
|
23
|
+
});
|
|
24
|
+
if (result.error && failOnError)
|
|
25
|
+
throw result.error;
|
|
26
|
+
if (result.status !== 0 && failOnError)
|
|
27
|
+
process.exitCode = result.status || 1;
|
|
28
|
+
return result;
|
|
29
|
+
}
|
|
30
|
+
function packageJson() {
|
|
31
|
+
if (!existsSync(packagePath))
|
|
32
|
+
throw new Error("package.json was not found in the current directory.");
|
|
33
|
+
return parsePackageMetadata(readFileSync(packagePath, "utf8"));
|
|
34
|
+
}
|
|
35
|
+
function packageMigrations(packageName, cwd = process.cwd()) {
|
|
36
|
+
const directory = join(cwd, "node_modules", ...packageName.split("/"), "migrations");
|
|
37
|
+
if (!existsSync(directory))
|
|
38
|
+
return [];
|
|
39
|
+
return readdirSync(directory).filter((name) => /^\d+_.+\.sql$/.test(name)).sort().map((name) => ({ name, path: join(directory, name), sql: readFileSync(join(directory, name), "utf8") }));
|
|
40
|
+
}
|
|
41
|
+
function migrationHash(sql) { return createHash("sha256").update(sql).digest("hex").slice(0, 12); }
|
|
42
|
+
export function vendorPackageMigrations({ packageName = basePackageName, version, cwd = process.cwd() } = {}) {
|
|
43
|
+
const destination = join(cwd, "migrations");
|
|
44
|
+
if (!existsSync(destination))
|
|
45
|
+
mkdirSync(destination, { recursive: true });
|
|
46
|
+
const sources = packageMigrations(packageName, cwd);
|
|
47
|
+
if (!sources.length)
|
|
48
|
+
return { packageName, version, added: [], skipped: [] };
|
|
49
|
+
const existing = readdirSync(destination).filter((name) => /^\d+_.+\.sql$/.test(name));
|
|
50
|
+
const used = new Set(existing);
|
|
51
|
+
const sourceText = existing.map((name) => readFileSync(join(destination, name), "utf8")).join("\n");
|
|
52
|
+
let next = Math.max(0, ...existing.map((name) => Number(name.match(/^\d+/)?.[0] || 0))) + 1;
|
|
53
|
+
const added = [];
|
|
54
|
+
const skipped = [];
|
|
55
|
+
for (const source of sources) {
|
|
56
|
+
const marker = `cf-genai-source: ${packageName}/${source.name}`;
|
|
57
|
+
if (sourceText.includes(marker)) {
|
|
58
|
+
skipped.push(source.name);
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
let target;
|
|
62
|
+
const packageSuffix = packageName.split("/").at(-1) || "package";
|
|
63
|
+
do {
|
|
64
|
+
target = `${String(next++).padStart(4, "0")}_${packageSuffix.replaceAll("-", "_")}_${source.name.replace(/^\d+_/, "")}`;
|
|
65
|
+
} while (used.has(target));
|
|
66
|
+
const content = `-- ${marker}@${version || "installed"} sha256:${migrationHash(source.sql)}\n${source.sql.trim()}\n`;
|
|
67
|
+
writeFileSync(join(destination, target), content);
|
|
68
|
+
used.add(target);
|
|
69
|
+
added.push(target);
|
|
70
|
+
}
|
|
71
|
+
return { packageName, version, added, skipped };
|
|
72
|
+
}
|
|
73
|
+
export function upgradePackageName(value) {
|
|
74
|
+
const key = String(value || "");
|
|
75
|
+
const target = key === "base" || key === "auth" ? upgradePackages[key] : undefined;
|
|
76
|
+
if (!target)
|
|
77
|
+
throw new Error(`Unknown cf-genai package: ${value || "missing"}. Use base or auth.`);
|
|
78
|
+
return target;
|
|
79
|
+
}
|
|
80
|
+
function upgradePackage(args = []) {
|
|
81
|
+
const target = upgradePackageName(args[0]);
|
|
82
|
+
const requested = args[1] || "latest";
|
|
83
|
+
if (args.length > 2)
|
|
84
|
+
throw new Error("Upgrade accepts one package and version: cf-genai upgrade <base|auth> <latest|VERSION>.");
|
|
85
|
+
const result = run("npm", ["install", `${target}@${requested}`], { failOnError: false });
|
|
86
|
+
if (result.status !== 0)
|
|
87
|
+
throw new Error("npm install failed; no package migrations were copied.");
|
|
88
|
+
const installed = packageJson().dependencies?.[target] || packageJson().devDependencies?.[target] || requested;
|
|
89
|
+
const migrationResult = vendorPackageMigrations({ packageName: target, version: installed });
|
|
90
|
+
console.log(`Upgraded ${target} to ${installed}.`);
|
|
91
|
+
console.log(`Package migrations added: ${migrationResult.added.length}; already vendored: ${migrationResult.skipped.length}.`);
|
|
92
|
+
for (const name of migrationResult.added)
|
|
93
|
+
console.log(` + migrations/${name}`);
|
|
94
|
+
return migrationResult;
|
|
95
|
+
}
|
|
96
|
+
function packageDependency(packageMetadata, name) {
|
|
97
|
+
const sections = ["dependencies", "devDependencies", "peerDependencies", "optionalDependencies"];
|
|
98
|
+
return sections
|
|
99
|
+
.map((section) => packageMetadata[section]?.[name])
|
|
100
|
+
.find((value) => value !== undefined) || null;
|
|
101
|
+
}
|
|
102
|
+
export function baseDependencyVersion(packageMetadata = {}) {
|
|
103
|
+
if (packageMetadata.name === basePackageName)
|
|
104
|
+
return packageMetadata.version || null;
|
|
105
|
+
const spec = packageDependency(packageMetadata, basePackageName);
|
|
106
|
+
if (!spec)
|
|
107
|
+
return null;
|
|
108
|
+
const match = String(spec).match(/\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?/);
|
|
109
|
+
return match ? match[0] : null;
|
|
110
|
+
}
|
|
111
|
+
function isCfGenaiProject(cwd) {
|
|
112
|
+
if (!existsSync(join(cwd, packagePath)))
|
|
113
|
+
return false;
|
|
114
|
+
const pkg = parsePackageMetadata(readFileSync(join(cwd, packagePath), "utf8"));
|
|
115
|
+
const name = pkg.name || "";
|
|
116
|
+
if (name === "@agilesyndrome/cf-genai-base")
|
|
117
|
+
return false;
|
|
118
|
+
const dependencies = { ...(pkg.dependencies || {}), ...(pkg.devDependencies || {}), ...(pkg.peerDependencies || {}) };
|
|
119
|
+
return name.startsWith("@agilesyndrome/cf-genai-") || name.startsWith("cf-genai-") || Boolean(dependencies["@agilesyndrome/cf-genai-base"]);
|
|
120
|
+
}
|
|
121
|
+
function sourceFiles(directory, files = []) {
|
|
122
|
+
if (!existsSync(directory))
|
|
123
|
+
return files;
|
|
124
|
+
for (const entry of readdirSync(directory, { withFileTypes: true })) {
|
|
125
|
+
if (["node_modules", ".git", ".wrangler", "dist", "coverage"].includes(entry.name))
|
|
126
|
+
continue;
|
|
127
|
+
const path = join(directory, entry.name);
|
|
128
|
+
if (entry.isDirectory())
|
|
129
|
+
sourceFiles(path, files);
|
|
130
|
+
else if (DATA_ACCESS_EXTENSIONS.has(path.slice(path.lastIndexOf("."))))
|
|
131
|
+
files.push(path);
|
|
132
|
+
}
|
|
133
|
+
return files;
|
|
134
|
+
}
|
|
135
|
+
export function dataAccessLint({ cwd = process.cwd() } = {}) {
|
|
136
|
+
if (!isCfGenaiProject(cwd))
|
|
137
|
+
return { skipped: true, violations: [] };
|
|
138
|
+
const roots = ["src", "app", "apps", "functions", "workers", "server"].map((root) => join(cwd, root)).filter((root) => existsSync(root));
|
|
139
|
+
const files = (roots.length ? roots : [cwd]).flatMap((root) => sourceFiles(root));
|
|
140
|
+
const violations = files
|
|
141
|
+
.filter((path) => !path.split(/[\\/]/).includes("tests"))
|
|
142
|
+
.flatMap((path) => String(readFileSync(path, "utf8")).split(/\r?\n/).flatMap((line, index) => DATA_ACCESS_DIRECT.test(line) ? [{ path, line: index + 1, text: line.trim() }] : []));
|
|
143
|
+
if (violations.length) {
|
|
144
|
+
const details = violations.map((item) => ` ${item.path}:${item.line}: ${item.text}`).join("\n");
|
|
145
|
+
throw new Error(`Direct D1 access is not allowed in cf-genai domain source. Use state.data scoped readers instead.\n${details}`);
|
|
146
|
+
}
|
|
147
|
+
return { skipped: false, violations };
|
|
148
|
+
}
|
|
149
|
+
function packageName() {
|
|
150
|
+
return packageJson().name || "package";
|
|
151
|
+
}
|
|
152
|
+
function version() {
|
|
153
|
+
const value = packageJson().version;
|
|
154
|
+
if (!value)
|
|
155
|
+
throw new Error("package.json does not contain a version.");
|
|
156
|
+
return value;
|
|
157
|
+
}
|
|
158
|
+
function assertClean() {
|
|
159
|
+
const result = run("git", ["status", "--porcelain"], { inherit: false });
|
|
160
|
+
if (result.status !== 0)
|
|
161
|
+
throw new Error("Unable to inspect git status.");
|
|
162
|
+
if (result.stdout.trim())
|
|
163
|
+
throw new Error("Working tree must be clean before a release.");
|
|
164
|
+
}
|
|
165
|
+
function output(command, args) {
|
|
166
|
+
const result = run(command, args, { inherit: false, failOnError: false });
|
|
167
|
+
if (result.status !== 0)
|
|
168
|
+
throw new Error(`${command} ${args.join(" ")} failed.`);
|
|
169
|
+
return result.stdout.trim();
|
|
170
|
+
}
|
|
171
|
+
function assertMainIsSynchronized() {
|
|
172
|
+
const branch = output("git", ["branch", "--show-current"]);
|
|
173
|
+
if (branch !== "main")
|
|
174
|
+
throw new Error(`Releases must run from main (currently on ${branch || "detached HEAD"}).`);
|
|
175
|
+
const fetched = run("git", ["fetch", "origin", "main", "--tags"]);
|
|
176
|
+
if (fetched.status !== 0)
|
|
177
|
+
throw new Error("Unable to fetch origin/main; release stopped before changing anything.");
|
|
178
|
+
const local = output("git", ["rev-parse", "main"]);
|
|
179
|
+
const remote = output("git", ["rev-parse", "origin/main"]);
|
|
180
|
+
if (local !== remote)
|
|
181
|
+
throw new Error("Local main does not match origin/main; push or reconcile it before releasing.");
|
|
182
|
+
}
|
|
183
|
+
function assertFlag(args, flag, message) {
|
|
184
|
+
if (!args.includes(flag))
|
|
185
|
+
throw new Error(`${message} Re-run with ${flag}.`);
|
|
186
|
+
}
|
|
187
|
+
function npmVersion(name, currentVersion) {
|
|
188
|
+
const result = run("npm", ["view", `${name}@${currentVersion}`, "version"], { inherit: false, failOnError: false });
|
|
189
|
+
return result.status === 0 ? result.stdout.trim() : "";
|
|
190
|
+
}
|
|
191
|
+
function npmLatestVersion(name) {
|
|
192
|
+
const result = run("npm", ["view", name, "version", "--json", "--registry", npmRegistry], { inherit: false, failOnError: false });
|
|
193
|
+
if (result.status !== 0) {
|
|
194
|
+
if (/E404|not found/i.test(`${result.stdout}\n${result.stderr}`))
|
|
195
|
+
return null;
|
|
196
|
+
throw new Error(`Unable to verify the latest published version of ${name}.`);
|
|
197
|
+
}
|
|
198
|
+
let published = result.stdout.trim();
|
|
199
|
+
try {
|
|
200
|
+
published = JSON.parse(result.stdout.trim());
|
|
201
|
+
}
|
|
202
|
+
catch { /* npm may return an unquoted version */ }
|
|
203
|
+
return typeof published === "string" && published ? published : null;
|
|
204
|
+
}
|
|
205
|
+
export function isPreparedReleaseVersion(currentVersion, latestPublishedVersion, currentTagExists) {
|
|
206
|
+
return !currentTagExists && latestPublishedVersion !== null && compareVersions(currentVersion, latestPublishedVersion) > 0;
|
|
207
|
+
}
|
|
208
|
+
function npmVersionState(name, requestedVersion) {
|
|
209
|
+
const result = run("npm", ["view", `${name}@${requestedVersion}`, "version", "--json", "--registry", npmRegistry], { inherit: false, failOnError: false });
|
|
210
|
+
if (result.status === 0) {
|
|
211
|
+
let published = result.stdout.trim();
|
|
212
|
+
try {
|
|
213
|
+
published = JSON.parse(result.stdout.trim());
|
|
214
|
+
}
|
|
215
|
+
catch { /* npm may return an unquoted version */ }
|
|
216
|
+
const publishedVersion = typeof published === "string" ? published : null;
|
|
217
|
+
return { exists: publishedVersion === requestedVersion, version: publishedVersion };
|
|
218
|
+
}
|
|
219
|
+
if (/E404|not found/i.test(`${result.stdout}\n${result.stderr}`))
|
|
220
|
+
return { exists: false, version: null };
|
|
221
|
+
throw new Error(`Unable to verify whether ${name}@${requestedVersion} is published.`);
|
|
222
|
+
}
|
|
223
|
+
function npmPackageExists(name) {
|
|
224
|
+
const result = run("npm", ["view", name, "name", "--json", "--registry", npmRegistry], { inherit: false, failOnError: false });
|
|
225
|
+
if (result.status === 0)
|
|
226
|
+
return Boolean(result.stdout.trim());
|
|
227
|
+
if (/E404|not found/i.test(`${result.stdout}\n${result.stderr}`))
|
|
228
|
+
return false;
|
|
229
|
+
throw new Error(`Unable to verify whether ${name} exists on npm.`);
|
|
230
|
+
}
|
|
231
|
+
export function normalizeReleaseVersion(value) {
|
|
232
|
+
const match = String(value || "").trim().match(/^(\d+)\.(\d+)$/);
|
|
233
|
+
if (!match)
|
|
234
|
+
throw new Error("--version must be a major.minor version such as 4.1; patch is assigned as .0.");
|
|
235
|
+
return `${Number(match[1])}.${Number(match[2])}.0`;
|
|
236
|
+
}
|
|
237
|
+
export function requestedReleaseAction(currentVersion, requestedVersion) {
|
|
238
|
+
const comparison = compareVersions(requestedVersion, currentVersion);
|
|
239
|
+
if (comparison < 0)
|
|
240
|
+
throw new Error(`Requested version ${requestedVersion} must not be older than the current version ${currentVersion}.`);
|
|
241
|
+
return { version: requestedVersion, bump: comparison > 0 };
|
|
242
|
+
}
|
|
243
|
+
/** Select the reusable prerelease version for a release. */
|
|
244
|
+
export function preReleaseAction(currentVersion, prePublished = false) {
|
|
245
|
+
const existing = currentVersion.match(/^(\d+)\.(\d+)\.(\d+)-pre(?:\.(\d+))?$/);
|
|
246
|
+
if (existing) {
|
|
247
|
+
const next = Number(existing[4] || 0) + 1;
|
|
248
|
+
return { version: `${existing[1]}.${existing[2]}.${existing[3]}-pre.${next}`, bump: true };
|
|
249
|
+
}
|
|
250
|
+
if (prePublished)
|
|
251
|
+
return { version: `${currentVersion}-pre.1`, bump: true };
|
|
252
|
+
const match = currentVersion.match(/^(\d+)\.(\d+)\.(\d+)$/);
|
|
253
|
+
if (!match)
|
|
254
|
+
throw new Error(`Cannot create a prerelease from ${currentVersion}.`);
|
|
255
|
+
return { version: `${Number(match[1])}.${Number(match[2])}.${Number(match[3]) + 1}-pre.0`, bump: true };
|
|
256
|
+
}
|
|
257
|
+
function requestedReleaseVersion(args = []) {
|
|
258
|
+
const index = args.findIndex((arg) => arg === "--version" || arg.startsWith("--version="));
|
|
259
|
+
if (index < 0)
|
|
260
|
+
return null;
|
|
261
|
+
const raw = args[index].includes("=") ? args[index].split("=", 2)[1] : args[index + 1];
|
|
262
|
+
if (raw === undefined || raw.startsWith("--"))
|
|
263
|
+
throw new Error("--version requires a major.minor value.");
|
|
264
|
+
return normalizeReleaseVersion(raw);
|
|
265
|
+
}
|
|
266
|
+
function packageScope(name) {
|
|
267
|
+
return name.startsWith("@") ? name.split("/", 1)[0] : "";
|
|
268
|
+
}
|
|
269
|
+
export function isNpmAuthenticationFailure(output = "") {
|
|
270
|
+
return /\b(?:E401|ENEEDAUTH)\b|401\s+Unauthorized|auth(?:entication|entication token)?[^\n]*(?:required|invalid|expired)|not logged in|must be logged in/i.test(output);
|
|
271
|
+
}
|
|
272
|
+
function ensureNpmLogin(name) {
|
|
273
|
+
console.log("Checking npm authentication for " + name + "...");
|
|
274
|
+
const whoami = run("npm", ["whoami", "--registry", npmRegistry], { inherit: false, failOnError: false });
|
|
275
|
+
if (whoami.status === 0 && whoami.stdout.trim()) {
|
|
276
|
+
console.log("npm authentication OK (" + whoami.stdout.trim() + ").");
|
|
277
|
+
return;
|
|
278
|
+
}
|
|
279
|
+
const failure = whoami.stdout + "\n" + whoami.stderr;
|
|
280
|
+
if (!isNpmAuthenticationFailure(failure)) {
|
|
281
|
+
throw new Error("Unable to verify npm authentication. Check " + npmRegistry + " and try again.");
|
|
282
|
+
}
|
|
283
|
+
const scope = packageScope(name);
|
|
284
|
+
console.log("npm authentication is missing or invalid; starting npm login...");
|
|
285
|
+
const loginArgs = ["login", "--registry", npmRegistry];
|
|
286
|
+
if (scope)
|
|
287
|
+
loginArgs.push("--scope", scope);
|
|
288
|
+
const login = run("npm", loginArgs, { failOnError: false });
|
|
289
|
+
if (login.status !== 0)
|
|
290
|
+
throw new Error("npm login failed or was cancelled. Re-run the release after logging in.");
|
|
291
|
+
const verified = run("npm", ["whoami", "--registry", npmRegistry], { inherit: false, failOnError: false });
|
|
292
|
+
if (verified.status !== 0 || !verified.stdout.trim()) {
|
|
293
|
+
throw new Error("npm login completed, but npm authentication could not be verified. Run npm whoami and try again.");
|
|
294
|
+
}
|
|
295
|
+
console.log("npm authentication OK (" + verified.stdout.trim() + ").");
|
|
296
|
+
}
|
|
297
|
+
function tagExists(tag) {
|
|
298
|
+
const local = run("git", ["tag", "--list", tag], { inherit: false, failOnError: false });
|
|
299
|
+
if (local.status === 0 && local.stdout.trim())
|
|
300
|
+
return true;
|
|
301
|
+
const remote = run("git", ["ls-remote", "--tags", "origin", `refs/tags/${tag}`], { inherit: false, failOnError: false });
|
|
302
|
+
return remote.status === 0 && Boolean(remote.stdout.trim());
|
|
303
|
+
}
|
|
304
|
+
function remoteRepository() {
|
|
305
|
+
const remote = output("git", ["remote", "get-url", "origin"]);
|
|
306
|
+
const match = remote.match(/github\.com[/:]([^/]+)\/([^/]+?)(?:\.git)?$/i);
|
|
307
|
+
if (!match)
|
|
308
|
+
throw new Error("origin does not point to a GitHub repository.");
|
|
309
|
+
return `${match[1]}/${match[2]}`;
|
|
310
|
+
}
|
|
311
|
+
function addNpmTrust(name) {
|
|
312
|
+
const workflow = ".github/workflows/publish.yml";
|
|
313
|
+
if (!existsSync(workflow))
|
|
314
|
+
throw new Error(`Cannot configure npm trust: ${workflow} was not found.`);
|
|
315
|
+
const npmVersionResult = run("npm", ["--version"], { inherit: false, failOnError: false });
|
|
316
|
+
const npmVersionOutput = npmVersionResult.stdout?.trim() || "";
|
|
317
|
+
if (npmVersionResult.status !== 0 || compareVersions(npmVersionOutput, "11.15.0") < 0) {
|
|
318
|
+
throw new Error(`npm trust requires npm 11.15.0 or newer (found ${npmVersionOutput || "unknown"}).`);
|
|
319
|
+
}
|
|
320
|
+
const trust = run("npm", [
|
|
321
|
+
"trust", "github", name,
|
|
322
|
+
"--file", "publish.yml",
|
|
323
|
+
"--repo", remoteRepository(),
|
|
324
|
+
"--allow-publish",
|
|
325
|
+
"--yes",
|
|
326
|
+
"--registry", npmRegistry,
|
|
327
|
+
], { failOnError: false });
|
|
328
|
+
if (trust.status !== 0) {
|
|
329
|
+
throw new Error("Unable to configure npm Trusted Publishing. Confirm that the package exists, your npm account has 2FA enabled, and you have package write access.");
|
|
330
|
+
}
|
|
331
|
+
return trust;
|
|
332
|
+
}
|
|
333
|
+
export function releaseWaitMinutes(args = []) {
|
|
334
|
+
const index = args.findIndex((arg) => arg === "--wait" || arg.startsWith("--wait="));
|
|
335
|
+
if (index < 0)
|
|
336
|
+
return 5;
|
|
337
|
+
const raw = args[index].includes("=") ? args[index].split("=", 2)[1] : args[index + 1];
|
|
338
|
+
if (raw === undefined || raw.startsWith("--"))
|
|
339
|
+
throw new Error("--wait requires a number of minutes.");
|
|
340
|
+
const minutes = Number(raw);
|
|
341
|
+
if (!Number.isFinite(minutes) || minutes < 0)
|
|
342
|
+
throw new Error("--wait must be a non-negative number of minutes.");
|
|
343
|
+
return minutes;
|
|
344
|
+
}
|
|
345
|
+
export function releaseStatusShouldContinue(checks, now, deadline) {
|
|
346
|
+
if (now >= deadline)
|
|
347
|
+
return false;
|
|
348
|
+
if (checks.github_actions.state === "failed")
|
|
349
|
+
return false;
|
|
350
|
+
if (checks.github_actions.state === "unavailable")
|
|
351
|
+
return !["published", "unavailable"].includes(checks.npm.state);
|
|
352
|
+
return !(checks.github_actions.state === "passed" && checks.npm.state === "published");
|
|
353
|
+
}
|
|
354
|
+
export function releaseStatusDot(state, ready = false) {
|
|
355
|
+
if (ready || ["clean", "yes", "present and correct", "passed", "published", "ready"].includes(state))
|
|
356
|
+
return "🟢";
|
|
357
|
+
if (["dirty", "no", "missing or incorrect", "failed", "unavailable", "not ready"].includes(state))
|
|
358
|
+
return "🔴";
|
|
359
|
+
return "🟡";
|
|
360
|
+
}
|
|
361
|
+
function releaseTagState(tag) {
|
|
362
|
+
const local = run("git", ["rev-parse", `refs/tags/${tag}`], { inherit: false, failOnError: false });
|
|
363
|
+
// Do not allow Git to wait for credentials in non-interactive images or CI.
|
|
364
|
+
// A remote/network failure is a status result, not a reason to block the CLI.
|
|
365
|
+
const remote = run("git", ["ls-remote", "origin", `refs/tags/${tag}`], {
|
|
366
|
+
inherit: false,
|
|
367
|
+
failOnError: false,
|
|
368
|
+
timeout: releaseStatusCommandTimeout,
|
|
369
|
+
env: { ...process.env, GIT_TERMINAL_PROMPT: "0" },
|
|
370
|
+
});
|
|
371
|
+
const localSha = local.status === 0 ? local.stdout.trim() : "";
|
|
372
|
+
const remoteSha = remote.status === 0 ? remote.stdout.trim().split(/\s+/)[0] : "";
|
|
373
|
+
return { present: Boolean(localSha && remoteSha), local_sha: localSha || null, remote_sha: remoteSha || null, matches: Boolean(localSha && remoteSha && localSha === remoteSha) };
|
|
374
|
+
}
|
|
375
|
+
function gitReleaseState() {
|
|
376
|
+
const clean = run("git", ["status", "--porcelain"], { inherit: false, failOnError: false });
|
|
377
|
+
const branch = run("git", ["branch", "--show-current"], { inherit: false, failOnError: false });
|
|
378
|
+
const head = run("git", ["rev-parse", "HEAD"], { inherit: false, failOnError: false });
|
|
379
|
+
const upstream = run("git", ["rev-parse", "--abbrev-ref", "--symbolic-full-name", "@{u}"], { inherit: false, failOnError: false });
|
|
380
|
+
const upstreamHead = upstream.status === 0 ? run("git", ["rev-parse", upstream.stdout.trim()], { inherit: false, failOnError: false }) : null;
|
|
381
|
+
const headSha = head.status === 0 ? head.stdout.trim() : "";
|
|
382
|
+
const remoteSha = upstreamHead?.status === 0 ? upstreamHead.stdout.trim() : "";
|
|
383
|
+
return { clean: clean.status === 0 && !clean.stdout.trim(), branch: branch.status === 0 ? branch.stdout.trim() : null, pushed: Boolean(headSha && remoteSha && headSha === remoteSha), head_sha: headSha || null, remote_sha: remoteSha || null };
|
|
384
|
+
}
|
|
385
|
+
function githubActionsState(repository, commit, timeout) {
|
|
386
|
+
const result = run("gh", ["run", "list", "--repo", repository, "--workflow", "publish.yml", "--commit", commit, "--limit", "100", "--json", "status,conclusion,databaseId,displayTitle,workflowName,url,headSha"], { inherit: false, failOnError: false, timeout });
|
|
387
|
+
if (result.status !== 0)
|
|
388
|
+
return { state: "unavailable", runs: [], error: (result.stderr || result.stdout || "GitHub Actions could not be queried.").trim() };
|
|
389
|
+
let parsed;
|
|
390
|
+
try {
|
|
391
|
+
parsed = JSON.parse(result.stdout || "[]");
|
|
392
|
+
}
|
|
393
|
+
catch {
|
|
394
|
+
return { state: "unavailable", runs: [], error: "GitHub Actions returned invalid JSON." };
|
|
395
|
+
}
|
|
396
|
+
if (!Array.isArray(parsed))
|
|
397
|
+
return { state: "unavailable", runs: [], error: "GitHub Actions returned invalid JSON." };
|
|
398
|
+
const runs = parsed.filter(isGithubRun);
|
|
399
|
+
if (!runs.length)
|
|
400
|
+
return { state: "pending", runs: [] };
|
|
401
|
+
const failed = runs.filter((item) => item.status === "completed" && item.conclusion !== "success");
|
|
402
|
+
const running = runs.filter((item) => item.status !== "completed");
|
|
403
|
+
return { state: failed.length ? "failed" : running.length ? "running" : "passed", runs };
|
|
404
|
+
}
|
|
405
|
+
function npmReleaseState(name, currentVersion, timeout) {
|
|
406
|
+
const result = run("npm", ["view", `${name}@${currentVersion}`, "version", "--json", "--registry", npmRegistry], { inherit: false, failOnError: false, timeout });
|
|
407
|
+
if (result.status === 0) {
|
|
408
|
+
let published = result.stdout.trim();
|
|
409
|
+
try {
|
|
410
|
+
published = JSON.parse(result.stdout.trim());
|
|
411
|
+
}
|
|
412
|
+
catch { /* npm may return an unquoted version */ }
|
|
413
|
+
const publishedVersion = typeof published === "string" ? published : null;
|
|
414
|
+
return { state: publishedVersion === currentVersion ? "published" : "not_published", version: publishedVersion };
|
|
415
|
+
}
|
|
416
|
+
return { state: /E404|not found/i.test(`${result.stdout}\n${result.stderr}`) ? "not_published" : "unavailable", version: null, error: (result.stderr || result.stdout || "npm could not be queried.").trim() };
|
|
417
|
+
}
|
|
418
|
+
function baseReleaseState(packageMetadata, timeout) {
|
|
419
|
+
const configured = baseDependencyVersion(packageMetadata);
|
|
420
|
+
const spec = packageMetadata.name === basePackageName ? packageMetadata.version : packageDependency(packageMetadata, basePackageName);
|
|
421
|
+
if (!spec)
|
|
422
|
+
return { state: "not_declared", version: null, latest: null };
|
|
423
|
+
if (!configured)
|
|
424
|
+
return { state: "unavailable", version: null, latest: null, spec, error: `Could not determine a version from ${basePackageName}: ${spec}` };
|
|
425
|
+
const result = run("npm", ["view", basePackageName, "version", "--json", "--registry", npmRegistry], { inherit: false, failOnError: false, timeout });
|
|
426
|
+
if (result.status !== 0)
|
|
427
|
+
return { state: "unavailable", version: configured, latest: null, spec, error: (result.stderr || result.stdout || "npm could not be queried.").trim() };
|
|
428
|
+
let latest = result.stdout.trim();
|
|
429
|
+
try {
|
|
430
|
+
latest = JSON.parse(result.stdout.trim());
|
|
431
|
+
}
|
|
432
|
+
catch { /* npm may return an unquoted version */ }
|
|
433
|
+
if (typeof latest !== "string" || !latest)
|
|
434
|
+
return { state: "unavailable", version: configured, latest: null, spec };
|
|
435
|
+
const outdated = compareVersions(latest, configured) > 0;
|
|
436
|
+
return { state: outdated ? "outdated" : "current", version: configured, latest, spec, ...(outdated ? { upgrade: "cf-genai upgrade base latest" } : {}) };
|
|
437
|
+
}
|
|
438
|
+
export function devCommand({ hasScript, args = [] }) {
|
|
439
|
+
const forwarded = args[0] === "--" ? args.slice(1) : args;
|
|
440
|
+
const command = hasScript ? ["npm", "run", "dev", ...forwarded] : ["npx", "wrangler", "dev", ...forwarded];
|
|
441
|
+
return ["op", "run", "--env-file=.env.dev", "--", ...command];
|
|
442
|
+
}
|
|
443
|
+
export function lastProdRefresh({ cwd = process.cwd(), env = process.env } = {}) {
|
|
444
|
+
if (env.CF_GENAI_LAST_PROD_REFRESH)
|
|
445
|
+
return env.CF_GENAI_LAST_PROD_REFRESH;
|
|
446
|
+
try {
|
|
447
|
+
return readFileSync(join(cwd, ".cf-genai-last-prod-refresh"), "utf8").trim() || null;
|
|
448
|
+
}
|
|
449
|
+
catch {
|
|
450
|
+
return null;
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
function printDevDataStatus(options = {}) {
|
|
454
|
+
const refreshed = lastProdRefresh(options);
|
|
455
|
+
console.log("Last production data refresh: " + (refreshed || "unknown"));
|
|
456
|
+
console.log("To refresh data from prod run: cf-genai d1 refresh local");
|
|
457
|
+
}
|
|
458
|
+
function applyDevMigrations(env = process.env) {
|
|
459
|
+
if (!existsSync("migrations"))
|
|
460
|
+
return;
|
|
461
|
+
console.log("Applying local D1 migrations...");
|
|
462
|
+
migrateD1({
|
|
463
|
+
target: "local",
|
|
464
|
+
database: env.CF_GENAI_DATABASE || "DB",
|
|
465
|
+
options: {
|
|
466
|
+
config: env.CF_GENAI_WRANGLER_CONFIG || "wrangler.jsonc",
|
|
467
|
+
database: env.CF_GENAI_DATABASE || "DB",
|
|
468
|
+
productionDatabase: env.CF_GENAI_DATABASE || "DB",
|
|
469
|
+
productionEnv: env.CF_GENAI_PRODUCTION_ENV || "",
|
|
470
|
+
stagingEnv: env.CF_GENAI_STAGING_ENV || "staging",
|
|
471
|
+
wranglerCommand: ["op", "run", "--env-file=.env.dev", "--", ...shellCommand(env.CF_GENAI_WRANGLER || "npx wrangler")],
|
|
472
|
+
yes: false,
|
|
473
|
+
confirmProduction: false,
|
|
474
|
+
target: "local",
|
|
475
|
+
json: false,
|
|
476
|
+
help: false,
|
|
477
|
+
positional: [],
|
|
478
|
+
env,
|
|
479
|
+
},
|
|
480
|
+
});
|
|
481
|
+
}
|
|
482
|
+
export function runProjectCommand(command, args = []) {
|
|
483
|
+
if (command === "check") {
|
|
484
|
+
dataAccessLint();
|
|
485
|
+
return run("npm", ["run", "check"]);
|
|
486
|
+
}
|
|
487
|
+
if (command === "lint") {
|
|
488
|
+
if (args.length && args[0] !== "data-access")
|
|
489
|
+
throw new Error("Unknown lint target. Use data-access.");
|
|
490
|
+
return dataAccessLint();
|
|
491
|
+
}
|
|
492
|
+
if (command === "ci:lint") {
|
|
493
|
+
const result = dataAccessLint();
|
|
494
|
+
const scripts = packageJson().scripts || {};
|
|
495
|
+
if (scripts["format:check"])
|
|
496
|
+
run("npm", ["run", "format:check"]);
|
|
497
|
+
if (scripts["lint:source"])
|
|
498
|
+
run("npm", ["run", "lint:source"]);
|
|
499
|
+
return result;
|
|
500
|
+
}
|
|
501
|
+
if (command === "test")
|
|
502
|
+
return run("npm", ["test"]);
|
|
503
|
+
if (command === "build" || command === "ci")
|
|
504
|
+
return run("npm", ["run", "build"]);
|
|
505
|
+
if (command === "dev") {
|
|
506
|
+
printDevDataStatus();
|
|
507
|
+
applyDevMigrations();
|
|
508
|
+
const scripts = packageJson().scripts || {};
|
|
509
|
+
const [program, ...programArgs] = devCommand({ hasScript: Boolean(scripts.dev), args });
|
|
510
|
+
return run(program, programArgs);
|
|
511
|
+
}
|
|
512
|
+
if (command === "storybook")
|
|
513
|
+
return run("npm", ["run", "storybook", ...args]);
|
|
514
|
+
if (command === "upgrade")
|
|
515
|
+
return upgradePackage(args);
|
|
516
|
+
if (command === "release" && args.includes("--first"))
|
|
517
|
+
return publishFirst(args);
|
|
518
|
+
if (command === "release" && args.includes("--add-trust"))
|
|
519
|
+
return addTrust(args);
|
|
520
|
+
if (command === "release")
|
|
521
|
+
return release(args);
|
|
522
|
+
if (command === "release-status")
|
|
523
|
+
return releaseStatus(args);
|
|
524
|
+
return null;
|
|
525
|
+
}
|
|
526
|
+
function publishFirst(args) {
|
|
527
|
+
if (args.some((arg) => arg === "--version" || arg.startsWith("--version=")))
|
|
528
|
+
throw new Error("--version is only supported by the normal release command, not --first.");
|
|
529
|
+
assertFlag(args, "--confirm", "Initial npm publishing is irreversible and requires explicit human confirmation.");
|
|
530
|
+
assertClean();
|
|
531
|
+
if (!args.includes("--bypass-lint"))
|
|
532
|
+
runProjectCommand("ci:lint");
|
|
533
|
+
assertMainIsSynchronized();
|
|
534
|
+
const name = packageName();
|
|
535
|
+
const currentVersion = version();
|
|
536
|
+
ensureNpmLogin(name);
|
|
537
|
+
if (npmVersion(name, currentVersion))
|
|
538
|
+
throw new Error(name + "@" + currentVersion + " is already published.");
|
|
539
|
+
console.log("Publishing " + name + "@" + currentVersion + " to npm...");
|
|
540
|
+
const published = run("npm", ["publish", "--access", "public", "--provenance=false"]);
|
|
541
|
+
if (published.status !== 0)
|
|
542
|
+
return published;
|
|
543
|
+
console.log("Configuring npm Trusted Publishing for " + name + "...");
|
|
544
|
+
return addNpmTrust(name);
|
|
545
|
+
}
|
|
546
|
+
function addTrust(args) {
|
|
547
|
+
if (args.includes("--first"))
|
|
548
|
+
throw new Error("Use either --first or --add-trust; --first already configures Trusted Publishing after the initial publish.");
|
|
549
|
+
assertFlag(args, "--confirm", "Changing npm Trusted Publishing requires explicit human confirmation.");
|
|
550
|
+
assertClean();
|
|
551
|
+
const name = packageName();
|
|
552
|
+
if (!npmPackageExists(name)) {
|
|
553
|
+
throw new Error(`${name} must be published before Trusted Publishing can be configured. Run cf-genai release --first --confirm.`);
|
|
554
|
+
}
|
|
555
|
+
console.log("Configuring npm Trusted Publishing for " + name + "...");
|
|
556
|
+
return addNpmTrust(name);
|
|
557
|
+
}
|
|
558
|
+
function release(args) {
|
|
559
|
+
const dryRun = args.includes("--dry-run");
|
|
560
|
+
const bypassLint = args.includes("--bypass-lint");
|
|
561
|
+
const pre = args.includes("--pre");
|
|
562
|
+
const requestedVersion = requestedReleaseVersion(args);
|
|
563
|
+
if (pre && requestedVersion)
|
|
564
|
+
throw new Error("Use either --pre or --version, not both.");
|
|
565
|
+
if (pre && args.includes("--type"))
|
|
566
|
+
throw new Error("Use either --pre or --type, not both.");
|
|
567
|
+
if (requestedVersion && args.includes("--type"))
|
|
568
|
+
throw new Error("Use either --version or --type, not both.");
|
|
569
|
+
if (!dryRun)
|
|
570
|
+
assertFlag(args, "--confirm", "A release requires explicit human confirmation because it creates a commit, tag, and npm publish trigger.");
|
|
571
|
+
assertClean();
|
|
572
|
+
if (!bypassLint)
|
|
573
|
+
runProjectCommand("ci:lint");
|
|
574
|
+
assertMainIsSynchronized();
|
|
575
|
+
const name = packageName();
|
|
576
|
+
let currentVersion = version();
|
|
577
|
+
if (pre) {
|
|
578
|
+
let action = preReleaseAction(currentVersion);
|
|
579
|
+
while (npmVersionState(name, action.version).exists)
|
|
580
|
+
action = preReleaseAction(action.version);
|
|
581
|
+
if (dryRun) {
|
|
582
|
+
console.log(`Dry run: ${name}@${currentVersion} would release as ${action.version}. Main is synchronized and no changes were made.`);
|
|
583
|
+
return;
|
|
584
|
+
}
|
|
585
|
+
if (currentVersion !== action.version) {
|
|
586
|
+
const bumped = run("npm", ["version", action.version, "--no-git-tag-version"]);
|
|
587
|
+
if (bumped.status !== 0)
|
|
588
|
+
return bumped;
|
|
589
|
+
currentVersion = version();
|
|
590
|
+
}
|
|
591
|
+
return finishRelease(name, currentVersion, true);
|
|
592
|
+
}
|
|
593
|
+
if (requestedVersion) {
|
|
594
|
+
const action = requestedReleaseAction(currentVersion, requestedVersion);
|
|
595
|
+
const published = npmVersionState(name, requestedVersion);
|
|
596
|
+
if (published.exists || tagExists(`v${requestedVersion}`))
|
|
597
|
+
throw new Error(`${name}@${requestedVersion} already exists; release versions cannot be reused.`);
|
|
598
|
+
if (dryRun) {
|
|
599
|
+
console.log(`Dry run: ${name}@${currentVersion} would release as ${action.version}. Main is synchronized and no changes were made.`);
|
|
600
|
+
return;
|
|
601
|
+
}
|
|
602
|
+
if (action.bump) {
|
|
603
|
+
const bumped = run("npm", ["version", requestedVersion, "--no-git-tag-version"]);
|
|
604
|
+
if (bumped.status !== 0)
|
|
605
|
+
return bumped;
|
|
606
|
+
currentVersion = version();
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
const typeIndex = args.indexOf("--type");
|
|
610
|
+
const type = typeIndex >= 0 ? args[typeIndex + 1] : "patch";
|
|
611
|
+
if (!type || !["patch", "minor", "major"].includes(type))
|
|
612
|
+
throw new Error("--type must be patch, minor, or major.");
|
|
613
|
+
const currentPublished = requestedVersion ? false : npmVersionState(name, currentVersion).exists;
|
|
614
|
+
const currentTagExists = requestedVersion ? false : tagExists(`v${currentVersion}`);
|
|
615
|
+
if (!requestedVersion && currentTagExists && !currentPublished) {
|
|
616
|
+
throw new Error(`${name}@${currentVersion} has a release tag but is not published. Repair the failed publish or run release-status before creating another release.`);
|
|
617
|
+
}
|
|
618
|
+
const prepared = !requestedVersion && !currentPublished && isPreparedReleaseVersion(currentVersion, npmLatestVersion(name), currentTagExists);
|
|
619
|
+
if (!requestedVersion && !currentPublished && !currentTagExists && !prepared) {
|
|
620
|
+
throw new Error(`${name} is not published yet. Run cf-genai release --first --confirm to bootstrap the npm package before creating a release tag.`);
|
|
621
|
+
}
|
|
622
|
+
const consumed = requestedVersion ? false : Boolean(currentPublished || currentTagExists || prepared);
|
|
623
|
+
if (dryRun) {
|
|
624
|
+
console.log(`Dry run: ${name}@${currentVersion}${consumed ? ` would bump ${type}` : " is ready to release"}. Main is synchronized and no changes were made.`);
|
|
625
|
+
return;
|
|
626
|
+
}
|
|
627
|
+
if (consumed) {
|
|
628
|
+
const bumped = run("npm", ["version", type, "--no-git-tag-version"]);
|
|
629
|
+
if (bumped.status !== 0)
|
|
630
|
+
return bumped;
|
|
631
|
+
currentVersion = version();
|
|
632
|
+
}
|
|
633
|
+
return finishRelease(name, currentVersion, false);
|
|
634
|
+
}
|
|
635
|
+
function finishRelease(name, currentVersion, pre) {
|
|
636
|
+
const staged = run("git", ["add", "package.json", "package-lock.json"]);
|
|
637
|
+
if (staged.status !== 0)
|
|
638
|
+
return staged;
|
|
639
|
+
const stagedChanges = spawnSync("git", ["diff", "--cached", "--quiet"], { stdio: "ignore" });
|
|
640
|
+
if (stagedChanges.status !== 0) {
|
|
641
|
+
const committed = run("git", ["commit", "-m", `Release ${name} v${currentVersion}`]);
|
|
642
|
+
if (committed.status !== 0)
|
|
643
|
+
return committed;
|
|
644
|
+
}
|
|
645
|
+
const pushedMain = run("git", ["push", "origin", "main"]);
|
|
646
|
+
if (pushedMain.status !== 0)
|
|
647
|
+
return pushedMain;
|
|
648
|
+
const localHead = output("git", ["rev-parse", "HEAD"]);
|
|
649
|
+
const remoteHead = output("git", ["ls-remote", "origin", "refs/heads/main"]).split(/\s+/)[0];
|
|
650
|
+
if (localHead !== remoteHead)
|
|
651
|
+
throw new Error("origin/main could not be verified at the release commit; tag was not created.");
|
|
652
|
+
const tag = `v${currentVersion}`;
|
|
653
|
+
if (tagExists(tag))
|
|
654
|
+
throw new Error(`Tag ${tag} already exists; release tags are immutable.`);
|
|
655
|
+
const tagged = run("git", ["tag", tag]);
|
|
656
|
+
if (tagged.status !== 0)
|
|
657
|
+
return tagged;
|
|
658
|
+
return run("git", ["push", "origin", `refs/tags/${tag}`]);
|
|
659
|
+
}
|
|
660
|
+
async function releaseStatus(args = []) {
|
|
661
|
+
const name = packageName();
|
|
662
|
+
const currentVersion = version();
|
|
663
|
+
const waitMinutes = releaseWaitMinutes(args);
|
|
664
|
+
const json = args.includes("--json");
|
|
665
|
+
const deadline = Date.now() + waitMinutes * 60_000;
|
|
666
|
+
const tag = `v${currentVersion}`;
|
|
667
|
+
const checks = { git: gitReleaseState(), tag: releaseTagState(tag), base: baseReleaseState(packageJson(), releaseStatusCommandTimeout), github_actions: { state: "pending", runs: [] }, npm: { state: "not_published", version: null } };
|
|
668
|
+
const repository = remoteRepository();
|
|
669
|
+
do {
|
|
670
|
+
const remaining = Math.max(1, deadline - Date.now());
|
|
671
|
+
checks.github_actions = githubActionsState(repository, checks.tag.remote_sha || checks.tag.local_sha || "", Math.min(10_000, remaining));
|
|
672
|
+
checks.npm = npmReleaseState(name, currentVersion, Math.min(10_000, Math.max(1, deadline - Date.now())));
|
|
673
|
+
if (!releaseStatusShouldContinue(checks, Date.now(), deadline))
|
|
674
|
+
break;
|
|
675
|
+
await new Promise((resolve) => setTimeout(resolve, Math.min(5000, Math.max(1, deadline - Date.now()))));
|
|
676
|
+
} while (Date.now() < deadline);
|
|
677
|
+
const result = { package: name, version: currentVersion, tag, repository, wait_minutes: waitMinutes, checks, ok: checks.git.clean && checks.git.pushed && checks.tag.matches && checks.github_actions.state === "passed" && checks.npm.state === "published" };
|
|
678
|
+
if (json)
|
|
679
|
+
console.log(JSON.stringify(result, null, 2));
|
|
680
|
+
else {
|
|
681
|
+
console.log(`${name}@${currentVersion}`);
|
|
682
|
+
const clean = checks.git.clean ? "clean" : "dirty";
|
|
683
|
+
const pushed = checks.git.pushed ? "yes" : "no";
|
|
684
|
+
const tagState = checks.tag.matches ? "present and correct" : "missing or incorrect";
|
|
685
|
+
const releaseState = result.ok ? "ready" : "not ready";
|
|
686
|
+
console.log(`workspace: ${releaseStatusDot(clean)} ${clean}; pushed: ${releaseStatusDot(pushed)} ${pushed}`);
|
|
687
|
+
console.log(`tag ${tag}: ${releaseStatusDot(tagState)} ${tagState}`);
|
|
688
|
+
const actionsError = checks.github_actions.error ? ` — ${checks.github_actions.error.replace(/\s+/g, " ")}` : "";
|
|
689
|
+
const failedPublish = checks.github_actions.runs?.find((run) => run.status === "completed" && run.conclusion !== "success");
|
|
690
|
+
const failedPublishError = failedPublish ? ` — ${failedPublish.conclusion}${failedPublish.url ? ` (${failedPublish.url})` : ""}` : "";
|
|
691
|
+
const npmError = checks.npm.error ? ` — ${checks.npm.error.replace(/\s+/g, " ")}` : "";
|
|
692
|
+
const baseError = checks.base.error ? ` — ${checks.base.error.replace(/\s+/g, " ")}` : "";
|
|
693
|
+
console.log(`GitHub Actions: ${releaseStatusDot(checks.github_actions.state)} ${checks.github_actions.state}${actionsError}${failedPublishError}`);
|
|
694
|
+
console.log(`npm: ${releaseStatusDot(checks.npm.state)} ${checks.npm.state}${npmError}`);
|
|
695
|
+
if (checks.base.state === "outdated") {
|
|
696
|
+
console.log(`cf-genai-base: ${releaseStatusDot(checks.base.state)} outdated (${checks.base.version}; latest ${checks.base.latest})`);
|
|
697
|
+
console.log(` Upgrade: ${checks.base.upgrade}`);
|
|
698
|
+
}
|
|
699
|
+
else if (checks.base.state !== "not_declared") {
|
|
700
|
+
console.log(`cf-genai-base: ${releaseStatusDot(checks.base.state)} ${checks.base.state}${baseError}`);
|
|
701
|
+
}
|
|
702
|
+
console.log(`release status: ${releaseStatusDot(releaseState)} ${releaseState}`);
|
|
703
|
+
}
|
|
704
|
+
return result;
|
|
705
|
+
}
|
|
706
|
+
function parsePackageMetadata(text) {
|
|
707
|
+
const value = JSON.parse(text);
|
|
708
|
+
if (value === null || typeof value !== "object" || Array.isArray(value))
|
|
709
|
+
throw new Error("package.json must contain a JSON object.");
|
|
710
|
+
const metadata = {};
|
|
711
|
+
const name = Reflect.get(value, "name");
|
|
712
|
+
const packageVersion = Reflect.get(value, "version");
|
|
713
|
+
if (typeof name === "string")
|
|
714
|
+
metadata.name = name;
|
|
715
|
+
if (typeof packageVersion === "string")
|
|
716
|
+
metadata.version = packageVersion;
|
|
717
|
+
for (const field of ["scripts", "dependencies", "devDependencies", "peerDependencies", "optionalDependencies"]) {
|
|
718
|
+
const entries = stringRecord(Reflect.get(value, field));
|
|
719
|
+
if (entries)
|
|
720
|
+
metadata[field] = entries;
|
|
721
|
+
}
|
|
722
|
+
return metadata;
|
|
723
|
+
}
|
|
724
|
+
function stringRecord(value) {
|
|
725
|
+
if (value === null || typeof value !== "object" || Array.isArray(value))
|
|
726
|
+
return null;
|
|
727
|
+
const entries = Object.entries(value);
|
|
728
|
+
if (!entries.every((entry) => typeof entry[1] === "string"))
|
|
729
|
+
return null;
|
|
730
|
+
return Object.fromEntries(entries);
|
|
731
|
+
}
|
|
732
|
+
function isGithubRun(value) {
|
|
733
|
+
return value !== null && typeof value === "object" && !Array.isArray(value)
|
|
734
|
+
&& (Reflect.get(value, "status") === undefined || typeof Reflect.get(value, "status") === "string")
|
|
735
|
+
&& (Reflect.get(value, "conclusion") === undefined || typeof Reflect.get(value, "conclusion") === "string")
|
|
736
|
+
&& (Reflect.get(value, "url") === undefined || typeof Reflect.get(value, "url") === "string");
|
|
737
|
+
}
|
|
738
|
+
//# sourceMappingURL=project.js.map
|