@jini-ai/user-management 0.7.3-next.1 → 0.7.3-next.3
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 +6 -0
- package/README.md +55 -2
- package/dist/admin/adapters/memory.js +4 -4
- package/dist/admin-http/auth/auth-request.d.ts +112 -0
- package/dist/admin-http/auth/auth-request.js +32 -0
- package/dist/admin-http/auth/boot-redemption.d.ts +9 -0
- package/dist/admin-http/auth/boot-redemption.js +17 -0
- package/dist/admin-http/auth/boot-session.d.ts +30 -0
- package/dist/admin-http/auth/boot-session.js +40 -0
- package/dist/admin-http/auth/current-user.d.ts +28 -0
- package/dist/admin-http/auth/current-user.js +34 -0
- package/dist/admin-http/auth/index.d.ts +17 -0
- package/dist/admin-http/auth/index.js +9 -0
- package/dist/admin-http/auth/local-boot-session.d.ts +9 -0
- package/dist/admin-http/auth/local-boot-session.js +30 -0
- package/dist/admin-http/auth/logout.d.ts +10 -0
- package/dist/admin-http/auth/logout.js +17 -0
- package/dist/admin-http/auth/mfa-login.d.ts +30 -0
- package/dist/admin-http/auth/mfa-login.js +43 -0
- package/dist/admin-http/auth/password-login.d.ts +35 -0
- package/dist/admin-http/auth/password-login.js +52 -0
- package/dist/admin-http/auth/password-status.d.ts +34 -0
- package/dist/admin-http/auth/password-status.js +42 -0
- package/dist/admin-http/http/api-keys.d.ts +45 -0
- package/dist/admin-http/http/api-keys.js +28 -0
- package/dist/admin-http/http/users.d.ts +71 -0
- package/dist/admin-http/http/users.js +42 -0
- package/dist/admin-http/owner/mfa-deps.d.ts +41 -0
- package/dist/admin-http/owner/mfa-deps.js +26 -0
- package/dist/admin-http/owner/mfa-routes.d.ts +72 -0
- package/dist/admin-http/owner/mfa-routes.js +105 -0
- package/dist/admin-http/owner/passkey-admission.d.ts +46 -0
- package/dist/admin-http/owner/passkey-admission.js +23 -0
- package/dist/admin-http/owner/passkey-route-deps.d.ts +53 -0
- package/dist/admin-http/owner/passkey-route-deps.js +33 -0
- package/dist/admin-http/owner/passkey-routes.d.ts +146 -0
- package/dist/admin-http/owner/passkey-routes.js +98 -0
- package/dist/admin-http/owner/recovery-routes.d.ts +71 -0
- package/dist/admin-http/owner/recovery-routes.js +112 -0
- package/dist/admin-http/routes/api-keys/create-principal.d.ts +26 -0
- package/dist/admin-http/routes/api-keys/create-principal.js +37 -0
- package/dist/admin-http/routes/api-keys/issue.d.ts +32 -0
- package/dist/admin-http/routes/api-keys/issue.js +38 -0
- package/dist/admin-http/routes/api-keys/revoke.d.ts +26 -0
- package/dist/admin-http/routes/api-keys/revoke.js +31 -0
- package/dist/admin-http/routes/api-keys/shared.d.ts +46 -0
- package/dist/admin-http/routes/api-keys/shared.js +38 -0
- package/dist/admin-http/routes/users/access-shared.d.ts +103 -0
- package/dist/admin-http/routes/users/access-shared.js +85 -0
- package/dist/admin-http/routes/users/assign-role.d.ts +24 -0
- package/dist/admin-http/routes/users/assign-role.js +30 -0
- package/dist/admin-http/routes/users/attach-policy.d.ts +25 -0
- package/dist/admin-http/routes/users/attach-policy.js +31 -0
- package/dist/admin-http/routes/users/create-policy.d.ts +19 -0
- package/dist/admin-http/routes/users/create-policy.js +28 -0
- package/dist/admin-http/routes/users/create-role.d.ts +15 -0
- package/dist/admin-http/routes/users/create-role.js +21 -0
- package/dist/admin-http/routes/users/create.d.ts +32 -0
- package/dist/admin-http/routes/users/create.js +67 -0
- package/dist/admin-http/routes/users/delete-policy.d.ts +16 -0
- package/dist/admin-http/routes/users/delete-policy.js +24 -0
- package/dist/admin-http/routes/users/delete-role.d.ts +16 -0
- package/dist/admin-http/routes/users/delete-role.js +24 -0
- package/dist/admin-http/routes/users/delete.d.ts +35 -0
- package/dist/admin-http/routes/users/delete.js +35 -0
- package/dist/admin-http/routes/users/disable.d.ts +31 -0
- package/dist/admin-http/routes/users/disable.js +38 -0
- package/dist/admin-http/routes/users/enable.d.ts +32 -0
- package/dist/admin-http/routes/users/enable.js +45 -0
- package/dist/admin-http/routes/users/list-policies.d.ts +18 -0
- package/dist/admin-http/routes/users/list-policies.js +20 -0
- package/dist/admin-http/routes/users/list-policy-permissions.d.ts +28 -0
- package/dist/admin-http/routes/users/list-policy-permissions.js +30 -0
- package/dist/admin-http/routes/users/list-roles.d.ts +18 -0
- package/dist/admin-http/routes/users/list-roles.js +20 -0
- package/dist/admin-http/routes/users/list.d.ts +40 -0
- package/dist/admin-http/routes/users/list.js +82 -0
- package/dist/admin-http/routes/users/remove-policy-permission.d.ts +48 -0
- package/dist/admin-http/routes/users/remove-policy-permission.js +62 -0
- package/dist/admin-http/routes/users/reset-password.d.ts +33 -0
- package/dist/admin-http/routes/users/reset-password.js +52 -0
- package/dist/admin-http/routes/users/shared.d.ts +124 -0
- package/dist/admin-http/routes/users/shared.js +93 -0
- package/dist/admin-http/routes/users/update-policy.d.ts +25 -0
- package/dist/admin-http/routes/users/update-policy.js +30 -0
- package/dist/admin-http/routes/users/update-role.d.ts +23 -0
- package/dist/admin-http/routes/users/update-role.js +29 -0
- package/dist/admin-http/routes/users/update.d.ts +35 -0
- package/dist/admin-http/routes/users/update.js +78 -0
- package/dist/admin-http/routes/users/write-policy-permission.d.ts +31 -0
- package/dist/admin-http/routes/users/write-policy-permission.js +45 -0
- package/dist/core/ports.d.ts +22 -3
- package/dist/core/types.d.ts +17 -5
- package/dist/core/types.js +12 -0
- package/dist/identity/api-key-secret.d.ts +68 -0
- package/dist/identity/api-key-secret.js +229 -0
- package/dist/identity/api-key-service.d.ts +144 -0
- package/dist/identity/api-key-service.js +389 -0
- package/dist/identity/api-key-types.d.ts +79 -0
- package/dist/identity/api-key-types.js +2 -0
- package/dist/identity/boot-session-token.d.ts +18 -0
- package/dist/identity/boot-session-token.js +92 -0
- package/dist/identity/builtin-role-grants.d.ts +120 -0
- package/dist/identity/builtin-role-grants.js +88 -0
- package/dist/identity/delete-user-service.d.ts +195 -0
- package/dist/identity/delete-user-service.js +275 -0
- package/dist/identity/owner-reset-env.d.ts +37 -0
- package/dist/identity/owner-reset-env.js +38 -0
- package/dist/identity/permission-grants.d.ts +31 -0
- package/dist/identity/permission-grants.js +12 -0
- package/dist/identity/permission-list-tool.d.ts +35 -0
- package/dist/identity/permission-list-tool.js +47 -0
- package/dist/identity/repo.authentication.d.ts +57 -0
- package/dist/identity/repo.authentication.js +153 -0
- package/dist/identity/repo.authorization.d.ts +82 -0
- package/dist/identity/repo.authorization.js +203 -0
- package/dist/identity/repo.d.ts +87 -0
- package/dist/identity/repo.js +167 -0
- package/dist/identity/repo.memory.d.ts +31 -0
- package/dist/identity/repo.memory.js +37 -0
- package/dist/identity/role-manage-permission.d.ts +34 -0
- package/dist/identity/role-manage-permission.js +39 -0
- package/dist/identity/site-key-permission.d.ts +66 -0
- package/dist/identity/site-key-permission.js +92 -0
- package/dist/identity/sql/kernel-user-purge.d.ts +19 -0
- package/dist/identity/sql/kernel-user-purge.js +34 -0
- package/dist/identity/sql/kernel-user-trash-store.d.ts +15 -0
- package/dist/identity/sql/kernel-user-trash-store.js +41 -0
- package/dist/identity/sql/user-trash-adapter.d.ts +87 -0
- package/dist/identity/sql/user-trash-adapter.js +124 -0
- package/dist/identity/tool-registrations.d.ts +100 -0
- package/dist/identity/tool-registrations.js +257 -0
- package/dist/identity/user-manage-permission.d.ts +8 -0
- package/dist/identity/user-manage-permission.js +8 -0
- package/dist/identity/user-purge-types.d.ts +85 -0
- package/dist/identity/user-purge-types.js +17 -0
- package/dist/identity/user-purge.d.ts +69 -0
- package/dist/identity/user-purge.js +46 -0
- package/dist/identity/username-change-ports.d.ts +15 -0
- package/dist/identity/username-change-ports.js +22 -0
- package/dist/mail/site/capture-clear.d.ts +58 -0
- package/dist/mail/site/capture-clear.js +21 -0
- package/dist/mail/status/agent-tools.d.ts +65 -0
- package/dist/mail/status/agent-tools.js +22 -0
- package/dist/mail/status/delivery-agent-tools.d.ts +206 -0
- package/dist/mail/status/delivery-agent-tools.js +63 -0
- package/dist/mail/status/delivery-tool-registrations.d.ts +216 -0
- package/dist/mail/status/delivery-tool-registrations.js +110 -0
- package/dist/mail/status/domain-deps.d.ts +25 -0
- package/dist/mail/status/domain-deps.js +23 -0
- package/dist/mail/status/permissions.d.ts +43 -0
- package/dist/mail/status/permissions.js +45 -0
- package/dist/mail/status/provider-agent-tools.d.ts +38 -0
- package/dist/mail/status/provider-agent-tools.js +17 -0
- package/dist/mail/status/provider-operations.d.ts +166 -0
- package/dist/mail/status/provider-operations.js +121 -0
- package/dist/mail/status/provider-tool-registrations.d.ts +65 -0
- package/dist/mail/status/provider-tool-registrations.js +106 -0
- package/dist/mail/status/tool-registrations.d.ts +152 -0
- package/dist/mail/status/tool-registrations.js +112 -0
- package/dist/member-login/credentials.d.ts +40 -0
- package/dist/member-login/credentials.js +26 -0
- package/dist/member-login/link-service.d.ts +66 -0
- package/dist/member-login/link-service.js +141 -0
- package/dist/member-login/oidc-login.d.ts +132 -0
- package/dist/member-login/oidc-login.js +206 -0
- package/dist/member-login/oidc-request.d.ts +80 -0
- package/dist/member-login/oidc-request.js +86 -0
- package/dist/member-login/providers.d.ts +79 -0
- package/dist/member-login/providers.js +41 -0
- package/dist/member-login/ready-providers.d.ts +17 -0
- package/dist/member-login/ready-providers.js +11 -0
- package/dist/member-login/unlink-identity.d.ts +26 -0
- package/dist/member-login/unlink-identity.js +59 -0
- package/dist/members/access-resolver.d.ts +107 -0
- package/dist/members/access-resolver.js +231 -0
- package/dist/members/agent-tools.d.ts +14 -0
- package/dist/members/agent-tools.js +139 -0
- package/dist/members/auth-mail.d.ts +27 -0
- package/dist/members/auth-mail.js +21 -0
- package/dist/members/capability-card.d.ts +18 -0
- package/dist/members/capability-card.js +27 -0
- package/dist/members/consent-service.d.ts +115 -0
- package/dist/members/consent-service.js +179 -0
- package/dist/members/member-admin-writes.d.ts +73 -0
- package/dist/members/member-admin-writes.js +149 -0
- package/dist/members/member-challenge-request.d.ts +59 -0
- package/dist/members/member-challenge-request.js +145 -0
- package/dist/members/member-challenge.d.ts +37 -0
- package/dist/members/member-challenge.js +84 -0
- package/dist/members/member-credentials.d.ts +35 -0
- package/dist/members/member-credentials.js +57 -0
- package/dist/members/member-sign-in.d.ts +44 -0
- package/dist/members/member-sign-in.js +130 -0
- package/dist/members/member-validation.d.ts +5 -0
- package/dist/members/member-validation.js +13 -0
- package/dist/members/password-auth.d.ts +55 -0
- package/dist/members/password-auth.js +177 -0
- package/dist/members/ports.d.ts +455 -0
- package/dist/members/ports.js +21 -0
- package/dist/members/public-member-auth-response.d.ts +68 -0
- package/dist/members/public-member-auth-response.js +45 -0
- package/dist/members/public-member-response.d.ts +25 -0
- package/dist/members/public-member-response.js +15 -0
- package/dist/members/repo.d.ts +199 -0
- package/dist/members/repo.js +324 -0
- package/dist/members/repo.memory.d.ts +276 -0
- package/dist/members/repo.memory.js +395 -0
- package/dist/members/repo.rows.d.ts +153 -0
- package/dist/members/repo.rows.js +250 -0
- package/dist/members/repo.sessions.d.ts +80 -0
- package/dist/members/repo.sessions.js +166 -0
- package/dist/members/repo.sql.d.ts +9 -0
- package/dist/members/repo.sql.js +11 -0
- package/dist/members/subscriber-directory.d.ts +85 -0
- package/dist/members/subscriber-directory.js +70 -0
- package/dist/members/tool-registrations.d.ts +143 -0
- package/dist/members/tool-registrations.js +247 -0
- package/dist/members/trash-member.d.ts +24 -0
- package/dist/members/trash-member.js +24 -0
- package/dist/members/types.d.ts +321 -0
- package/dist/members/types.js +34 -0
- package/dist/members/write-service.d.ts +17 -0
- package/dist/members/write-service.js +15 -0
- package/dist/newsletter/agent-tools.d.ts +20 -0
- package/dist/newsletter/agent-tools.js +236 -0
- package/dist/newsletter/campaign-write-service.d.ts +92 -0
- package/dist/newsletter/campaign-write-service.js +190 -0
- package/dist/newsletter/campaign.d.ts +53 -0
- package/dist/newsletter/campaign.js +95 -0
- package/dist/newsletter/confirmation.d.ts +75 -0
- package/dist/newsletter/confirmation.js +142 -0
- package/dist/newsletter/data-module-manifest.d.ts +68 -0
- package/dist/newsletter/data-module-manifest.js +126 -0
- package/dist/newsletter/delivery/tool-registrations.d.ts +67 -0
- package/dist/newsletter/delivery/tool-registrations.js +229 -0
- package/dist/newsletter/errors.d.ts +93 -0
- package/dist/newsletter/errors.js +93 -0
- package/dist/newsletter/hooks.d.ts +59 -0
- package/dist/newsletter/hooks.js +49 -0
- package/dist/newsletter/http-error-responses.d.ts +17 -0
- package/dist/newsletter/http-error-responses.js +96 -0
- package/dist/newsletter/launch-gate.d.ts +62 -0
- package/dist/newsletter/launch-gate.js +29 -0
- package/dist/newsletter/lists.d.ts +60 -0
- package/dist/newsletter/lists.js +83 -0
- package/dist/newsletter/ports.d.ts +278 -0
- package/dist/newsletter/ports.js +2 -0
- package/dist/newsletter/repo-sends.d.ts +82 -0
- package/dist/newsletter/repo-sends.js +178 -0
- package/dist/newsletter/repo-subscribers.d.ts +82 -0
- package/dist/newsletter/repo-subscribers.js +193 -0
- package/dist/newsletter/repo.d.ts +61 -0
- package/dist/newsletter/repo.js +147 -0
- package/dist/newsletter/repo.memory.d.ts +201 -0
- package/dist/newsletter/repo.memory.js +250 -0
- package/dist/newsletter/repo.rows.d.ts +221 -0
- package/dist/newsletter/repo.rows.js +260 -0
- package/dist/newsletter/send-pipeline.d.ts +236 -0
- package/dist/newsletter/send-pipeline.js +514 -0
- package/dist/newsletter/subscriptions.d.ts +87 -0
- package/dist/newsletter/subscriptions.js +119 -0
- package/dist/newsletter/tool-registrations.d.ts +89 -0
- package/dist/newsletter/tool-registrations.deps.d.ts +9 -0
- package/dist/newsletter/tool-registrations.deps.js +9 -0
- package/dist/newsletter/tool-registrations.js +133 -0
- package/dist/newsletter/tool-registrations.read.d.ts +76 -0
- package/dist/newsletter/tool-registrations.read.js +140 -0
- package/dist/newsletter/tool-registrations.write.d.ts +54 -0
- package/dist/newsletter/tool-registrations.write.js +229 -0
- package/dist/newsletter/types.d.ts +279 -0
- package/dist/newsletter/types.js +23 -0
- package/dist/newsletter/unsubscribe.d.ts +41 -0
- package/dist/newsletter/unsubscribe.js +100 -0
- package/dist/project-keys/attached-vault.d.ts +23 -0
- package/dist/project-keys/attached-vault.js +65 -0
- package/dist/project-keys/create-vault.d.ts +17 -0
- package/dist/project-keys/create-vault.js +29 -0
- package/dist/project-keys/service.d.ts +133 -0
- package/dist/project-keys/service.js +128 -0
- package/dist/project-keys/site-references.d.ts +30 -0
- package/dist/project-keys/site-references.js +63 -0
- package/dist/project-keys/site-sealer.d.ts +28 -0
- package/dist/project-keys/site-sealer.js +64 -0
- package/dist/project-keys/sql/attachments.d.ts +33 -0
- package/dist/project-keys/sql/attachments.js +55 -0
- package/dist/project-keys/tools.d.ts +86 -0
- package/dist/project-keys/tools.js +66 -0
- package/dist/public-http/routes/mail/feedback.d.ts +44 -0
- package/dist/public-http/routes/mail/feedback.js +17 -0
- package/dist/public-http/routes/newsletter/confirm.d.ts +38 -0
- package/dist/public-http/routes/newsletter/confirm.js +33 -0
- package/dist/public-http/routes/newsletter/page.d.ts +29 -0
- package/dist/public-http/routes/newsletter/page.js +34 -0
- package/dist/public-http/routes/newsletter/unsubscribe.d.ts +33 -0
- package/dist/public-http/routes/newsletter/unsubscribe.js +35 -0
- package/dist/react/auth/Passkeys.d.ts +2 -34
- package/dist/react/auth/RecoveryCodesCard.d.ts +27 -0
- package/dist/react/auth/RecoveryCodesCard.hooks.d.ts +67 -0
- package/dist/react/auth/RecoveryCodesCard.hooks.js +38 -0
- package/dist/react/auth/RecoveryCodesCard.js +56 -0
- package/dist/react/auth/TotpSettings.d.ts +2 -23
- package/dist/react/auth/local-owner-signin.d.ts +40 -0
- package/dist/react/auth/local-owner-signin.js +25 -0
- package/dist/react/auth/owner-mfa-api.d.ts +10 -0
- package/dist/react/auth/owner-mfa-api.js +17 -0
- package/dist/react/auth/owner-passkey-api.d.ts +11 -0
- package/dist/react/auth/owner-passkey-api.js +17 -0
- package/dist/react/auth/owner-recovery-api.d.ts +51 -0
- package/dist/react/auth/owner-recovery-api.js +29 -0
- package/dist/react/auth/owner-request.d.ts +7 -0
- package/dist/react/auth/owner-request.js +2 -0
- package/dist/react/index.d.ts +10 -0
- package/dist/react/index.js +6 -0
- package/dist/react/mail/Email.d.ts +20 -0
- package/dist/react/mail/Email.js +143 -0
- package/dist/react/mail/EmailProviderTab.d.ts +34 -0
- package/dist/react/mail/EmailProviderTab.js +132 -0
- package/dist/react/mail/EmailSegments.d.ts +24 -0
- package/dist/react/mail/EmailSegments.js +15 -0
- package/dist/react/mail/EmailTemplateEditor.d.ts +146 -0
- package/dist/react/mail/EmailTemplateEditor.js +116 -0
- package/dist/react/mail/email-view.types.d.ts +236 -0
- package/dist/react/mail/email-view.types.js +2 -0
- package/dist/react/members/Members.d.ts +5 -3
- package/dist/react/members/Members.js +3 -3
- package/dist/react/members/api/members-api.d.ts +37 -0
- package/dist/react/members/api/members-api.js +16 -0
- package/dist/react/members/hooks/use-members.hooks.js +2 -1
- package/dist/react/members/members-i18n.d.ts +23 -0
- package/dist/react/members/members-i18n.js +25 -0
- package/dist/react/members/members-i18n.locales-a.d.ts +4 -0
- package/dist/react/members/members-i18n.locales-a.js +294 -0
- package/dist/react/members/members-i18n.locales-b.d.ts +4 -0
- package/dist/react/members/members-i18n.locales-b.js +265 -0
- package/dist/react/models.d.ts +1 -49
- package/dist/react/ports.d.ts +3 -143
- package/dist/react/roles/api/roles-api.d.ts +74 -0
- package/dist/react/roles/api/roles-api.js +22 -0
- package/dist/react/testing.js +18 -9
- package/dist/react/users/UsersPanel.d.ts +30 -0
- package/dist/react/users/UsersPanel.hooks.d.ts +8 -0
- package/dist/react/users/UsersPanel.hooks.js +9 -0
- package/dist/react/users/UsersPanel.js +9 -0
- package/dist/react/users/api/users-api.d.ts +65 -0
- package/dist/react/users/api/users-api.js +46 -0
- package/dist/react/users/hooks/use-localized-users.hooks.d.ts +43 -0
- package/dist/react/users/hooks/use-localized-users.hooks.js +15 -0
- package/dist/react/users/hooks/use-users-state.hooks.d.ts +18 -18
- package/dist/react/users/password-reset-notice.d.ts +8 -0
- package/dist/react/users/password-reset-notice.js +36 -0
- package/dist/server/admin-crud-service.d.ts +4 -10
- package/dist/server/admin-crud-service.js +20 -6
- package/dist/server/agent-tool-registrations.js +20 -5
- package/dist/server/agent-tools.js +16 -3
- package/dist/server/auth-challenge.d.ts +1 -1
- package/dist/server/auth-service.js +2 -1
- package/dist/server/grant-service.d.ts +1 -0
- package/dist/server/grant-service.js +7 -4
- package/dist/server/mfa/passkey-service.d.ts +2 -2
- package/dist/server/mfa/passkey-service.js +1 -1
- package/dist/server/mfa/service.js +6 -4
- package/dist/server/repo.memory.d.ts +30 -2
- package/dist/server/repo.memory.js +58 -4
- package/dist/server/seed.js +3 -3
- package/dist/server/sql/assignments.d.ts +90 -0
- package/dist/server/sql/assignments.js +128 -0
- package/dist/server/sql/index.d.ts +6 -0
- package/dist/server/sql/index.js +5 -0
- package/dist/server/sql/kernel.d.ts +9 -0
- package/dist/server/sql/kernel.js +2 -0
- package/dist/server/sql/mfa.d.ts +36 -0
- package/dist/server/sql/mfa.js +51 -0
- package/dist/server/sql/passkeys.d.ts +25 -0
- package/dist/server/sql/passkeys.js +33 -0
- package/dist/server/sql/recovery-codes.d.ts +22 -0
- package/dist/server/sql/recovery-codes.js +32 -0
- package/package.json +910 -12
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Core domain types for the `members` Tier-2 core library (ADR-030).
|
|
3
|
+
*
|
|
4
|
+
* Purpose:
|
|
5
|
+
* Type-only definitions for front-end membership: member accounts (a distinct
|
|
6
|
+
* principal kind from admin operators — ADR-021), tiers/subscriptions, gated
|
|
7
|
+
* content access, and member sign-in sessions kept isolated from the admin
|
|
8
|
+
* session (ADR-020/021/025).
|
|
9
|
+
*
|
|
10
|
+
* Architectural role:
|
|
11
|
+
* These are the row/domain shapes the `members` library owns. They mirror the
|
|
12
|
+
* `features/*` conventions (records + workspace-scoped ports in ADR-030's
|
|
13
|
+
* `ports.ts`). No feature logic lives here — interfaces and types only.
|
|
14
|
+
*
|
|
15
|
+
* Scope note (ADR-030 §Trust boundary):
|
|
16
|
+
* A `member` is an authenticated NON-operator principal governed by the
|
|
17
|
+
* *entitlement* axis (tier membership), never by the operator RBAC axis
|
|
18
|
+
* (ADR-021 §1). Nothing in this file grants a member an operator permission.
|
|
19
|
+
*/
|
|
20
|
+
import type { ISODateTime, JsonObject, UUID } from "@jini-ai/core/primitives";
|
|
21
|
+
import type { PrincipalKind } from "../core/index.js";
|
|
22
|
+
/**
|
|
23
|
+
* Principal kind for a front-end member: `@jini-ai/user-management`'s `"member"` kind, distinct from
|
|
24
|
+
* the operator kinds `user | agent | api_key | system`. Sign-up writes a principal row of this kind
|
|
25
|
+
* (`write-service.ts`), and `authorize()` denies it every operator permission through the single
|
|
26
|
+
* `principalKindMayExercisePermission` rule. OWNER DECISION 2026-10-04 (F3144): members may not use
|
|
27
|
+
* admin features for now; allowing some later is a change to that one rule.
|
|
28
|
+
*/
|
|
29
|
+
export type MemberPrincipalKind = Extract<PrincipalKind, "member">;
|
|
30
|
+
/**
|
|
31
|
+
* Member account lifecycle. Disable-only, never hard-deleted, because a member
|
|
32
|
+
* is an ADR-021 principal and `change_set.actorId` / revision history must not
|
|
33
|
+
* dangle (ADR-021 §5). `pending` = created but email not yet verified.
|
|
34
|
+
*/
|
|
35
|
+
export type MemberStatus = "pending" | "active" | "disabled" | "trash";
|
|
36
|
+
/** Trusted issuer/subject association, independent of the member's current email.
|
|
37
|
+
* An unlink marker reserves the member/provider pair until an explicit signed-in reconnect.
|
|
38
|
+
* No provider tokens, client secrets or claims are persisted here (Google login review, S1).
|
|
39
|
+
*/
|
|
40
|
+
export interface MemberExternalIdentityRecord {
|
|
41
|
+
id: UUID;
|
|
42
|
+
workspaceId: UUID;
|
|
43
|
+
memberId: UUID;
|
|
44
|
+
providerId: string;
|
|
45
|
+
issuer: string;
|
|
46
|
+
subject: string;
|
|
47
|
+
linkedAt: ISODateTime;
|
|
48
|
+
unlinkedAt?: ISODateTime;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Front-end member account. `id` is the member's principal id (ULID); the row
|
|
52
|
+
* is the member's profile, analogous to ADR-021's `users` table for operators.
|
|
53
|
+
* Password hashes are credential-only and never enter this profile/view model.
|
|
54
|
+
*/
|
|
55
|
+
export interface MemberRecord {
|
|
56
|
+
/** Principal id (ULID). Root of identity + audit; disable-only (ADR-021 §5). */
|
|
57
|
+
id: UUID;
|
|
58
|
+
/** Workspace boundary — carried on every scoped row (ADR-007). */
|
|
59
|
+
workspaceId: UUID;
|
|
60
|
+
/** Primary sign-in identifier; unique per workspace (case-folded on write). */
|
|
61
|
+
email: string;
|
|
62
|
+
/** Optional display name. */
|
|
63
|
+
name?: string | undefined;
|
|
64
|
+
/** Set once the email is verified (magic-link click or explicit verify). */
|
|
65
|
+
emailVerifiedAt?: ISODateTime;
|
|
66
|
+
/** Credential cutoff: only Trash/restore or explicit revocation changes it. */
|
|
67
|
+
credentialsRevokedAt?: ISODateTime;
|
|
68
|
+
/** Lifecycle state (disable-only). */
|
|
69
|
+
status: MemberStatus;
|
|
70
|
+
/** Operator-only private note (never exposed on the member origin). */
|
|
71
|
+
note?: string | undefined;
|
|
72
|
+
/** Namespaced, validated extension bag (`ext.{owner}.*`), per ADR-022 §2. */
|
|
73
|
+
fields?: JsonObject;
|
|
74
|
+
createdAt: ISODateTime;
|
|
75
|
+
updatedAt: ISODateTime;
|
|
76
|
+
/** Monotonic optimistic-concurrency version (ADR-022 §4c). */
|
|
77
|
+
version: number;
|
|
78
|
+
}
|
|
79
|
+
/** Whether a tier is free or paid. Billing itself is deferred (ADR-030 §6). */
|
|
80
|
+
export type MemberTierType = "free" | "paid";
|
|
81
|
+
/** Tier lifecycle. Archived tiers stop accepting new subscriptions. */
|
|
82
|
+
export type MemberTierStatus = "active" | "archived";
|
|
83
|
+
/**
|
|
84
|
+
* A membership tier (Ghost's "tier"). Registry-as-data, mirroring ADR-022
|
|
85
|
+
* content-types / ADR-028 setting-definitions / ADR-027 transform-registry.
|
|
86
|
+
* Price columns are nullable seams: no billing engine ships in v1 (ADR-030 §6).
|
|
87
|
+
*/
|
|
88
|
+
export interface MemberTierRecord {
|
|
89
|
+
id: UUID;
|
|
90
|
+
workspaceId: UUID;
|
|
91
|
+
name: string;
|
|
92
|
+
/** URL/identifier slug, unique per workspace. */
|
|
93
|
+
slug: string;
|
|
94
|
+
type: MemberTierType;
|
|
95
|
+
status: MemberTierStatus;
|
|
96
|
+
description?: string;
|
|
97
|
+
/** Optional post-signup welcome page path on the public origin. */
|
|
98
|
+
welcomePagePath?: string;
|
|
99
|
+
/** Whether the tier is offered in the public portal (vs comp-only). */
|
|
100
|
+
visibleInPortal: boolean;
|
|
101
|
+
/** Deferred billing seams — populated only by a future billing plugin. */
|
|
102
|
+
monthlyPriceCents?: number;
|
|
103
|
+
yearlyPriceCents?: number;
|
|
104
|
+
/** ISO-4217 code (e.g. "usd"); null until a paid tier is priced. */
|
|
105
|
+
currency?: string;
|
|
106
|
+
createdAt: ISODateTime;
|
|
107
|
+
updatedAt: ISODateTime;
|
|
108
|
+
version: number;
|
|
109
|
+
}
|
|
110
|
+
/** Subscription lifecycle state; drives entitlement resolution. */
|
|
111
|
+
export type MemberSubscriptionStatus = "active" | "canceled" | "expired" | "comped";
|
|
112
|
+
/**
|
|
113
|
+
* How a subscription came to exist. `billing` rows are written by a future
|
|
114
|
+
* tier-3 billing plugin through the core chokepoint (ADR-030 §6); v1 core mints
|
|
115
|
+
* `signup` (free) and `comped` (operator-granted) rows only.
|
|
116
|
+
*/
|
|
117
|
+
export type MemberSubscriptionSource = "signup" | "comp" | "billing";
|
|
118
|
+
/**
|
|
119
|
+
* A member's entitlement to a tier. The join carries its own `workspaceId` so
|
|
120
|
+
* the composite `(workspace_id, id)` FKs of ADR-021 §4 are buildable.
|
|
121
|
+
*/
|
|
122
|
+
export interface MemberSubscriptionRecord {
|
|
123
|
+
id: UUID;
|
|
124
|
+
workspaceId: UUID;
|
|
125
|
+
/** Composite FK → members(workspace_id, id). */
|
|
126
|
+
memberId: UUID;
|
|
127
|
+
/** Composite FK → member_tiers(workspace_id, id). */
|
|
128
|
+
tierId: UUID;
|
|
129
|
+
status: MemberSubscriptionStatus;
|
|
130
|
+
source: MemberSubscriptionSource;
|
|
131
|
+
/** Opaque provider reference (e.g. Stripe subscription id); billing-only. */
|
|
132
|
+
externalRef?: string | undefined;
|
|
133
|
+
startedAt: ISODateTime;
|
|
134
|
+
/** For paid/timeboxed entitlements; absent for open-ended free membership. */
|
|
135
|
+
currentPeriodEnd?: ISODateTime;
|
|
136
|
+
canceledAt?: ISODateTime | undefined;
|
|
137
|
+
createdAt: ISODateTime;
|
|
138
|
+
updatedAt: ISODateTime;
|
|
139
|
+
version: number;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* A member sign-in session. DELIBERATELY a separate table + cookie + origin
|
|
143
|
+
* from the operator `sessions` of ADR-021 §7 — a member session must never be
|
|
144
|
+
* replayable against an admin route (ADR-030 §3, ADR-020/025 origin isolation).
|
|
145
|
+
*/
|
|
146
|
+
export interface MemberSessionRecord {
|
|
147
|
+
id: UUID;
|
|
148
|
+
workspaceId: UUID;
|
|
149
|
+
/** Composite FK → members(workspace_id, id). */
|
|
150
|
+
memberId: UUID;
|
|
151
|
+
/** Argon2id/HMAC hash of the session token; the raw token never persists. */
|
|
152
|
+
tokenHash: string;
|
|
153
|
+
createdAt: ISODateTime;
|
|
154
|
+
expiresAt: ISODateTime;
|
|
155
|
+
/** Server-side revocation (ADR-021 §7 revocable sessions). */
|
|
156
|
+
revokedAt?: ISODateTime | undefined;
|
|
157
|
+
lastSeenAt?: ISODateTime;
|
|
158
|
+
userAgent?: string | undefined;
|
|
159
|
+
ip?: string | undefined;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* A single-use, short-TTL member challenge shared by its link and optional sign-in code.
|
|
163
|
+
* Stored hashed; consumed exactly once, then tombstoned. Staff uses a separate realm.
|
|
164
|
+
*/
|
|
165
|
+
export interface MagicLinkTokenRecord {
|
|
166
|
+
id: UUID;
|
|
167
|
+
workspaceId: UUID;
|
|
168
|
+
/** Existing member id, or reserved id for a new address until consumption. */
|
|
169
|
+
memberId: UUID;
|
|
170
|
+
/** New-address challenge identity; absent on legacy/existing-member links. */
|
|
171
|
+
email?: string;
|
|
172
|
+
tokenHash: string;
|
|
173
|
+
/** Absent for legacy links and link-only password resets; never the raw code. */
|
|
174
|
+
codeHash?: string | undefined;
|
|
175
|
+
/** Absent on legacy records means zero; incremented atomically by the repository. */
|
|
176
|
+
failedAttempts?: number;
|
|
177
|
+
/** What the click authorizes — first sign-in also verifies the email. */
|
|
178
|
+
purpose: "signin" | "signup" | "email_change" | "password_reset";
|
|
179
|
+
createdAt: ISODateTime;
|
|
180
|
+
expiresAt: ISODateTime;
|
|
181
|
+
consumedAt?: ISODateTime | undefined;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Content visibility levels stored on an entry at `fields.ext.members.access`
|
|
185
|
+
* (ADR-022 §2 namespaced ext field — no new content table). Mirrors Ghost's
|
|
186
|
+
* public / members / paid / specific-tiers model.
|
|
187
|
+
*/
|
|
188
|
+
export type MemberContentVisibility = "public" | "members" | "paid" | "tiers";
|
|
189
|
+
/** The validated ext-field shape written onto a gated entry. */
|
|
190
|
+
export interface MemberContentAccess {
|
|
191
|
+
visibility: MemberContentVisibility;
|
|
192
|
+
/** Required when `visibility === "tiers"`: the entitled tier ids. */
|
|
193
|
+
tierIds?: UUID[];
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* The resolved membership context for one front-end request. Anonymous callers
|
|
197
|
+
* get `{ isAuthenticated: false, activeTierIds: [] }`. Derived from a validated
|
|
198
|
+
* member session (never from a client-supplied claim).
|
|
199
|
+
*/
|
|
200
|
+
export interface MemberContext {
|
|
201
|
+
isAuthenticated: boolean;
|
|
202
|
+
memberId?: UUID;
|
|
203
|
+
/** Tier ids the member currently has an active/comped subscription to. */
|
|
204
|
+
activeTierIds: UUID[];
|
|
205
|
+
/** True if any active tier is a paid tier. */
|
|
206
|
+
isPaid: boolean;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Outcome of the core content-access decision. This is an ENTITLEMENT decision
|
|
210
|
+
* (tier membership axis), evaluated by the `members` library at the read
|
|
211
|
+
* chokepoint — NOT the ADR-021 operator RBAC `authorize()` (ADR-030 §4).
|
|
212
|
+
*/
|
|
213
|
+
export interface MemberAccessDecision {
|
|
214
|
+
allowed: boolean;
|
|
215
|
+
/** The entry's declared visibility that produced this decision. */
|
|
216
|
+
visibility: MemberContentVisibility;
|
|
217
|
+
/** Machine-readable reason, e.g. "public", "entitled", "upgrade_required". */
|
|
218
|
+
reason: string;
|
|
219
|
+
/**
|
|
220
|
+
* When `allowed === false`, whether a truncated teaser/paywall may still be
|
|
221
|
+
* rendered (Ghost's "public preview") rather than a hard 404.
|
|
222
|
+
*/
|
|
223
|
+
teaser: boolean;
|
|
224
|
+
}
|
|
225
|
+
/** Raised when a member sign-in credential is invalid, expired, or consumed. */
|
|
226
|
+
export declare class MemberAuthError extends Error {
|
|
227
|
+
}
|
|
228
|
+
/** Why a sign-in link or code was refused at consumption time. */
|
|
229
|
+
export type MagicLinkTokenRejection = "not_found" | "expired" | "already_consumed";
|
|
230
|
+
/**
|
|
231
|
+
* Raised by a magic-link repo when it refuses to consume a token for a known single-use reason.
|
|
232
|
+
* Callers match on the class and `reason`, never on message text; any other error is an outage.
|
|
233
|
+
*/
|
|
234
|
+
export declare class MagicLinkTokenRejectedError extends Error {
|
|
235
|
+
readonly reason: MagicLinkTokenRejection;
|
|
236
|
+
constructor({ id, reason }: {
|
|
237
|
+
id: string;
|
|
238
|
+
reason: MagicLinkTokenRejection;
|
|
239
|
+
}, _options?: Record<string, never>);
|
|
240
|
+
}
|
|
241
|
+
/** A passwordless member must prove inbox access again before setting a password. */
|
|
242
|
+
export declare class MemberReauthenticationRequiredError extends MemberAuthError {
|
|
243
|
+
}
|
|
244
|
+
/** Site-wide setup failure; safe to expose before any per-address lookup. */
|
|
245
|
+
export declare class MemberSignInUnavailableError extends Error {
|
|
246
|
+
}
|
|
247
|
+
/** Raised when a member profile/tier/subscription payload fails validation. */
|
|
248
|
+
export declare class MemberValidationError extends Error {
|
|
249
|
+
}
|
|
250
|
+
/** Raised on a unique-constraint clash (e.g. duplicate email or tier slug). */
|
|
251
|
+
export declare class MemberConflictError extends Error {
|
|
252
|
+
}
|
|
253
|
+
/** Raised when a member, tier, or subscription is not found in the workspace. */
|
|
254
|
+
export declare class MemberNotFoundError extends Error {
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* D1c consent — Members-owned, purpose-keyed consent records (ADR-PIPE-013
|
|
258
|
+
* Decision §4, crosscutting-sweep D1c LOCKED 4-0).
|
|
259
|
+
*
|
|
260
|
+
* Purpose is a module-prefixed string (e.g. `"marketing-email"`,
|
|
261
|
+
* `"newsletter:{listId}"`, `"feature:{ns}:{id}"`) rather than a closed union —
|
|
262
|
+
* new modules mint their own namespaced purposes without touching this file
|
|
263
|
+
* (Article III: no speculative enum, just a documented string convention).
|
|
264
|
+
* The exported purpose type follows the stored consent record's field.
|
|
265
|
+
*/
|
|
266
|
+
export type ConsentPurpose = MemberConsentRecord["purpose"];
|
|
267
|
+
/** Consent lifecycle. Only `confirmConsent` may produce `'granted'` (INV-NEW-02) — see `consent-service.ts`. */
|
|
268
|
+
export type ConsentStatus = "pending" | "granted" | "revoked";
|
|
269
|
+
/** Evidence captured alongside a consent state change (never the raw consent-text body — a reference/hash only). */
|
|
270
|
+
export interface ConsentEvidence {
|
|
271
|
+
/** Reference to the consent copy shown (e.g. a CMS entry id), not the text itself. */
|
|
272
|
+
consentTextRef?: string;
|
|
273
|
+
/** Hash of the consent copy shown, for tamper-evidence without storing the body. */
|
|
274
|
+
consentTextHash?: string;
|
|
275
|
+
/** Where the request/confirmation originated, e.g. `"newsletter-signup-form"`. */
|
|
276
|
+
source: string;
|
|
277
|
+
/** The magic/confirm-token id that authorized a `confirmConsent` call, when applicable. */
|
|
278
|
+
confirmTokenId?: string;
|
|
279
|
+
ip?: string | undefined;
|
|
280
|
+
userAgent?: string | undefined;
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* A member's consent record for one `(memberId, purpose)` pair. Reaches
|
|
284
|
+
* `status: 'granted'` ONLY via `requestConsent` then `confirmConsent` in
|
|
285
|
+
* sequence (INV-NEW-02) — no caller may assert `granted` directly.
|
|
286
|
+
*/
|
|
287
|
+
export interface MemberConsentRecord {
|
|
288
|
+
id: UUID;
|
|
289
|
+
workspaceId: UUID;
|
|
290
|
+
/** Composite FK → members(workspace_id, id). */
|
|
291
|
+
memberId: UUID;
|
|
292
|
+
purpose: string;
|
|
293
|
+
status: ConsentStatus;
|
|
294
|
+
evidence: ConsentEvidence;
|
|
295
|
+
grantedAt?: ISODateTime | undefined;
|
|
296
|
+
revokedAt?: ISODateTime | undefined;
|
|
297
|
+
createdAt: ISODateTime;
|
|
298
|
+
updatedAt: ISODateTime;
|
|
299
|
+
version: number;
|
|
300
|
+
}
|
|
301
|
+
/** A consent state-change op recorded on the shared `member_revisions` ledger (`entity_kind='consent'`). */
|
|
302
|
+
export type ConsentRevisionOp = "consent_request" | "consent_confirm" | "consent_revoke";
|
|
303
|
+
/**
|
|
304
|
+
* One append-only `member_revisions` row documenting a consent state change.
|
|
305
|
+
* `originModule` attributes the call to the caller (e.g. `"newsletter"`) —
|
|
306
|
+
* satisfies "attributed" without inventing ADR-024 capability infrastructure
|
|
307
|
+
* (ADR-PIPE-013 Decision §4 capability-gating scope decision).
|
|
308
|
+
*/
|
|
309
|
+
export interface MemberConsentRevisionRecord {
|
|
310
|
+
seq: number;
|
|
311
|
+
workspaceId: UUID;
|
|
312
|
+
memberId: UUID;
|
|
313
|
+
consentId: UUID;
|
|
314
|
+
purpose: ConsentPurpose;
|
|
315
|
+
op: ConsentRevisionOp;
|
|
316
|
+
beforeJson: JsonObject | null;
|
|
317
|
+
afterJson: JsonObject | null;
|
|
318
|
+
originModule: string;
|
|
319
|
+
createdAt: ISODateTime;
|
|
320
|
+
}
|
|
321
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/** Raised when a member sign-in credential is invalid, expired, or consumed. */
|
|
2
|
+
export class MemberAuthError extends Error {
|
|
3
|
+
}
|
|
4
|
+
const MAGIC_LINK_REJECTION_TEXT = {
|
|
5
|
+
not_found: "was not found", expired: "has expired", already_consumed: "was already consumed",
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Raised by a magic-link repo when it refuses to consume a token for a known single-use reason.
|
|
9
|
+
* Callers match on the class and `reason`, never on message text; any other error is an outage.
|
|
10
|
+
*/
|
|
11
|
+
export class MagicLinkTokenRejectedError extends Error {
|
|
12
|
+
reason;
|
|
13
|
+
constructor({ id, reason }, _options = {}) {
|
|
14
|
+
super(`magic link token '${id}' ${MAGIC_LINK_REJECTION_TEXT[reason]}`);
|
|
15
|
+
this.name = "MagicLinkTokenRejectedError";
|
|
16
|
+
this.reason = reason;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
/** A passwordless member must prove inbox access again before setting a password. */
|
|
20
|
+
export class MemberReauthenticationRequiredError extends MemberAuthError {
|
|
21
|
+
}
|
|
22
|
+
/** Site-wide setup failure; safe to expose before any per-address lookup. */
|
|
23
|
+
export class MemberSignInUnavailableError extends Error {
|
|
24
|
+
}
|
|
25
|
+
/** Raised when a member profile/tier/subscription payload fails validation. */
|
|
26
|
+
export class MemberValidationError extends Error {
|
|
27
|
+
}
|
|
28
|
+
/** Raised on a unique-constraint clash (e.g. duplicate email or tier slug). */
|
|
29
|
+
export class MemberConflictError extends Error {
|
|
30
|
+
}
|
|
31
|
+
/** Raised when a member, tier, or subscription is not found in the workspace. */
|
|
32
|
+
export class MemberNotFoundError extends Error {
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file `MembersWriteService` implementation (ADR-030 §3/§6, plus the member sign-in amendment).
|
|
3
|
+
*
|
|
4
|
+
* The single write chokepoint for member-domain mutations: email sign-in (link + code), profile
|
|
5
|
+
* updates, disable-only lifecycle and comp/subscription changes, plus the host adapters for
|
|
6
|
+
* Jini's shared email-challenge primitives. Plain async functions taking `{ deps, input }`.
|
|
7
|
+
*
|
|
8
|
+
* New-address challenges reserve a member id and carry the email, without creating a member or
|
|
9
|
+
* principal. Consumption resolves that email again and creates the member then. Legacy
|
|
10
|
+
* challenges without an email remain bound to their existing member id.
|
|
11
|
+
*/
|
|
12
|
+
import type { MembersWriteService } from "./ports.js";
|
|
13
|
+
/**
|
|
14
|
+
* The `MembersWriteService` implementation, grouped into the port shape.
|
|
15
|
+
*/
|
|
16
|
+
export declare const membersWriteService: MembersWriteService;
|
|
17
|
+
//# sourceMappingURL=write-service.d.ts.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { requestSignInLink } from "./member-challenge-request.js";
|
|
2
|
+
import { completeSignIn } from "./member-sign-in.js";
|
|
3
|
+
import { updateProfile, disableMember, compSubscription, setSubscriptionStatus } from "./member-admin-writes.js";
|
|
4
|
+
/**
|
|
5
|
+
* The `MembersWriteService` implementation, grouped into the port shape.
|
|
6
|
+
*/
|
|
7
|
+
export const membersWriteService = {
|
|
8
|
+
requestSignInLink,
|
|
9
|
+
completeSignIn,
|
|
10
|
+
updateProfile,
|
|
11
|
+
disableMember,
|
|
12
|
+
compSubscription,
|
|
13
|
+
setSubscriptionStatus,
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=write-service.js.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { AgentToolDefinition as SharedAgentToolDefinition } from "@jini-ai/core";
|
|
2
|
+
declare const MUTATES_DURABLE_STATE: "mutates-durable-state";
|
|
3
|
+
/** Bulk import stays absent: 1-500 imported contacts can each trigger a real confirmation email,
|
|
4
|
+
* so one call creates third-party mail at scale. Single-contact adds send double-opt-in links,
|
|
5
|
+
* never campaign content or an assertion of consent. Pause/unsubscribe only narrow delivery.
|
|
6
|
+
* Shared editorial bounds come from the validators so published schemas cannot drift from them.
|
|
7
|
+
* The catalog declares permissions but performs no authorization; registration handlers must
|
|
8
|
+
* check them explicitly because Newsletter domain services do not authorize themselves. */
|
|
9
|
+
export type AgentToolSideEffect = "none" | typeof MUTATES_DURABLE_STATE | "mints-token";
|
|
10
|
+
export type { AgentToolActorClassRule } from "@jini-ai/core";
|
|
11
|
+
/**
|
|
12
|
+
* JSON Schema for this tool's `input`, published to the model via `ToolDescriptor.inputSchema`
|
|
13
|
+
* (`assistant/tool-registrations.ts`, which refuses to wire any tool lacking one).
|
|
14
|
+
*/
|
|
15
|
+
export type AgentToolDefinition = SharedAgentToolDefinition & {
|
|
16
|
+
sideEffects: AgentToolSideEffect;
|
|
17
|
+
};
|
|
18
|
+
/** Newsletter's fixed agent-tool catalog. */
|
|
19
|
+
export declare const newsletterAgentToolCatalog: AgentToolDefinition[];
|
|
20
|
+
//# sourceMappingURL=agent-tools.d.ts.map
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Newsletter composition, list and subscription catalog.
|
|
3
|
+
* Delivery tools live in delivery/tool-registrations.ts. Mass sends, scheduling and resume require
|
|
4
|
+
* browser-only approval; opt-in resends and owner test sends run directly.
|
|
5
|
+
* Bulk subscription import remains unavailable to the assistant.
|
|
6
|
+
*/
|
|
7
|
+
import { PREHEADER_MAX, SUBJECT_MAX, SUBJECT_MIN } from "./campaign-write-service.js";
|
|
8
|
+
const MUTATES_DURABLE_STATE = "mutates-durable-state";
|
|
9
|
+
const CAMPAIGN_ID_SCHEMA = {
|
|
10
|
+
type: "string",
|
|
11
|
+
minLength: 1,
|
|
12
|
+
description: "The campaign's id. Get it from newsletter_create_campaign's result or {{read:newsletter_campaign}}.",
|
|
13
|
+
};
|
|
14
|
+
const LIST_ID_SCHEMA = {
|
|
15
|
+
type: "string",
|
|
16
|
+
minLength: 1,
|
|
17
|
+
description: "A newsletter list's id. Get it from newsletter_create_list's result or {{read:newsletter_list}}.",
|
|
18
|
+
};
|
|
19
|
+
/** Campaign editorial fields shared by `create`/`update` — every field but `listId` maps 1:1 onto `CampaignRecord`. */
|
|
20
|
+
const CAMPAIGN_FIELDS_PROPERTIES = {
|
|
21
|
+
subject: {
|
|
22
|
+
type: "string",
|
|
23
|
+
minLength: SUBJECT_MIN,
|
|
24
|
+
maxLength: SUBJECT_MAX,
|
|
25
|
+
description: `Email subject line (${SUBJECT_MIN}-${SUBJECT_MAX} characters).`,
|
|
26
|
+
},
|
|
27
|
+
preheader: {
|
|
28
|
+
type: ["string", "null"],
|
|
29
|
+
maxLength: PREHEADER_MAX,
|
|
30
|
+
description: `Optional inbox-preview text (max ${PREHEADER_MAX} characters). Omit or pass null for none.`,
|
|
31
|
+
},
|
|
32
|
+
fromName: { type: "string", minLength: 1, description: "Envelope From display name." },
|
|
33
|
+
fromEmail: { type: "string", minLength: 1, description: "Envelope From address." },
|
|
34
|
+
replyTo: { type: "string", minLength: 1, description: "Reply-To address." },
|
|
35
|
+
listId: LIST_ID_SCHEMA,
|
|
36
|
+
};
|
|
37
|
+
/** Newsletter's fixed agent-tool catalog. */
|
|
38
|
+
export const newsletterAgentToolCatalog = [
|
|
39
|
+
// --- Read tools ---
|
|
40
|
+
{
|
|
41
|
+
name: "newsletter_list_campaigns",
|
|
42
|
+
description: "Lists the workspace's campaigns, optionally filtered by status. Read-only. Call this to find a campaign's id before getting, updating, canceling, or pausing it.",
|
|
43
|
+
sideEffects: "none",
|
|
44
|
+
authorization: { permission: "admin.newsletter.read" },
|
|
45
|
+
inputSchema: {
|
|
46
|
+
type: "object",
|
|
47
|
+
additionalProperties: false,
|
|
48
|
+
required: [],
|
|
49
|
+
properties: {
|
|
50
|
+
limit: { type: "integer", minimum: 1, maximum: 100, clamp: true, description: "Maximum campaigns to scan per page." },
|
|
51
|
+
cursor: { type: "string", description: "nextCursor from the previous call. Omit for the first page." },
|
|
52
|
+
status: {
|
|
53
|
+
type: "string",
|
|
54
|
+
enum: ["draft", "scheduled", "sending", "sent", "paused", "canceled", "failed"],
|
|
55
|
+
description: "Filter to campaigns in exactly this status. Omit to list every status.",
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
name: "newsletter_get_campaign",
|
|
62
|
+
description: "Fetches a single campaign's full details by id, including its current status and delivery counters. Read-only.",
|
|
63
|
+
sideEffects: "none",
|
|
64
|
+
authorization: { permission: "admin.newsletter.read" },
|
|
65
|
+
inputSchema: {
|
|
66
|
+
type: "object",
|
|
67
|
+
additionalProperties: false,
|
|
68
|
+
required: ["campaignId"],
|
|
69
|
+
properties: { campaignId: CAMPAIGN_ID_SCHEMA },
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
name: "newsletter_list_lists",
|
|
74
|
+
description: "Lists the workspace's subscriber lists. Read-only. Call this to find a listId before creating a campaign, adding a subscription, or archiving a list.",
|
|
75
|
+
sideEffects: "none",
|
|
76
|
+
authorization: { permission: "admin.newsletter.read" },
|
|
77
|
+
inputSchema: {
|
|
78
|
+
type: "object",
|
|
79
|
+
additionalProperties: false,
|
|
80
|
+
required: [],
|
|
81
|
+
properties: {},
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
name: "newsletter_list_subscriptions",
|
|
86
|
+
description: "Lists the subscriptions on one list. Read-only.",
|
|
87
|
+
sideEffects: "none",
|
|
88
|
+
authorization: { permission: "admin.newsletter.subscriber.read" },
|
|
89
|
+
inputSchema: {
|
|
90
|
+
type: "object",
|
|
91
|
+
additionalProperties: false,
|
|
92
|
+
required: ["listId"],
|
|
93
|
+
properties: { listId: LIST_ID_SCHEMA,
|
|
94
|
+
limit: { type: "integer", minimum: 1, maximum: 100, clamp: true, description: "Maximum subscriptions per page." },
|
|
95
|
+
cursor: { type: "string", description: "nextCursor from the previous call. Omit for the first page." } },
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
name: "newsletter_list_send_log",
|
|
100
|
+
description: "Lists the per-recipient delivery log for one campaign (id, recipient email, delivery status, attempts). Read-only; PII-adjacent (recipient email addresses). Returns at most 100 rows per page; supply the previous nextCursor and stop on null.",
|
|
101
|
+
sideEffects: "none",
|
|
102
|
+
authorization: { permission: "admin.newsletter.subscriber.read" },
|
|
103
|
+
inputSchema: {
|
|
104
|
+
type: "object",
|
|
105
|
+
additionalProperties: false,
|
|
106
|
+
required: ["campaignId"],
|
|
107
|
+
properties: { campaignId: CAMPAIGN_ID_SCHEMA,
|
|
108
|
+
limit: { type: "integer", minimum: 1, maximum: 100, clamp: true, description: "Maximum send rows per page." },
|
|
109
|
+
cursor: { type: "string", description: "nextCursor from the previous call. Omit for the first page." } },
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
// --- Write tools: draft campaign composition (never touches status) ---
|
|
113
|
+
{
|
|
114
|
+
name: "newsletter_create_campaign",
|
|
115
|
+
description: "Creates a new newsletter campaign in 'draft' status. Returns {campaign}. Use newsletter_update_campaign to edit it, newsletter_send_test for an owner-only test, or newsletter_send_campaign/newsletter_schedule_campaign for a human-confirmed subscriber send. Refuses an unknown list or invalid editorial fields.",
|
|
116
|
+
sideEffects: MUTATES_DURABLE_STATE,
|
|
117
|
+
authorization: { permission: "admin.newsletter.campaign.compose" },
|
|
118
|
+
inputSchema: {
|
|
119
|
+
type: "object",
|
|
120
|
+
additionalProperties: false,
|
|
121
|
+
required: ["subject", "fromName", "fromEmail", "replyTo", "listId"],
|
|
122
|
+
properties: CAMPAIGN_FIELDS_PROPERTIES,
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
name: "newsletter_update_campaign",
|
|
127
|
+
description: "Edits an existing campaign's editorial fields (subject/preheader/fromName/fromEmail/replyTo/listId). Only works while the campaign is 'draft' — refused once it is scheduled or beyond. A partial patch: omitted fields keep their current value. Never changes status.",
|
|
128
|
+
sideEffects: MUTATES_DURABLE_STATE,
|
|
129
|
+
authorization: { permission: "admin.newsletter.campaign.compose" },
|
|
130
|
+
inputSchema: {
|
|
131
|
+
type: "object",
|
|
132
|
+
additionalProperties: false,
|
|
133
|
+
required: ["campaignId"],
|
|
134
|
+
properties: { campaignId: CAMPAIGN_ID_SCHEMA, ...CAMPAIGN_FIELDS_PROPERTIES },
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
name: "newsletter_cancel_campaign",
|
|
139
|
+
description: "Cancels a 'draft' or 'scheduled' campaign, terminally taking it out of the send pipeline before it ever sends. This is a safety/rollback action — it never causes mail to go out, only prevents it. Cannot cancel a campaign that is already 'sending' or 'sent'.",
|
|
140
|
+
sideEffects: MUTATES_DURABLE_STATE,
|
|
141
|
+
authorization: { permission: "admin.newsletter.campaign.compose" },
|
|
142
|
+
inputSchema: {
|
|
143
|
+
type: "object",
|
|
144
|
+
additionalProperties: false,
|
|
145
|
+
required: ["campaignId"],
|
|
146
|
+
properties: { campaignId: CAMPAIGN_ID_SCHEMA },
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
name: "newsletter_pause_campaign",
|
|
151
|
+
description: "Pauses a campaign that is actively 'sending', halting remaining recipients without a confirmation card. An in-flight recipient may finish. Returns {campaign}. Use newsletter_resume_campaign to resume with human confirmation. Refuses campaigns that are not sending.",
|
|
152
|
+
sideEffects: MUTATES_DURABLE_STATE,
|
|
153
|
+
authorization: { permission: "admin.newsletter.campaign.send" },
|
|
154
|
+
inputSchema: {
|
|
155
|
+
type: "object",
|
|
156
|
+
additionalProperties: false,
|
|
157
|
+
required: ["campaignId"],
|
|
158
|
+
properties: { campaignId: CAMPAIGN_ID_SCHEMA },
|
|
159
|
+
},
|
|
160
|
+
},
|
|
161
|
+
// --- Write tools: lists ---
|
|
162
|
+
{
|
|
163
|
+
name: "newsletter_create_list",
|
|
164
|
+
description: "Creates a new subscriber list with a unique name and slug. Always created active, never the default list.",
|
|
165
|
+
sideEffects: MUTATES_DURABLE_STATE,
|
|
166
|
+
authorization: { permission: "admin.newsletter.list.manage" },
|
|
167
|
+
inputSchema: {
|
|
168
|
+
type: "object",
|
|
169
|
+
additionalProperties: false,
|
|
170
|
+
required: ["name", "slug"],
|
|
171
|
+
properties: {
|
|
172
|
+
name: { type: "string", minLength: 1, description: "Human-readable list name." },
|
|
173
|
+
slug: { type: "string", minLength: 1, description: "Unique-per-workspace slug." },
|
|
174
|
+
},
|
|
175
|
+
},
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
name: "newsletter_archive_list",
|
|
179
|
+
description: "Archives a subscriber list. The workspace's default 'all subscribers' list can never be archived and is refused.",
|
|
180
|
+
sideEffects: MUTATES_DURABLE_STATE,
|
|
181
|
+
authorization: { permission: "admin.newsletter.list.manage" },
|
|
182
|
+
inputSchema: {
|
|
183
|
+
type: "object",
|
|
184
|
+
additionalProperties: false,
|
|
185
|
+
required: ["listId"],
|
|
186
|
+
properties: { listId: LIST_ID_SCHEMA },
|
|
187
|
+
},
|
|
188
|
+
},
|
|
189
|
+
// --- Write tools: individual subscriptions (never bulk import — see file header) ---
|
|
190
|
+
{
|
|
191
|
+
name: "newsletter_create_subscription",
|
|
192
|
+
description: "Adds a single existing Members subscriber to a list, creating a 'pending' subscription and emailing them ONE double-opt-in confirmation link (they must still click it to become 'subscribed'). subscriberId must resolve to an existing Members principal. Never sends marketing content — only the confirmation link.",
|
|
193
|
+
sideEffects: MUTATES_DURABLE_STATE,
|
|
194
|
+
authorization: { permission: "admin.newsletter.subscriber.manage" },
|
|
195
|
+
inputSchema: {
|
|
196
|
+
type: "object",
|
|
197
|
+
additionalProperties: false,
|
|
198
|
+
required: ["listId", "subscriberId"],
|
|
199
|
+
properties: {
|
|
200
|
+
listId: LIST_ID_SCHEMA,
|
|
201
|
+
subscriberId: { type: "string", minLength: 1, description: "An existing Members subscriber's id." },
|
|
202
|
+
source: { type: "string", enum: ["admin", "import", "api"], description: "Provenance tag for audit/consent purposes. Defaults to 'admin'." },
|
|
203
|
+
},
|
|
204
|
+
},
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
name: "newsletter_remove_subscription",
|
|
208
|
+
description: "Unsubscribes one existing subscription (admin-triggered removal, by id — not a caller-supplied email). Idempotent: removing an already-unsubscribed subscription is a no-op success. This only ever narrows a subscriber's access to future sends, never grants or re-adds it.",
|
|
209
|
+
sideEffects: MUTATES_DURABLE_STATE,
|
|
210
|
+
authorization: { permission: "admin.newsletter.subscriber.manage" },
|
|
211
|
+
inputSchema: {
|
|
212
|
+
type: "object",
|
|
213
|
+
additionalProperties: false,
|
|
214
|
+
required: ["listId", "subscriptionId"],
|
|
215
|
+
properties: {
|
|
216
|
+
listId: LIST_ID_SCHEMA,
|
|
217
|
+
subscriptionId: { type: "string", minLength: 1, description: "The subscription's id, as returned by newsletter_create_subscription or newsletter_list_subscriptions." },
|
|
218
|
+
},
|
|
219
|
+
},
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
name: "newsletter_resend_confirmation",
|
|
223
|
+
description: "Resends a double-opt-in link directly. Invalidates prior links for a pending subscription. Returns {delivered:true,mailDeliveryAvailable:true} as a privacy-preserving acknowledgement, without revealing whether the subscription/contact exists or guaranteeing delivery, or {delivered:false,mailDeliveryAvailable:false,note} when mail is off and nothing was sent. Requires subscriber-management permission.",
|
|
224
|
+
sideEffects: MUTATES_DURABLE_STATE,
|
|
225
|
+
authorization: { permission: "admin.newsletter.subscriber.manage" },
|
|
226
|
+
inputSchema: {
|
|
227
|
+
type: "object",
|
|
228
|
+
additionalProperties: false,
|
|
229
|
+
required: ["subscriptionId"],
|
|
230
|
+
properties: {
|
|
231
|
+
subscriptionId: { type: "string", minLength: 1, description: "The subscription's id, as returned by newsletter_create_subscription or newsletter_list_subscriptions." },
|
|
232
|
+
},
|
|
233
|
+
},
|
|
234
|
+
},
|
|
235
|
+
];
|
|
236
|
+
//# sourceMappingURL=agent-tools.js.map
|