@kelpie/server 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +661 -0
- package/README.md +57 -0
- package/dist/app.d.ts +36 -0
- package/dist/app.d.ts.map +1 -0
- package/dist/app.js +98 -0
- package/dist/app.js.map +1 -0
- package/dist/index.d.ts +46 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +26 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/actor.d.ts +71 -0
- package/dist/lib/actor.d.ts.map +1 -0
- package/dist/lib/actor.js +48 -0
- package/dist/lib/actor.js.map +1 -0
- package/dist/lib/changes.d.ts +17 -0
- package/dist/lib/changes.d.ts.map +1 -0
- package/dist/lib/changes.js +35 -0
- package/dist/lib/changes.js.map +1 -0
- package/dist/lib/columns.d.ts +152 -0
- package/dist/lib/columns.d.ts.map +1 -0
- package/dist/lib/columns.js +126 -0
- package/dist/lib/columns.js.map +1 -0
- package/dist/lib/config.d.ts +36 -0
- package/dist/lib/config.d.ts.map +1 -0
- package/dist/lib/config.js +52 -0
- package/dist/lib/config.js.map +1 -0
- package/dist/lib/database.d.ts +57 -0
- package/dist/lib/database.d.ts.map +1 -0
- package/dist/lib/database.js +91 -0
- package/dist/lib/database.js.map +1 -0
- package/dist/lib/dates.d.ts +11 -0
- package/dist/lib/dates.d.ts.map +1 -0
- package/dist/lib/dates.js +17 -0
- package/dist/lib/dates.js.map +1 -0
- package/dist/lib/email.d.ts +42 -0
- package/dist/lib/email.d.ts.map +1 -0
- package/dist/lib/email.js +38 -0
- package/dist/lib/email.js.map +1 -0
- package/dist/lib/errors.d.ts +76 -0
- package/dist/lib/errors.d.ts.map +1 -0
- package/dist/lib/errors.js +102 -0
- package/dist/lib/errors.js.map +1 -0
- package/dist/lib/http.d.ts +59 -0
- package/dist/lib/http.d.ts.map +1 -0
- package/dist/lib/http.js +89 -0
- package/dist/lib/http.js.map +1 -0
- package/dist/lib/ids.d.ts +55 -0
- package/dist/lib/ids.d.ts.map +1 -0
- package/dist/lib/ids.js +56 -0
- package/dist/lib/ids.js.map +1 -0
- package/dist/lib/logger.d.ts +22 -0
- package/dist/lib/logger.d.ts.map +1 -0
- package/dist/lib/logger.js +43 -0
- package/dist/lib/logger.js.map +1 -0
- package/dist/lib/moduleConfig.d.ts +14 -0
- package/dist/lib/moduleConfig.d.ts.map +1 -0
- package/dist/lib/moduleConfig.js +56 -0
- package/dist/lib/moduleConfig.js.map +1 -0
- package/dist/lib/normalisation.d.ts +19 -0
- package/dist/lib/normalisation.d.ts.map +1 -0
- package/dist/lib/normalisation.js +32 -0
- package/dist/lib/normalisation.js.map +1 -0
- package/dist/lib/pagination.d.ts +104 -0
- package/dist/lib/pagination.d.ts.map +1 -0
- package/dist/lib/pagination.js +189 -0
- package/dist/lib/pagination.js.map +1 -0
- package/dist/lib/passwords.d.ts +32 -0
- package/dist/lib/passwords.d.ts.map +1 -0
- package/dist/lib/passwords.js +51 -0
- package/dist/lib/passwords.js.map +1 -0
- package/dist/lib/search.d.ts +11 -0
- package/dist/lib/search.d.ts.map +1 -0
- package/dist/lib/search.js +25 -0
- package/dist/lib/search.js.map +1 -0
- package/dist/lib/secrets.d.ts +40 -0
- package/dist/lib/secrets.d.ts.map +1 -0
- package/dist/lib/secrets.js +152 -0
- package/dist/lib/secrets.js.map +1 -0
- package/dist/lib/timezones.d.ts +38 -0
- package/dist/lib/timezones.d.ts.map +1 -0
- package/dist/lib/timezones.js +55 -0
- package/dist/lib/timezones.js.map +1 -0
- package/dist/lib/tokens.d.ts +10 -0
- package/dist/lib/tokens.d.ts.map +1 -0
- package/dist/lib/tokens.js +31 -0
- package/dist/lib/tokens.js.map +1 -0
- package/dist/lib/url.d.ts +25 -0
- package/dist/lib/url.d.ts.map +1 -0
- package/dist/lib/url.js +41 -0
- package/dist/lib/url.js.map +1 -0
- package/dist/modules/activities/index.d.ts +18 -0
- package/dist/modules/activities/index.d.ts.map +1 -0
- package/dist/modules/activities/index.js +34 -0
- package/dist/modules/activities/index.js.map +1 -0
- package/dist/modules/activities/recorder.d.ts +53 -0
- package/dist/modules/activities/recorder.d.ts.map +1 -0
- package/dist/modules/activities/recorder.js +36 -0
- package/dist/modules/activities/recorder.js.map +1 -0
- package/dist/modules/activities/repository.d.ts +52 -0
- package/dist/modules/activities/repository.d.ts.map +1 -0
- package/dist/modules/activities/repository.js +127 -0
- package/dist/modules/activities/repository.js.map +1 -0
- package/dist/modules/activities/routes.d.ts +17 -0
- package/dist/modules/activities/routes.d.ts.map +1 -0
- package/dist/modules/activities/routes.js +45 -0
- package/dist/modules/activities/routes.js.map +1 -0
- package/dist/modules/activities/schema.d.ts +188 -0
- package/dist/modules/activities/schema.d.ts.map +1 -0
- package/dist/modules/activities/schema.js +34 -0
- package/dist/modules/activities/schema.js.map +1 -0
- package/dist/modules/activities/service.d.ts +32 -0
- package/dist/modules/activities/service.d.ts.map +1 -0
- package/dist/modules/activities/service.js +28 -0
- package/dist/modules/activities/service.js.map +1 -0
- package/dist/modules/activities/tools.d.ts +4 -0
- package/dist/modules/activities/tools.d.ts.map +1 -0
- package/dist/modules/activities/tools.js +26 -0
- package/dist/modules/activities/tools.js.map +1 -0
- package/dist/modules/activities/wording.d.ts +79 -0
- package/dist/modules/activities/wording.d.ts.map +1 -0
- package/dist/modules/activities/wording.js +134 -0
- package/dist/modules/activities/wording.js.map +1 -0
- package/dist/modules/agent-tasks/catalog.d.ts +16 -0
- package/dist/modules/agent-tasks/catalog.d.ts.map +1 -0
- package/dist/modules/agent-tasks/catalog.js +694 -0
- package/dist/modules/agent-tasks/catalog.js.map +1 -0
- package/dist/modules/agent-tasks/dispatch.d.ts +61 -0
- package/dist/modules/agent-tasks/dispatch.d.ts.map +1 -0
- package/dist/modules/agent-tasks/dispatch.js +139 -0
- package/dist/modules/agent-tasks/dispatch.js.map +1 -0
- package/dist/modules/agent-tasks/index.d.ts +17 -0
- package/dist/modules/agent-tasks/index.d.ts.map +1 -0
- package/dist/modules/agent-tasks/index.js +54 -0
- package/dist/modules/agent-tasks/index.js.map +1 -0
- package/dist/modules/agent-tasks/prompt.d.ts +41 -0
- package/dist/modules/agent-tasks/prompt.d.ts.map +1 -0
- package/dist/modules/agent-tasks/prompt.js +78 -0
- package/dist/modules/agent-tasks/prompt.js.map +1 -0
- package/dist/modules/agent-tasks/repository.d.ts +32 -0
- package/dist/modules/agent-tasks/repository.d.ts.map +1 -0
- package/dist/modules/agent-tasks/repository.js +83 -0
- package/dist/modules/agent-tasks/repository.js.map +1 -0
- package/dist/modules/agent-tasks/resolve.d.ts +44 -0
- package/dist/modules/agent-tasks/resolve.d.ts.map +1 -0
- package/dist/modules/agent-tasks/resolve.js +396 -0
- package/dist/modules/agent-tasks/resolve.js.map +1 -0
- package/dist/modules/agent-tasks/routes.d.ts +55 -0
- package/dist/modules/agent-tasks/routes.d.ts.map +1 -0
- package/dist/modules/agent-tasks/routes.js +173 -0
- package/dist/modules/agent-tasks/routes.js.map +1 -0
- package/dist/modules/agent-tasks/schema.d.ts +346 -0
- package/dist/modules/agent-tasks/schema.d.ts.map +1 -0
- package/dist/modules/agent-tasks/schema.js +47 -0
- package/dist/modules/agent-tasks/schema.js.map +1 -0
- package/dist/modules/agent-tasks/service.d.ts +79 -0
- package/dist/modules/agent-tasks/service.d.ts.map +1 -0
- package/dist/modules/agent-tasks/service.js +210 -0
- package/dist/modules/agent-tasks/service.js.map +1 -0
- package/dist/modules/agent-tasks/wire.d.ts +35 -0
- package/dist/modules/agent-tasks/wire.d.ts.map +1 -0
- package/dist/modules/agent-tasks/wire.js +31 -0
- package/dist/modules/agent-tasks/wire.js.map +1 -0
- package/dist/modules/api-keys/index.d.ts +9 -0
- package/dist/modules/api-keys/index.d.ts.map +1 -0
- package/dist/modules/api-keys/index.js +29 -0
- package/dist/modules/api-keys/index.js.map +1 -0
- package/dist/modules/api-keys/keys.d.ts +25 -0
- package/dist/modules/api-keys/keys.d.ts.map +1 -0
- package/dist/modules/api-keys/keys.js +40 -0
- package/dist/modules/api-keys/keys.js.map +1 -0
- package/dist/modules/api-keys/repository.d.ts +15 -0
- package/dist/modules/api-keys/repository.d.ts.map +1 -0
- package/dist/modules/api-keys/repository.js +48 -0
- package/dist/modules/api-keys/repository.js.map +1 -0
- package/dist/modules/api-keys/routes.d.ts +8 -0
- package/dist/modules/api-keys/routes.d.ts.map +1 -0
- package/dist/modules/api-keys/routes.js +52 -0
- package/dist/modules/api-keys/routes.js.map +1 -0
- package/dist/modules/api-keys/schema.d.ts +166 -0
- package/dist/modules/api-keys/schema.d.ts.map +1 -0
- package/dist/modules/api-keys/schema.js +23 -0
- package/dist/modules/api-keys/schema.js.map +1 -0
- package/dist/modules/api-keys/service.d.ts +37 -0
- package/dist/modules/api-keys/service.d.ts.map +1 -0
- package/dist/modules/api-keys/service.js +95 -0
- package/dist/modules/api-keys/service.js.map +1 -0
- package/dist/modules/attachedRecords.d.ts +39 -0
- package/dist/modules/attachedRecords.d.ts.map +1 -0
- package/dist/modules/attachedRecords.js +52 -0
- package/dist/modules/attachedRecords.js.map +1 -0
- package/dist/modules/auth/actor.d.ts +11 -0
- package/dist/modules/auth/actor.d.ts.map +1 -0
- package/dist/modules/auth/actor.js +10 -0
- package/dist/modules/auth/actor.js.map +1 -0
- package/dist/modules/auth/credentials.d.ts +18 -0
- package/dist/modules/auth/credentials.d.ts.map +1 -0
- package/dist/modules/auth/credentials.js +105 -0
- package/dist/modules/auth/credentials.js.map +1 -0
- package/dist/modules/auth/index.d.ts +3 -0
- package/dist/modules/auth/index.d.ts.map +1 -0
- package/dist/modules/auth/index.js +41 -0
- package/dist/modules/auth/index.js.map +1 -0
- package/dist/modules/auth/preferences.d.ts +34 -0
- package/dist/modules/auth/preferences.d.ts.map +1 -0
- package/dist/modules/auth/preferences.js +30 -0
- package/dist/modules/auth/preferences.js.map +1 -0
- package/dist/modules/auth/repository.d.ts +54 -0
- package/dist/modules/auth/repository.d.ts.map +1 -0
- package/dist/modules/auth/repository.js +137 -0
- package/dist/modules/auth/repository.js.map +1 -0
- package/dist/modules/auth/routes.d.ts +10 -0
- package/dist/modules/auth/routes.d.ts.map +1 -0
- package/dist/modules/auth/routes.js +181 -0
- package/dist/modules/auth/routes.js.map +1 -0
- package/dist/modules/auth/schema.d.ts +530 -0
- package/dist/modules/auth/schema.d.ts.map +1 -0
- package/dist/modules/auth/schema.js +67 -0
- package/dist/modules/auth/schema.js.map +1 -0
- package/dist/modules/auth/service.d.ts +73 -0
- package/dist/modules/auth/service.d.ts.map +1 -0
- package/dist/modules/auth/service.js +288 -0
- package/dist/modules/auth/service.js.map +1 -0
- package/dist/modules/auth/session.d.ts +16 -0
- package/dist/modules/auth/session.d.ts.map +1 -0
- package/dist/modules/auth/session.js +30 -0
- package/dist/modules/auth/session.js.map +1 -0
- package/dist/modules/companies/index.d.ts +9 -0
- package/dist/modules/companies/index.d.ts.map +1 -0
- package/dist/modules/companies/index.js +37 -0
- package/dist/modules/companies/index.js.map +1 -0
- package/dist/modules/companies/repository.d.ts +40 -0
- package/dist/modules/companies/repository.d.ts.map +1 -0
- package/dist/modules/companies/repository.js +112 -0
- package/dist/modules/companies/repository.js.map +1 -0
- package/dist/modules/companies/routes.d.ts +89 -0
- package/dist/modules/companies/routes.d.ts.map +1 -0
- package/dist/modules/companies/routes.js +125 -0
- package/dist/modules/companies/routes.js.map +1 -0
- package/dist/modules/companies/schema.d.ts +381 -0
- package/dist/modules/companies/schema.d.ts.map +1 -0
- package/dist/modules/companies/schema.js +51 -0
- package/dist/modules/companies/schema.js.map +1 -0
- package/dist/modules/companies/service.d.ts +49 -0
- package/dist/modules/companies/service.d.ts.map +1 -0
- package/dist/modules/companies/service.js +184 -0
- package/dist/modules/companies/service.js.map +1 -0
- package/dist/modules/companies/tools.d.ts +4 -0
- package/dist/modules/companies/tools.d.ts.map +1 -0
- package/dist/modules/companies/tools.js +27 -0
- package/dist/modules/companies/tools.js.map +1 -0
- package/dist/modules/core.d.ts +21 -0
- package/dist/modules/core.d.ts.map +1 -0
- package/dist/modules/core.js +82 -0
- package/dist/modules/core.js.map +1 -0
- package/dist/modules/crudTools.d.ts +99 -0
- package/dist/modules/crudTools.d.ts.map +1 -0
- package/dist/modules/crudTools.js +123 -0
- package/dist/modules/crudTools.js.map +1 -0
- package/dist/modules/dashboard/attention.d.ts +39 -0
- package/dist/modules/dashboard/attention.d.ts.map +1 -0
- package/dist/modules/dashboard/attention.js +57 -0
- package/dist/modules/dashboard/attention.js.map +1 -0
- package/dist/modules/dashboard/index.d.ts +15 -0
- package/dist/modules/dashboard/index.d.ts.map +1 -0
- package/dist/modules/dashboard/index.js +44 -0
- package/dist/modules/dashboard/index.js.map +1 -0
- package/dist/modules/dashboard/repository.d.ts +83 -0
- package/dist/modules/dashboard/repository.d.ts.map +1 -0
- package/dist/modules/dashboard/repository.js +217 -0
- package/dist/modules/dashboard/repository.js.map +1 -0
- package/dist/modules/dashboard/routes.d.ts +21 -0
- package/dist/modules/dashboard/routes.d.ts.map +1 -0
- package/dist/modules/dashboard/routes.js +116 -0
- package/dist/modules/dashboard/routes.js.map +1 -0
- package/dist/modules/dashboard/service.d.ts +122 -0
- package/dist/modules/dashboard/service.d.ts.map +1 -0
- package/dist/modules/dashboard/service.js +215 -0
- package/dist/modules/dashboard/service.js.map +1 -0
- package/dist/modules/dashboard/tools.d.ts +4 -0
- package/dist/modules/dashboard/tools.d.ts.map +1 -0
- package/dist/modules/dashboard/tools.js +33 -0
- package/dist/modules/dashboard/tools.js.map +1 -0
- package/dist/modules/deals/index.d.ts +11 -0
- package/dist/modules/deals/index.d.ts.map +1 -0
- package/dist/modules/deals/index.js +38 -0
- package/dist/modules/deals/index.js.map +1 -0
- package/dist/modules/deals/repository.d.ts +44 -0
- package/dist/modules/deals/repository.d.ts.map +1 -0
- package/dist/modules/deals/repository.js +160 -0
- package/dist/modules/deals/repository.js.map +1 -0
- package/dist/modules/deals/routes.d.ts +50 -0
- package/dist/modules/deals/routes.d.ts.map +1 -0
- package/dist/modules/deals/routes.js +132 -0
- package/dist/modules/deals/routes.js.map +1 -0
- package/dist/modules/deals/schema.d.ts +419 -0
- package/dist/modules/deals/schema.d.ts.map +1 -0
- package/dist/modules/deals/schema.js +61 -0
- package/dist/modules/deals/schema.js.map +1 -0
- package/dist/modules/deals/service.d.ts +71 -0
- package/dist/modules/deals/service.d.ts.map +1 -0
- package/dist/modules/deals/service.js +277 -0
- package/dist/modules/deals/service.js.map +1 -0
- package/dist/modules/deals/tools.d.ts +4 -0
- package/dist/modules/deals/tools.d.ts.map +1 -0
- package/dist/modules/deals/tools.js +33 -0
- package/dist/modules/deals/tools.js.map +1 -0
- package/dist/modules/decisions/index.d.ts +11 -0
- package/dist/modules/decisions/index.d.ts.map +1 -0
- package/dist/modules/decisions/index.js +34 -0
- package/dist/modules/decisions/index.js.map +1 -0
- package/dist/modules/decisions/repository.d.ts +38 -0
- package/dist/modules/decisions/repository.d.ts.map +1 -0
- package/dist/modules/decisions/repository.js +126 -0
- package/dist/modules/decisions/repository.js.map +1 -0
- package/dist/modules/decisions/routes.d.ts +42 -0
- package/dist/modules/decisions/routes.d.ts.map +1 -0
- package/dist/modules/decisions/routes.js +131 -0
- package/dist/modules/decisions/routes.js.map +1 -0
- package/dist/modules/decisions/schema.d.ts +228 -0
- package/dist/modules/decisions/schema.d.ts.map +1 -0
- package/dist/modules/decisions/schema.js +41 -0
- package/dist/modules/decisions/schema.js.map +1 -0
- package/dist/modules/decisions/service.d.ts +60 -0
- package/dist/modules/decisions/service.d.ts.map +1 -0
- package/dist/modules/decisions/service.js +122 -0
- package/dist/modules/decisions/service.js.map +1 -0
- package/dist/modules/decisions/tools.d.ts +4 -0
- package/dist/modules/decisions/tools.d.ts.map +1 -0
- package/dist/modules/decisions/tools.js +32 -0
- package/dist/modules/decisions/tools.js.map +1 -0
- package/dist/modules/forms/embed.d.ts +50 -0
- package/dist/modules/forms/embed.d.ts.map +1 -0
- package/dist/modules/forms/embed.js +236 -0
- package/dist/modules/forms/embed.js.map +1 -0
- package/dist/modules/forms/fields.d.ts +71 -0
- package/dist/modules/forms/fields.d.ts.map +1 -0
- package/dist/modules/forms/fields.js +122 -0
- package/dist/modules/forms/fields.js.map +1 -0
- package/dist/modules/forms/index.d.ts +15 -0
- package/dist/modules/forms/index.d.ts.map +1 -0
- package/dist/modules/forms/index.js +53 -0
- package/dist/modules/forms/index.js.map +1 -0
- package/dist/modules/forms/mapping.d.ts +99 -0
- package/dist/modules/forms/mapping.d.ts.map +1 -0
- package/dist/modules/forms/mapping.js +152 -0
- package/dist/modules/forms/mapping.js.map +1 -0
- package/dist/modules/forms/publicRoutes.d.ts +11 -0
- package/dist/modules/forms/publicRoutes.d.ts.map +1 -0
- package/dist/modules/forms/publicRoutes.js +68 -0
- package/dist/modules/forms/publicRoutes.js.map +1 -0
- package/dist/modules/forms/repository.d.ts +65 -0
- package/dist/modules/forms/repository.d.ts.map +1 -0
- package/dist/modules/forms/repository.js +139 -0
- package/dist/modules/forms/repository.js.map +1 -0
- package/dist/modules/forms/routes.d.ts +106 -0
- package/dist/modules/forms/routes.d.ts.map +1 -0
- package/dist/modules/forms/routes.js +204 -0
- package/dist/modules/forms/routes.js.map +1 -0
- package/dist/modules/forms/schema.d.ts +643 -0
- package/dist/modules/forms/schema.d.ts.map +1 -0
- package/dist/modules/forms/schema.js +87 -0
- package/dist/modules/forms/schema.js.map +1 -0
- package/dist/modules/forms/service.d.ts +62 -0
- package/dist/modules/forms/service.d.ts.map +1 -0
- package/dist/modules/forms/service.js +208 -0
- package/dist/modules/forms/service.js.map +1 -0
- package/dist/modules/forms/submission.d.ts +30 -0
- package/dist/modules/forms/submission.d.ts.map +1 -0
- package/dist/modules/forms/submission.js +337 -0
- package/dist/modules/forms/submission.js.map +1 -0
- package/dist/modules/forms/tools.d.ts +4 -0
- package/dist/modules/forms/tools.d.ts.map +1 -0
- package/dist/modules/forms/tools.js +46 -0
- package/dist/modules/forms/tools.js.map +1 -0
- package/dist/modules/handbook/index.d.ts +15 -0
- package/dist/modules/handbook/index.d.ts.map +1 -0
- package/dist/modules/handbook/index.js +37 -0
- package/dist/modules/handbook/index.js.map +1 -0
- package/dist/modules/handbook/repository.d.ts +52 -0
- package/dist/modules/handbook/repository.d.ts.map +1 -0
- package/dist/modules/handbook/repository.js +109 -0
- package/dist/modules/handbook/repository.js.map +1 -0
- package/dist/modules/handbook/routes.d.ts +38 -0
- package/dist/modules/handbook/routes.d.ts.map +1 -0
- package/dist/modules/handbook/routes.js +103 -0
- package/dist/modules/handbook/routes.js.map +1 -0
- package/dist/modules/handbook/schema.d.ts +206 -0
- package/dist/modules/handbook/schema.d.ts.map +1 -0
- package/dist/modules/handbook/schema.js +37 -0
- package/dist/modules/handbook/schema.js.map +1 -0
- package/dist/modules/handbook/service.d.ts +59 -0
- package/dist/modules/handbook/service.d.ts.map +1 -0
- package/dist/modules/handbook/service.js +246 -0
- package/dist/modules/handbook/service.js.map +1 -0
- package/dist/modules/handbook/slugs.d.ts +28 -0
- package/dist/modules/handbook/slugs.d.ts.map +1 -0
- package/dist/modules/handbook/slugs.js +48 -0
- package/dist/modules/handbook/slugs.js.map +1 -0
- package/dist/modules/handbook/tools.d.ts +4 -0
- package/dist/modules/handbook/tools.d.ts.map +1 -0
- package/dist/modules/handbook/tools.js +26 -0
- package/dist/modules/handbook/tools.js.map +1 -0
- package/dist/modules/handbook/tree.d.ts +69 -0
- package/dist/modules/handbook/tree.d.ts.map +1 -0
- package/dist/modules/handbook/tree.js +117 -0
- package/dist/modules/handbook/tree.js.map +1 -0
- package/dist/modules/hiring/candidates.d.ts +70 -0
- package/dist/modules/hiring/candidates.d.ts.map +1 -0
- package/dist/modules/hiring/candidates.js +243 -0
- package/dist/modules/hiring/candidates.js.map +1 -0
- package/dist/modules/hiring/index.d.ts +15 -0
- package/dist/modules/hiring/index.d.ts.map +1 -0
- package/dist/modules/hiring/index.js +48 -0
- package/dist/modules/hiring/index.js.map +1 -0
- package/dist/modules/hiring/repository.d.ts +52 -0
- package/dist/modules/hiring/repository.d.ts.map +1 -0
- package/dist/modules/hiring/repository.js +137 -0
- package/dist/modules/hiring/repository.js.map +1 -0
- package/dist/modules/hiring/roles.d.ts +42 -0
- package/dist/modules/hiring/roles.d.ts.map +1 -0
- package/dist/modules/hiring/roles.js +104 -0
- package/dist/modules/hiring/roles.js.map +1 -0
- package/dist/modules/hiring/routes.d.ts +73 -0
- package/dist/modules/hiring/routes.d.ts.map +1 -0
- package/dist/modules/hiring/routes.js +170 -0
- package/dist/modules/hiring/routes.js.map +1 -0
- package/dist/modules/hiring/schema.d.ts +308 -0
- package/dist/modules/hiring/schema.d.ts.map +1 -0
- package/dist/modules/hiring/schema.js +62 -0
- package/dist/modules/hiring/schema.js.map +1 -0
- package/dist/modules/hiring/tools.d.ts +8 -0
- package/dist/modules/hiring/tools.d.ts.map +1 -0
- package/dist/modules/hiring/tools.js +50 -0
- package/dist/modules/hiring/tools.js.map +1 -0
- package/dist/modules/import-export/csv.d.ts +47 -0
- package/dist/modules/import-export/csv.d.ts.map +1 -0
- package/dist/modules/import-export/csv.js +138 -0
- package/dist/modules/import-export/csv.js.map +1 -0
- package/dist/modules/import-export/drafts.d.ts +83 -0
- package/dist/modules/import-export/drafts.d.ts.map +1 -0
- package/dist/modules/import-export/drafts.js +97 -0
- package/dist/modules/import-export/drafts.js.map +1 -0
- package/dist/modules/import-export/exportRows.d.ts +8 -0
- package/dist/modules/import-export/exportRows.d.ts.map +1 -0
- package/dist/modules/import-export/exportRows.js +71 -0
- package/dist/modules/import-export/exportRows.js.map +1 -0
- package/dist/modules/import-export/index.d.ts +15 -0
- package/dist/modules/import-export/index.d.ts.map +1 -0
- package/dist/modules/import-export/index.js +43 -0
- package/dist/modules/import-export/index.js.map +1 -0
- package/dist/modules/import-export/mapping.d.ts +46 -0
- package/dist/modules/import-export/mapping.d.ts.map +1 -0
- package/dist/modules/import-export/mapping.js +115 -0
- package/dist/modules/import-export/mapping.js.map +1 -0
- package/dist/modules/import-export/plan.d.ts +107 -0
- package/dist/modules/import-export/plan.d.ts.map +1 -0
- package/dist/modules/import-export/plan.js +178 -0
- package/dist/modules/import-export/plan.js.map +1 -0
- package/dist/modules/import-export/presets.d.ts +39 -0
- package/dist/modules/import-export/presets.d.ts.map +1 -0
- package/dist/modules/import-export/presets.js +151 -0
- package/dist/modules/import-export/presets.js.map +1 -0
- package/dist/modules/import-export/repository.d.ts +171 -0
- package/dist/modules/import-export/repository.d.ts.map +1 -0
- package/dist/modules/import-export/repository.js +343 -0
- package/dist/modules/import-export/repository.js.map +1 -0
- package/dist/modules/import-export/routes.d.ts +9 -0
- package/dist/modules/import-export/routes.d.ts.map +1 -0
- package/dist/modules/import-export/routes.js +199 -0
- package/dist/modules/import-export/routes.js.map +1 -0
- package/dist/modules/import-export/schema.d.ts +494 -0
- package/dist/modules/import-export/schema.d.ts.map +1 -0
- package/dist/modules/import-export/schema.js +99 -0
- package/dist/modules/import-export/schema.js.map +1 -0
- package/dist/modules/import-export/service.d.ts +74 -0
- package/dist/modules/import-export/service.d.ts.map +1 -0
- package/dist/modules/import-export/service.js +561 -0
- package/dist/modules/import-export/service.js.map +1 -0
- package/dist/modules/import-export/streams.d.ts +4 -0
- package/dist/modules/import-export/streams.d.ts.map +1 -0
- package/dist/modules/import-export/streams.js +55 -0
- package/dist/modules/import-export/streams.js.map +1 -0
- package/dist/modules/import-export/tools.d.ts +22 -0
- package/dist/modules/import-export/tools.d.ts.map +1 -0
- package/dist/modules/import-export/tools.js +116 -0
- package/dist/modules/import-export/tools.js.map +1 -0
- package/dist/modules/import-export/validation.d.ts +7 -0
- package/dist/modules/import-export/validation.d.ts.map +1 -0
- package/dist/modules/import-export/validation.js +114 -0
- package/dist/modules/import-export/validation.js.map +1 -0
- package/dist/modules/import-export/writes.d.ts +45 -0
- package/dist/modules/import-export/writes.d.ts.map +1 -0
- package/dist/modules/import-export/writes.js +247 -0
- package/dist/modules/import-export/writes.js.map +1 -0
- package/dist/modules/integrations/schema.d.ts +185 -0
- package/dist/modules/integrations/schema.d.ts.map +1 -0
- package/dist/modules/integrations/schema.js +26 -0
- package/dist/modules/integrations/schema.js.map +1 -0
- package/dist/modules/mcp/index.d.ts +26 -0
- package/dist/modules/mcp/index.d.ts.map +1 -0
- package/dist/modules/mcp/index.js +45 -0
- package/dist/modules/mcp/index.js.map +1 -0
- package/dist/modules/mcp/protocol.d.ts +166 -0
- package/dist/modules/mcp/protocol.d.ts.map +1 -0
- package/dist/modules/mcp/protocol.js +292 -0
- package/dist/modules/mcp/protocol.js.map +1 -0
- package/dist/modules/mcp/router.d.ts +23 -0
- package/dist/modules/mcp/router.d.ts.map +1 -0
- package/dist/modules/mcp/router.js +298 -0
- package/dist/modules/mcp/router.js.map +1 -0
- package/dist/modules/notes/index.d.ts +9 -0
- package/dist/modules/notes/index.d.ts.map +1 -0
- package/dist/modules/notes/index.js +37 -0
- package/dist/modules/notes/index.js.map +1 -0
- package/dist/modules/notes/repository.d.ts +34 -0
- package/dist/modules/notes/repository.d.ts.map +1 -0
- package/dist/modules/notes/repository.js +70 -0
- package/dist/modules/notes/repository.js.map +1 -0
- package/dist/modules/notes/routes.d.ts +37 -0
- package/dist/modules/notes/routes.d.ts.map +1 -0
- package/dist/modules/notes/routes.js +124 -0
- package/dist/modules/notes/routes.js.map +1 -0
- package/dist/modules/notes/schema.d.ts +176 -0
- package/dist/modules/notes/schema.d.ts.map +1 -0
- package/dist/modules/notes/schema.js +35 -0
- package/dist/modules/notes/schema.js.map +1 -0
- package/dist/modules/notes/service.d.ts +49 -0
- package/dist/modules/notes/service.d.ts.map +1 -0
- package/dist/modules/notes/service.js +118 -0
- package/dist/modules/notes/service.js.map +1 -0
- package/dist/modules/notes/tools.d.ts +4 -0
- package/dist/modules/notes/tools.d.ts.map +1 -0
- package/dist/modules/notes/tools.js +41 -0
- package/dist/modules/notes/tools.js.map +1 -0
- package/dist/modules/opportunities/index.d.ts +11 -0
- package/dist/modules/opportunities/index.d.ts.map +1 -0
- package/dist/modules/opportunities/index.js +38 -0
- package/dist/modules/opportunities/index.js.map +1 -0
- package/dist/modules/opportunities/repository.d.ts +28 -0
- package/dist/modules/opportunities/repository.d.ts.map +1 -0
- package/dist/modules/opportunities/repository.js +89 -0
- package/dist/modules/opportunities/repository.js.map +1 -0
- package/dist/modules/opportunities/routes.d.ts +39 -0
- package/dist/modules/opportunities/routes.d.ts.map +1 -0
- package/dist/modules/opportunities/routes.js +104 -0
- package/dist/modules/opportunities/routes.js.map +1 -0
- package/dist/modules/opportunities/schema.d.ts +266 -0
- package/dist/modules/opportunities/schema.d.ts.map +1 -0
- package/dist/modules/opportunities/schema.js +41 -0
- package/dist/modules/opportunities/schema.js.map +1 -0
- package/dist/modules/opportunities/service.d.ts +60 -0
- package/dist/modules/opportunities/service.d.ts.map +1 -0
- package/dist/modules/opportunities/service.js +212 -0
- package/dist/modules/opportunities/service.js.map +1 -0
- package/dist/modules/opportunities/tools.d.ts +4 -0
- package/dist/modules/opportunities/tools.d.ts.map +1 -0
- package/dist/modules/opportunities/tools.js +33 -0
- package/dist/modules/opportunities/tools.js.map +1 -0
- package/dist/modules/partnerships/index.d.ts +11 -0
- package/dist/modules/partnerships/index.d.ts.map +1 -0
- package/dist/modules/partnerships/index.js +38 -0
- package/dist/modules/partnerships/index.js.map +1 -0
- package/dist/modules/partnerships/repository.d.ts +47 -0
- package/dist/modules/partnerships/repository.d.ts.map +1 -0
- package/dist/modules/partnerships/repository.js +169 -0
- package/dist/modules/partnerships/repository.js.map +1 -0
- package/dist/modules/partnerships/routes.d.ts +46 -0
- package/dist/modules/partnerships/routes.d.ts.map +1 -0
- package/dist/modules/partnerships/routes.js +122 -0
- package/dist/modules/partnerships/routes.js.map +1 -0
- package/dist/modules/partnerships/schema.d.ts +338 -0
- package/dist/modules/partnerships/schema.d.ts.map +1 -0
- package/dist/modules/partnerships/schema.js +54 -0
- package/dist/modules/partnerships/schema.js.map +1 -0
- package/dist/modules/partnerships/service.d.ts +71 -0
- package/dist/modules/partnerships/service.d.ts.map +1 -0
- package/dist/modules/partnerships/service.js +273 -0
- package/dist/modules/partnerships/service.js.map +1 -0
- package/dist/modules/partnerships/tools.d.ts +4 -0
- package/dist/modules/partnerships/tools.d.ts.map +1 -0
- package/dist/modules/partnerships/tools.js +35 -0
- package/dist/modules/partnerships/tools.js.map +1 -0
- package/dist/modules/people/index.d.ts +9 -0
- package/dist/modules/people/index.d.ts.map +1 -0
- package/dist/modules/people/index.js +37 -0
- package/dist/modules/people/index.js.map +1 -0
- package/dist/modules/people/repository.d.ts +31 -0
- package/dist/modules/people/repository.d.ts.map +1 -0
- package/dist/modules/people/repository.js +109 -0
- package/dist/modules/people/repository.js.map +1 -0
- package/dist/modules/people/routes.d.ts +111 -0
- package/dist/modules/people/routes.d.ts.map +1 -0
- package/dist/modules/people/routes.js +134 -0
- package/dist/modules/people/routes.js.map +1 -0
- package/dist/modules/people/schema.d.ts +354 -0
- package/dist/modules/people/schema.d.ts.map +1 -0
- package/dist/modules/people/schema.js +61 -0
- package/dist/modules/people/schema.js.map +1 -0
- package/dist/modules/people/service.d.ts +56 -0
- package/dist/modules/people/service.d.ts.map +1 -0
- package/dist/modules/people/service.js +190 -0
- package/dist/modules/people/service.js.map +1 -0
- package/dist/modules/people/tools.d.ts +4 -0
- package/dist/modules/people/tools.d.ts.map +1 -0
- package/dist/modules/people/tools.js +27 -0
- package/dist/modules/people/tools.js.map +1 -0
- package/dist/modules/pipelines/index.d.ts +9 -0
- package/dist/modules/pipelines/index.d.ts.map +1 -0
- package/dist/modules/pipelines/index.js +37 -0
- package/dist/modules/pipelines/index.js.map +1 -0
- package/dist/modules/pipelines/repository.d.ts +26 -0
- package/dist/modules/pipelines/repository.d.ts.map +1 -0
- package/dist/modules/pipelines/repository.js +67 -0
- package/dist/modules/pipelines/repository.js.map +1 -0
- package/dist/modules/pipelines/routes.d.ts +33 -0
- package/dist/modules/pipelines/routes.d.ts.map +1 -0
- package/dist/modules/pipelines/routes.js +98 -0
- package/dist/modules/pipelines/routes.js.map +1 -0
- package/dist/modules/pipelines/schema.d.ts +170 -0
- package/dist/modules/pipelines/schema.d.ts.map +1 -0
- package/dist/modules/pipelines/schema.js +30 -0
- package/dist/modules/pipelines/schema.js.map +1 -0
- package/dist/modules/pipelines/service.d.ts +49 -0
- package/dist/modules/pipelines/service.d.ts.map +1 -0
- package/dist/modules/pipelines/service.js +227 -0
- package/dist/modules/pipelines/service.js.map +1 -0
- package/dist/modules/pipelines/tools.d.ts +4 -0
- package/dist/modules/pipelines/tools.d.ts.map +1 -0
- package/dist/modules/pipelines/tools.js +43 -0
- package/dist/modules/pipelines/tools.js.map +1 -0
- package/dist/modules/plans/index.d.ts +10 -0
- package/dist/modules/plans/index.d.ts.map +1 -0
- package/dist/modules/plans/index.js +33 -0
- package/dist/modules/plans/index.js.map +1 -0
- package/dist/modules/plans/repository.d.ts +49 -0
- package/dist/modules/plans/repository.d.ts.map +1 -0
- package/dist/modules/plans/repository.js +94 -0
- package/dist/modules/plans/repository.js.map +1 -0
- package/dist/modules/plans/routes.d.ts +46 -0
- package/dist/modules/plans/routes.d.ts.map +1 -0
- package/dist/modules/plans/routes.js +152 -0
- package/dist/modules/plans/routes.js.map +1 -0
- package/dist/modules/plans/schema.d.ts +209 -0
- package/dist/modules/plans/schema.d.ts.map +1 -0
- package/dist/modules/plans/schema.js +37 -0
- package/dist/modules/plans/schema.js.map +1 -0
- package/dist/modules/plans/service.d.ts +57 -0
- package/dist/modules/plans/service.d.ts.map +1 -0
- package/dist/modules/plans/service.js +125 -0
- package/dist/modules/plans/service.js.map +1 -0
- package/dist/modules/plans/tools.d.ts +4 -0
- package/dist/modules/plans/tools.d.ts.map +1 -0
- package/dist/modules/plans/tools.js +39 -0
- package/dist/modules/plans/tools.js.map +1 -0
- package/dist/modules/positions/index.d.ts +9 -0
- package/dist/modules/positions/index.d.ts.map +1 -0
- package/dist/modules/positions/index.js +36 -0
- package/dist/modules/positions/index.js.map +1 -0
- package/dist/modules/positions/repository.d.ts +34 -0
- package/dist/modules/positions/repository.d.ts.map +1 -0
- package/dist/modules/positions/repository.js +71 -0
- package/dist/modules/positions/repository.js.map +1 -0
- package/dist/modules/positions/routes.d.ts +22 -0
- package/dist/modules/positions/routes.d.ts.map +1 -0
- package/dist/modules/positions/routes.js +56 -0
- package/dist/modules/positions/routes.js.map +1 -0
- package/dist/modules/positions/schema.d.ts +154 -0
- package/dist/modules/positions/schema.d.ts.map +1 -0
- package/dist/modules/positions/schema.js +36 -0
- package/dist/modules/positions/schema.js.map +1 -0
- package/dist/modules/positions/service.d.ts +46 -0
- package/dist/modules/positions/service.d.ts.map +1 -0
- package/dist/modules/positions/service.js +159 -0
- package/dist/modules/positions/service.js.map +1 -0
- package/dist/modules/positions/tools.d.ts +4 -0
- package/dist/modules/positions/tools.d.ts.map +1 -0
- package/dist/modules/positions/tools.js +26 -0
- package/dist/modules/positions/tools.js.map +1 -0
- package/dist/modules/raises/index.d.ts +11 -0
- package/dist/modules/raises/index.d.ts.map +1 -0
- package/dist/modules/raises/index.js +38 -0
- package/dist/modules/raises/index.js.map +1 -0
- package/dist/modules/raises/repository.d.ts +48 -0
- package/dist/modules/raises/repository.d.ts.map +1 -0
- package/dist/modules/raises/repository.js +164 -0
- package/dist/modules/raises/repository.js.map +1 -0
- package/dist/modules/raises/routes.d.ts +48 -0
- package/dist/modules/raises/routes.d.ts.map +1 -0
- package/dist/modules/raises/routes.js +126 -0
- package/dist/modules/raises/routes.js.map +1 -0
- package/dist/modules/raises/schema.d.ts +356 -0
- package/dist/modules/raises/schema.d.ts.map +1 -0
- package/dist/modules/raises/schema.js +55 -0
- package/dist/modules/raises/schema.js.map +1 -0
- package/dist/modules/raises/service.d.ts +79 -0
- package/dist/modules/raises/service.d.ts.map +1 -0
- package/dist/modules/raises/service.js +275 -0
- package/dist/modules/raises/service.js.map +1 -0
- package/dist/modules/raises/tools.d.ts +4 -0
- package/dist/modules/raises/tools.d.ts.map +1 -0
- package/dist/modules/raises/tools.js +33 -0
- package/dist/modules/raises/tools.js.map +1 -0
- package/dist/modules/recordTargets.d.ts +55 -0
- package/dist/modules/recordTargets.d.ts.map +1 -0
- package/dist/modules/recordTargets.js +107 -0
- package/dist/modules/recordTargets.js.map +1 -0
- package/dist/modules/references.d.ts +8 -0
- package/dist/modules/references.d.ts.map +1 -0
- package/dist/modules/references.js +40 -0
- package/dist/modules/references.js.map +1 -0
- package/dist/modules/reseal.d.ts +33 -0
- package/dist/modules/reseal.d.ts.map +1 -0
- package/dist/modules/reseal.js +108 -0
- package/dist/modules/reseal.js.map +1 -0
- package/dist/modules/search/index.d.ts +21 -0
- package/dist/modules/search/index.d.ts.map +1 -0
- package/dist/modules/search/index.js +50 -0
- package/dist/modules/search/index.js.map +1 -0
- package/dist/modules/search/query.d.ts +44 -0
- package/dist/modules/search/query.d.ts.map +1 -0
- package/dist/modules/search/query.js +88 -0
- package/dist/modules/search/query.js.map +1 -0
- package/dist/modules/search/repository.d.ts +44 -0
- package/dist/modules/search/repository.d.ts.map +1 -0
- package/dist/modules/search/repository.js +252 -0
- package/dist/modules/search/repository.js.map +1 -0
- package/dist/modules/search/routes.d.ts +17 -0
- package/dist/modules/search/routes.d.ts.map +1 -0
- package/dist/modules/search/routes.js +93 -0
- package/dist/modules/search/routes.js.map +1 -0
- package/dist/modules/search/service.d.ts +55 -0
- package/dist/modules/search/service.d.ts.map +1 -0
- package/dist/modules/search/service.js +69 -0
- package/dist/modules/search/service.js.map +1 -0
- package/dist/modules/search/tools.d.ts +4 -0
- package/dist/modules/search/tools.d.ts.map +1 -0
- package/dist/modules/search/tools.js +52 -0
- package/dist/modules/search/tools.js.map +1 -0
- package/dist/modules/stagedRecords.d.ts +28 -0
- package/dist/modules/stagedRecords.d.ts.map +1 -0
- package/dist/modules/stagedRecords.js +50 -0
- package/dist/modules/stagedRecords.js.map +1 -0
- package/dist/modules/webhooks/delivery.d.ts +98 -0
- package/dist/modules/webhooks/delivery.d.ts.map +1 -0
- package/dist/modules/webhooks/delivery.js +237 -0
- package/dist/modules/webhooks/delivery.js.map +1 -0
- package/dist/modules/webhooks/index.d.ts +23 -0
- package/dist/modules/webhooks/index.d.ts.map +1 -0
- package/dist/modules/webhooks/index.js +48 -0
- package/dist/modules/webhooks/index.js.map +1 -0
- package/dist/modules/webhooks/payloads.d.ts +31 -0
- package/dist/modules/webhooks/payloads.d.ts.map +1 -0
- package/dist/modules/webhooks/payloads.js +52 -0
- package/dist/modules/webhooks/payloads.js.map +1 -0
- package/dist/modules/webhooks/repository.d.ts +70 -0
- package/dist/modules/webhooks/repository.d.ts.map +1 -0
- package/dist/modules/webhooks/repository.js +140 -0
- package/dist/modules/webhooks/repository.js.map +1 -0
- package/dist/modules/webhooks/routes.d.ts +47 -0
- package/dist/modules/webhooks/routes.d.ts.map +1 -0
- package/dist/modules/webhooks/routes.js +170 -0
- package/dist/modules/webhooks/routes.js.map +1 -0
- package/dist/modules/webhooks/schema.d.ts +396 -0
- package/dist/modules/webhooks/schema.d.ts.map +1 -0
- package/dist/modules/webhooks/schema.js +61 -0
- package/dist/modules/webhooks/schema.js.map +1 -0
- package/dist/modules/webhooks/service.d.ts +65 -0
- package/dist/modules/webhooks/service.d.ts.map +1 -0
- package/dist/modules/webhooks/service.js +202 -0
- package/dist/modules/webhooks/service.js.map +1 -0
- package/dist/modules/webhooks/signing.d.ts +57 -0
- package/dist/modules/webhooks/signing.d.ts.map +1 -0
- package/dist/modules/webhooks/signing.js +69 -0
- package/dist/modules/webhooks/signing.js.map +1 -0
- package/dist/modules/webhooks/tools.d.ts +4 -0
- package/dist/modules/webhooks/tools.d.ts.map +1 -0
- package/dist/modules/webhooks/tools.js +77 -0
- package/dist/modules/webhooks/tools.js.map +1 -0
- package/dist/modules/webhooks/url.d.ts +10 -0
- package/dist/modules/webhooks/url.d.ts.map +1 -0
- package/dist/modules/webhooks/url.js +9 -0
- package/dist/modules/webhooks/url.js.map +1 -0
- package/dist/modules/workspace/capabilities.d.ts +9 -0
- package/dist/modules/workspace/capabilities.d.ts.map +1 -0
- package/dist/modules/workspace/capabilities.js +12 -0
- package/dist/modules/workspace/capabilities.js.map +1 -0
- package/dist/modules/workspace/idempotencyMiddleware.d.ts +16 -0
- package/dist/modules/workspace/idempotencyMiddleware.d.ts.map +1 -0
- package/dist/modules/workspace/idempotencyMiddleware.js +142 -0
- package/dist/modules/workspace/idempotencyMiddleware.js.map +1 -0
- package/dist/modules/workspace/idempotencyRepository.d.ts +43 -0
- package/dist/modules/workspace/idempotencyRepository.d.ts.map +1 -0
- package/dist/modules/workspace/idempotencyRepository.js +75 -0
- package/dist/modules/workspace/idempotencyRepository.js.map +1 -0
- package/dist/modules/workspace/index.d.ts +9 -0
- package/dist/modules/workspace/index.d.ts.map +1 -0
- package/dist/modules/workspace/index.js +53 -0
- package/dist/modules/workspace/index.js.map +1 -0
- package/dist/modules/workspace/repository.d.ts +112 -0
- package/dist/modules/workspace/repository.d.ts.map +1 -0
- package/dist/modules/workspace/repository.js +266 -0
- package/dist/modules/workspace/repository.js.map +1 -0
- package/dist/modules/workspace/roles.d.ts +22 -0
- package/dist/modules/workspace/roles.d.ts.map +1 -0
- package/dist/modules/workspace/roles.js +31 -0
- package/dist/modules/workspace/roles.js.map +1 -0
- package/dist/modules/workspace/routes.d.ts +41 -0
- package/dist/modules/workspace/routes.d.ts.map +1 -0
- package/dist/modules/workspace/routes.js +158 -0
- package/dist/modules/workspace/routes.js.map +1 -0
- package/dist/modules/workspace/schema.d.ts +719 -0
- package/dist/modules/workspace/schema.d.ts.map +1 -0
- package/dist/modules/workspace/schema.js +102 -0
- package/dist/modules/workspace/schema.js.map +1 -0
- package/dist/modules/workspace/service.d.ts +94 -0
- package/dist/modules/workspace/service.d.ts.map +1 -0
- package/dist/modules/workspace/service.js +528 -0
- package/dist/modules/workspace/service.js.map +1 -0
- package/dist/modules/workspace/starters.d.ts +22 -0
- package/dist/modules/workspace/starters.d.ts.map +1 -0
- package/dist/modules/workspace/starters.js +56 -0
- package/dist/modules/workspace/starters.js.map +1 -0
- package/dist/modules/workspace/tools.d.ts +4 -0
- package/dist/modules/workspace/tools.d.ts.map +1 -0
- package/dist/modules/workspace/tools.js +95 -0
- package/dist/modules/workspace/tools.js.map +1 -0
- package/dist/runtime/entitlements.d.ts +66 -0
- package/dist/runtime/entitlements.d.ts.map +1 -0
- package/dist/runtime/entitlements.js +62 -0
- package/dist/runtime/entitlements.js.map +1 -0
- package/dist/runtime/events.d.ts +139 -0
- package/dist/runtime/events.d.ts.map +1 -0
- package/dist/runtime/events.js +98 -0
- package/dist/runtime/events.js.map +1 -0
- package/dist/runtime/migrate.d.ts +28 -0
- package/dist/runtime/migrate.d.ts.map +1 -0
- package/dist/runtime/migrate.js +43 -0
- package/dist/runtime/migrate.js.map +1 -0
- package/dist/runtime/module.d.ts +138 -0
- package/dist/runtime/module.d.ts.map +1 -0
- package/dist/runtime/module.js +2 -0
- package/dist/runtime/module.js.map +1 -0
- package/dist/runtime/moduleConfig.d.ts +21 -0
- package/dist/runtime/moduleConfig.d.ts.map +1 -0
- package/dist/runtime/moduleConfig.js +54 -0
- package/dist/runtime/moduleConfig.js.map +1 -0
- package/dist/runtime/order.d.ts +21 -0
- package/dist/runtime/order.d.ts.map +1 -0
- package/dist/runtime/order.js +72 -0
- package/dist/runtime/order.js.map +1 -0
- package/dist/runtime/registry.d.ts +66 -0
- package/dist/runtime/registry.d.ts.map +1 -0
- package/dist/runtime/registry.js +148 -0
- package/dist/runtime/registry.js.map +1 -0
- package/dist/runtime/transaction.d.ts +34 -0
- package/dist/runtime/transaction.d.ts.map +1 -0
- package/dist/runtime/transaction.js +24 -0
- package/dist/runtime/transaction.js.map +1 -0
- package/dist/schema/index.d.ts +30 -0
- package/dist/schema/index.d.ts.map +1 -0
- package/dist/schema/index.js +30 -0
- package/dist/schema/index.js.map +1 -0
- package/dist/testing/app.d.ts +42 -0
- package/dist/testing/app.d.ts.map +1 -0
- package/dist/testing/app.js +31 -0
- package/dist/testing/app.js.map +1 -0
- package/dist/testing/client.d.ts +34 -0
- package/dist/testing/client.d.ts.map +1 -0
- package/dist/testing/client.js +70 -0
- package/dist/testing/client.js.map +1 -0
- package/dist/testing/database.d.ts +17 -0
- package/dist/testing/database.d.ts.map +1 -0
- package/dist/testing/database.js +84 -0
- package/dist/testing/database.js.map +1 -0
- package/dist/testing/environment.d.ts +17 -0
- package/dist/testing/environment.d.ts.map +1 -0
- package/dist/testing/environment.js +19 -0
- package/dist/testing/environment.js.map +1 -0
- package/dist/testing/fixtures.d.ts +22 -0
- package/dist/testing/fixtures.d.ts.map +1 -0
- package/dist/testing/fixtures.js +55 -0
- package/dist/testing/fixtures.js.map +1 -0
- package/dist/testing/index.d.ts +10 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +6 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/testing/services.d.ts +18 -0
- package/dist/testing/services.d.ts.map +1 -0
- package/dist/testing/services.js +43 -0
- package/dist/testing/services.js.map +1 -0
- package/migrations/0000_initial_schema.sql +597 -0
- package/migrations/0001_uneven_lockjaw.sql +11 -0
- package/migrations/0002_neat_madame_web.sql +2 -0
- package/migrations/0003_bright_shockwave.sql +1 -0
- package/migrations/0004_drop_unused_import_columns.sql +2 -0
- package/migrations/0005_import_job_rows.sql +23 -0
- package/migrations/0006_drop_webhook_secret_hash.sql +1 -0
- package/migrations/0007_add_webhook_secret_encrypted.sql +1 -0
- package/migrations/0008_rich_mister_sinister.sql +3 -0
- package/migrations/0009_natural_proemial_gods.sql +1 -0
- package/migrations/0010_fine_brood.sql +1 -0
- package/migrations/0011_add_webhook_previous_secret.sql +2 -0
- package/migrations/0012_idempotency_keys_response_nullable.sql +1 -0
- package/migrations/0013_add_agent_run_failure_reason.sql +1 -0
- package/migrations/0014_right_shinko_yamashiro.sql +12 -0
- package/migrations/0015_peaceful_chimera.sql +33 -0
- package/migrations/meta/0000_snapshot.json +4467 -0
- package/migrations/meta/0001_snapshot.json +4539 -0
- package/migrations/meta/0002_snapshot.json +4539 -0
- package/migrations/meta/0003_snapshot.json +4544 -0
- package/migrations/meta/0004_snapshot.json +4531 -0
- package/migrations/meta/0005_snapshot.json +4674 -0
- package/migrations/meta/0006_snapshot.json +4668 -0
- package/migrations/meta/0007_snapshot.json +4674 -0
- package/migrations/meta/0008_snapshot.json +4694 -0
- package/migrations/meta/0009_snapshot.json +4700 -0
- package/migrations/meta/0010_snapshot.json +4694 -0
- package/migrations/meta/0011_snapshot.json +4706 -0
- package/migrations/meta/0012_snapshot.json +4706 -0
- package/migrations/meta/0013_snapshot.json +4712 -0
- package/migrations/meta/0014_snapshot.json +4802 -0
- package/migrations/meta/0015_snapshot.json +5077 -0
- package/migrations/meta/_journal.json +118 -0
- package/package.json +68 -0
- package/src/app.ts +157 -0
- package/src/index.ts +113 -0
- package/src/lib/actor.ts +99 -0
- package/src/lib/changes.ts +43 -0
- package/src/lib/columns.ts +170 -0
- package/src/lib/config.ts +86 -0
- package/src/lib/database.ts +118 -0
- package/src/lib/dates.ts +18 -0
- package/src/lib/email.ts +65 -0
- package/src/lib/errors.ts +156 -0
- package/src/lib/http.ts +109 -0
- package/src/lib/ids.ts +61 -0
- package/src/lib/logger.ts +73 -0
- package/src/lib/moduleConfig.ts +65 -0
- package/src/lib/normalisation.ts +36 -0
- package/src/lib/pagination.ts +291 -0
- package/src/lib/passwords.ts +56 -0
- package/src/lib/search.ts +29 -0
- package/src/lib/secrets.ts +223 -0
- package/src/lib/timezones.ts +59 -0
- package/src/lib/tokens.ts +37 -0
- package/src/lib/url.ts +52 -0
- package/src/modules/activities/index.ts +43 -0
- package/src/modules/activities/recorder.ts +108 -0
- package/src/modules/activities/repository.ts +196 -0
- package/src/modules/activities/routes.ts +78 -0
- package/src/modules/activities/schema.ts +41 -0
- package/src/modules/activities/service.ts +93 -0
- package/src/modules/activities/tools.ts +40 -0
- package/src/modules/activities/wording.ts +168 -0
- package/src/modules/agent-tasks/catalog.ts +712 -0
- package/src/modules/agent-tasks/dispatch.ts +188 -0
- package/src/modules/agent-tasks/index.ts +79 -0
- package/src/modules/agent-tasks/prompt.ts +140 -0
- package/src/modules/agent-tasks/repository.ts +152 -0
- package/src/modules/agent-tasks/resolve.ts +704 -0
- package/src/modules/agent-tasks/routes.ts +260 -0
- package/src/modules/agent-tasks/schema.ts +57 -0
- package/src/modules/agent-tasks/service.ts +370 -0
- package/src/modules/agent-tasks/wire.ts +61 -0
- package/src/modules/api-keys/index.ts +34 -0
- package/src/modules/api-keys/keys.ts +59 -0
- package/src/modules/api-keys/repository.ts +82 -0
- package/src/modules/api-keys/routes.ts +83 -0
- package/src/modules/api-keys/schema.ts +28 -0
- package/src/modules/api-keys/service.ts +152 -0
- package/src/modules/attachedRecords.ts +85 -0
- package/src/modules/auth/actor.ts +17 -0
- package/src/modules/auth/credentials.ts +153 -0
- package/src/modules/auth/index.ts +49 -0
- package/src/modules/auth/preferences.ts +57 -0
- package/src/modules/auth/repository.ts +240 -0
- package/src/modules/auth/routes.ts +247 -0
- package/src/modules/auth/schema.ts +77 -0
- package/src/modules/auth/service.ts +441 -0
- package/src/modules/auth/session.ts +40 -0
- package/src/modules/companies/index.ts +43 -0
- package/src/modules/companies/repository.ts +185 -0
- package/src/modules/companies/routes.ts +170 -0
- package/src/modules/companies/schema.ts +66 -0
- package/src/modules/companies/service.ts +267 -0
- package/src/modules/companies/tools.ts +32 -0
- package/src/modules/core.ts +93 -0
- package/src/modules/crudTools.ts +226 -0
- package/src/modules/dashboard/attention.ts +67 -0
- package/src/modules/dashboard/index.ts +49 -0
- package/src/modules/dashboard/repository.ts +360 -0
- package/src/modules/dashboard/routes.ts +171 -0
- package/src/modules/dashboard/service.ts +449 -0
- package/src/modules/dashboard/tools.ts +39 -0
- package/src/modules/deals/index.ts +44 -0
- package/src/modules/deals/repository.ts +251 -0
- package/src/modules/deals/routes.ts +166 -0
- package/src/modules/deals/schema.ts +72 -0
- package/src/modules/deals/service.ts +433 -0
- package/src/modules/deals/tools.ts +39 -0
- package/src/modules/decisions/index.ts +40 -0
- package/src/modules/decisions/repository.ts +204 -0
- package/src/modules/decisions/routes.ts +184 -0
- package/src/modules/decisions/schema.ts +56 -0
- package/src/modules/decisions/service.ts +223 -0
- package/src/modules/decisions/tools.ts +38 -0
- package/src/modules/forms/embed.ts +274 -0
- package/src/modules/forms/fields.ts +206 -0
- package/src/modules/forms/index.ts +61 -0
- package/src/modules/forms/mapping.ts +222 -0
- package/src/modules/forms/publicRoutes.ts +92 -0
- package/src/modules/forms/repository.ts +223 -0
- package/src/modules/forms/routes.ts +276 -0
- package/src/modules/forms/schema.ts +135 -0
- package/src/modules/forms/service.ts +362 -0
- package/src/modules/forms/submission.ts +496 -0
- package/src/modules/forms/tools.ts +66 -0
- package/src/modules/handbook/index.ts +43 -0
- package/src/modules/handbook/repository.ts +173 -0
- package/src/modules/handbook/routes.ts +145 -0
- package/src/modules/handbook/schema.ts +43 -0
- package/src/modules/handbook/service.ts +399 -0
- package/src/modules/handbook/slugs.ts +54 -0
- package/src/modules/handbook/tools.ts +32 -0
- package/src/modules/handbook/tree.ts +158 -0
- package/src/modules/hiring/candidates.ts +391 -0
- package/src/modules/hiring/index.ts +55 -0
- package/src/modules/hiring/repository.ts +244 -0
- package/src/modules/hiring/roles.ts +174 -0
- package/src/modules/hiring/routes.ts +257 -0
- package/src/modules/hiring/schema.ts +93 -0
- package/src/modules/hiring/tools.ts +73 -0
- package/src/modules/import-export/csv.ts +180 -0
- package/src/modules/import-export/drafts.ts +182 -0
- package/src/modules/import-export/exportRows.ts +85 -0
- package/src/modules/import-export/index.ts +49 -0
- package/src/modules/import-export/mapping.ts +154 -0
- package/src/modules/import-export/plan.ts +311 -0
- package/src/modules/import-export/presets.ts +183 -0
- package/src/modules/import-export/repository.ts +603 -0
- package/src/modules/import-export/routes.ts +276 -0
- package/src/modules/import-export/schema.ts +142 -0
- package/src/modules/import-export/service.ts +842 -0
- package/src/modules/import-export/streams.ts +98 -0
- package/src/modules/import-export/tools.ts +153 -0
- package/src/modules/import-export/validation.ts +163 -0
- package/src/modules/import-export/writes.ts +365 -0
- package/src/modules/integrations/schema.ts +31 -0
- package/src/modules/mcp/index.ts +52 -0
- package/src/modules/mcp/protocol.ts +442 -0
- package/src/modules/mcp/router.ts +425 -0
- package/src/modules/notes/index.ts +43 -0
- package/src/modules/notes/repository.ts +130 -0
- package/src/modules/notes/routes.ts +170 -0
- package/src/modules/notes/schema.ts +42 -0
- package/src/modules/notes/service.ts +204 -0
- package/src/modules/notes/tools.ts +46 -0
- package/src/modules/opportunities/index.ts +44 -0
- package/src/modules/opportunities/repository.ts +157 -0
- package/src/modules/opportunities/routes.ts +152 -0
- package/src/modules/opportunities/schema.ts +47 -0
- package/src/modules/opportunities/service.ts +342 -0
- package/src/modules/opportunities/tools.ts +39 -0
- package/src/modules/partnerships/index.ts +44 -0
- package/src/modules/partnerships/repository.ts +274 -0
- package/src/modules/partnerships/routes.ts +170 -0
- package/src/modules/partnerships/schema.ts +65 -0
- package/src/modules/partnerships/service.ts +442 -0
- package/src/modules/partnerships/tools.ts +41 -0
- package/src/modules/people/index.ts +43 -0
- package/src/modules/people/repository.ts +167 -0
- package/src/modules/people/routes.ts +175 -0
- package/src/modules/people/schema.ts +89 -0
- package/src/modules/people/service.ts +284 -0
- package/src/modules/people/tools.ts +32 -0
- package/src/modules/pipelines/index.ts +43 -0
- package/src/modules/pipelines/repository.ts +116 -0
- package/src/modules/pipelines/routes.ts +157 -0
- package/src/modules/pipelines/schema.ts +37 -0
- package/src/modules/pipelines/service.ts +339 -0
- package/src/modules/pipelines/tools.ts +52 -0
- package/src/modules/plans/index.ts +39 -0
- package/src/modules/plans/repository.ts +174 -0
- package/src/modules/plans/routes.ts +212 -0
- package/src/modules/plans/schema.ts +45 -0
- package/src/modules/plans/service.ts +223 -0
- package/src/modules/plans/tools.ts +45 -0
- package/src/modules/positions/index.ts +42 -0
- package/src/modules/positions/repository.ts +136 -0
- package/src/modules/positions/routes.ts +97 -0
- package/src/modules/positions/schema.ts +42 -0
- package/src/modules/positions/service.ts +253 -0
- package/src/modules/positions/tools.ts +32 -0
- package/src/modules/raises/index.ts +44 -0
- package/src/modules/raises/repository.ts +254 -0
- package/src/modules/raises/routes.ts +160 -0
- package/src/modules/raises/schema.ts +66 -0
- package/src/modules/raises/service.ts +442 -0
- package/src/modules/raises/tools.ts +39 -0
- package/src/modules/recordTargets.ts +194 -0
- package/src/modules/references.ts +44 -0
- package/src/modules/reseal.ts +178 -0
- package/src/modules/search/index.ts +55 -0
- package/src/modules/search/query.ts +104 -0
- package/src/modules/search/repository.ts +388 -0
- package/src/modules/search/routes.ts +131 -0
- package/src/modules/search/service.ts +153 -0
- package/src/modules/search/tools.ts +60 -0
- package/src/modules/stagedRecords.ts +91 -0
- package/src/modules/webhooks/delivery.ts +349 -0
- package/src/modules/webhooks/index.ts +85 -0
- package/src/modules/webhooks/payloads.ts +84 -0
- package/src/modules/webhooks/repository.ts +244 -0
- package/src/modules/webhooks/routes.ts +240 -0
- package/src/modules/webhooks/schema.ts +78 -0
- package/src/modules/webhooks/service.ts +347 -0
- package/src/modules/webhooks/signing.ts +95 -0
- package/src/modules/webhooks/tools.ts +108 -0
- package/src/modules/webhooks/url.ts +21 -0
- package/src/modules/workspace/capabilities.ts +14 -0
- package/src/modules/workspace/idempotencyMiddleware.ts +207 -0
- package/src/modules/workspace/idempotencyRepository.ts +111 -0
- package/src/modules/workspace/index.ts +64 -0
- package/src/modules/workspace/repository.ts +420 -0
- package/src/modules/workspace/roles.ts +38 -0
- package/src/modules/workspace/routes.ts +255 -0
- package/src/modules/workspace/schema.ts +130 -0
- package/src/modules/workspace/service.ts +798 -0
- package/src/modules/workspace/starters.ts +69 -0
- package/src/modules/workspace/tools.ts +141 -0
- package/src/runtime/entitlements.ts +142 -0
- package/src/runtime/events.ts +185 -0
- package/src/runtime/migrate.ts +75 -0
- package/src/runtime/module.ts +147 -0
- package/src/runtime/moduleConfig.ts +68 -0
- package/src/runtime/order.ts +90 -0
- package/src/runtime/registry.ts +263 -0
- package/src/runtime/transaction.ts +80 -0
- package/src/schema/index.ts +30 -0
- package/src/testing/app.ts +79 -0
- package/src/testing/client.ts +118 -0
- package/src/testing/database.ts +106 -0
- package/src/testing/environment.ts +22 -0
- package/src/testing/fixtures.ts +70 -0
- package/src/testing/index.ts +13 -0
- package/src/testing/services.ts +67 -0
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
import { AppError } from '../../lib/errors.js';
|
|
2
|
+
import { UNIQUE_VIOLATION, postgresErrorCode } from '../../lib/database.js';
|
|
3
|
+
import { MINIMUM_PASSWORD_LENGTH, hashPassword, verifyPassword } from '../../lib/passwords.js';
|
|
4
|
+
import { generateToken, hashToken } from '../../lib/tokens.js';
|
|
5
|
+
import { DEFAULT_PREFERENCES, applyPreferenceChanges } from './preferences.js';
|
|
6
|
+
import * as repository from './repository.js';
|
|
7
|
+
/**
|
|
8
|
+
* Account and session rules.
|
|
9
|
+
*
|
|
10
|
+
* Two principles run through this file. Anything a stranger can call must not
|
|
11
|
+
* reveal whether an email is registered, so login and reset-request behave the
|
|
12
|
+
* same either way. And any change of password ends every other session, because
|
|
13
|
+
* the usual reason to change one is that it leaked.
|
|
14
|
+
*/
|
|
15
|
+
const SESSION_LIFETIME_MS = 30 * 24 * 60 * 60 * 1000;
|
|
16
|
+
const RESET_TOKEN_LIFETIME_MS = 60 * 60 * 1000;
|
|
17
|
+
function toAccountView(user) {
|
|
18
|
+
return { id: user.id, email: user.email, name: user.name };
|
|
19
|
+
}
|
|
20
|
+
function toPreferenceValues(record) {
|
|
21
|
+
return {
|
|
22
|
+
timezone: record.timezone,
|
|
23
|
+
theme: record.theme,
|
|
24
|
+
emailDigest: record.emailDigest,
|
|
25
|
+
mentionEmails: record.mentionEmails,
|
|
26
|
+
productUpdates: record.productUpdates,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
/** Emails are stored and compared lowercase, per `schema.md`. */
|
|
30
|
+
function normaliseEmail(email) {
|
|
31
|
+
return email.trim().toLowerCase();
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Rejects a field that is only whitespace.
|
|
35
|
+
*
|
|
36
|
+
* The route already refuses an empty string, but `" "` passes that and then
|
|
37
|
+
* normalises to nothing. Storing a nameless account or an empty address would be
|
|
38
|
+
* accepting a request the caller did not mean to make.
|
|
39
|
+
*/
|
|
40
|
+
function requireText(value, field) {
|
|
41
|
+
const trimmed = value.trim();
|
|
42
|
+
if (trimmed.length === 0) {
|
|
43
|
+
throw AppError.validationFailed(`${field} cannot be blank`, [
|
|
44
|
+
{ field, message: 'Cannot be blank' },
|
|
45
|
+
]);
|
|
46
|
+
}
|
|
47
|
+
return trimmed;
|
|
48
|
+
}
|
|
49
|
+
export function createAuthService(dependencies) {
|
|
50
|
+
const newToken = dependencies.newToken ?? generateToken;
|
|
51
|
+
/**
|
|
52
|
+
* The account behind a live session. A session outliving its user means the
|
|
53
|
+
* row was deleted underneath it, which is not an authenticated caller.
|
|
54
|
+
*/
|
|
55
|
+
async function requireUser(userId) {
|
|
56
|
+
const user = await repository.findUserById(dependencies.db, userId);
|
|
57
|
+
if (user === undefined) {
|
|
58
|
+
throw AppError.unauthorized('This session no longer belongs to an account');
|
|
59
|
+
}
|
|
60
|
+
return user;
|
|
61
|
+
}
|
|
62
|
+
async function issueSession(db, user, device, location) {
|
|
63
|
+
const now = dependencies.now();
|
|
64
|
+
const token = newToken();
|
|
65
|
+
const expiresAt = new Date(now.getTime() + SESSION_LIFETIME_MS);
|
|
66
|
+
const membership = await repository.findFirstMembership(db, user.id);
|
|
67
|
+
await repository.insertSession(db, {
|
|
68
|
+
id: dependencies.createId('session'),
|
|
69
|
+
userId: user.id,
|
|
70
|
+
activeWorkspaceId: membership?.workspaceId ?? null,
|
|
71
|
+
tokenHash: hashToken(token),
|
|
72
|
+
device: device ?? null,
|
|
73
|
+
location: location ?? null,
|
|
74
|
+
lastActiveAt: now,
|
|
75
|
+
expiresAt,
|
|
76
|
+
});
|
|
77
|
+
return {
|
|
78
|
+
account: toAccountView(user),
|
|
79
|
+
sessionToken: token,
|
|
80
|
+
expiresAt,
|
|
81
|
+
activeWorkspaceId: membership?.workspaceId ?? null,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
return {
|
|
85
|
+
/** Creates the account only. The first workspace comes from onboarding. */
|
|
86
|
+
async signUp(input) {
|
|
87
|
+
if (input.password.length < MINIMUM_PASSWORD_LENGTH) {
|
|
88
|
+
throw AppError.validationFailed('Password is too short', [
|
|
89
|
+
{ field: 'password', message: `Must be at least ${MINIMUM_PASSWORD_LENGTH} characters` },
|
|
90
|
+
]);
|
|
91
|
+
}
|
|
92
|
+
const email = normaliseEmail(input.email);
|
|
93
|
+
const passwordHash = await hashPassword(input.password);
|
|
94
|
+
return dependencies.transaction(async ({ tx }) => {
|
|
95
|
+
let user;
|
|
96
|
+
try {
|
|
97
|
+
user = await repository.insertUser(tx, {
|
|
98
|
+
id: dependencies.createId('user'),
|
|
99
|
+
email,
|
|
100
|
+
name: input.name,
|
|
101
|
+
passwordHash,
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
catch (error) {
|
|
105
|
+
if (postgresErrorCode(error) === UNIQUE_VIOLATION) {
|
|
106
|
+
// Signup is the one place the address is already known to the caller,
|
|
107
|
+
// so saying so is not a disclosure.
|
|
108
|
+
throw AppError.conflict('An account with that email already exists', [
|
|
109
|
+
{ field: 'email', message: 'Already registered' },
|
|
110
|
+
]);
|
|
111
|
+
}
|
|
112
|
+
throw error;
|
|
113
|
+
}
|
|
114
|
+
return issueSession(tx, user, input.device, input.location);
|
|
115
|
+
});
|
|
116
|
+
},
|
|
117
|
+
async logIn(input) {
|
|
118
|
+
const user = await repository.findUserByEmail(dependencies.db, normaliseEmail(input.email));
|
|
119
|
+
// Hash a throwaway password when the user is unknown, so a missing account
|
|
120
|
+
// and a wrong password take the same time to answer.
|
|
121
|
+
const storedHash = user?.passwordHash ?? (await hashPassword('not-a-real-password-placeholder'));
|
|
122
|
+
if (!(await verifyPassword(storedHash, input.password)) || user === undefined) {
|
|
123
|
+
throw AppError.unauthorized('Email or password is incorrect');
|
|
124
|
+
}
|
|
125
|
+
return dependencies.transaction(({ tx }) => issueSession(tx, user, input.device, input.location));
|
|
126
|
+
},
|
|
127
|
+
async logOut(actor) {
|
|
128
|
+
await repository.deleteSession(dependencies.db, actor.userId, actor.sessionId);
|
|
129
|
+
},
|
|
130
|
+
async getAccount(actor) {
|
|
131
|
+
return toAccountView(await requireUser(actor.userId));
|
|
132
|
+
},
|
|
133
|
+
/**
|
|
134
|
+
* Name and email, for every workspace at once. An account is global, so this
|
|
135
|
+
* is not a change to one membership.
|
|
136
|
+
*
|
|
137
|
+
* Moving the address is treated like a password change, because it is one:
|
|
138
|
+
* whoever controls the sign-in address controls the account through a
|
|
139
|
+
* password reset. The current password must verify, every other session
|
|
140
|
+
* ends, and the address being replaced is told, in case the caller was not
|
|
141
|
+
* its owner.
|
|
142
|
+
*/
|
|
143
|
+
async updateAccount(actor, changes) {
|
|
144
|
+
const user = await requireUser(actor.userId);
|
|
145
|
+
const values = {
|
|
146
|
+
...(changes.name === undefined ? {} : { name: requireText(changes.name, 'name') }),
|
|
147
|
+
...(changes.email === undefined
|
|
148
|
+
? {}
|
|
149
|
+
: { email: requireText(normaliseEmail(changes.email), 'email') }),
|
|
150
|
+
};
|
|
151
|
+
if (changes.email !== undefined &&
|
|
152
|
+
(changes.currentPassword === undefined ||
|
|
153
|
+
!(await verifyPassword(user.passwordHash, changes.currentPassword)))) {
|
|
154
|
+
throw AppError.unauthorized('Current password is incorrect');
|
|
155
|
+
}
|
|
156
|
+
const previousEmail = user.email;
|
|
157
|
+
try {
|
|
158
|
+
const updated = await dependencies.transaction(async ({ tx }) => {
|
|
159
|
+
const saved = await repository.updateUserProfile(tx, actor.userId, values, dependencies.now());
|
|
160
|
+
if (saved === undefined) {
|
|
161
|
+
throw AppError.unauthorized('This session no longer belongs to an account');
|
|
162
|
+
}
|
|
163
|
+
if (changes.email !== undefined) {
|
|
164
|
+
await repository.deleteOtherSessionsForUser(tx, actor.userId, actor.sessionId);
|
|
165
|
+
}
|
|
166
|
+
return saved;
|
|
167
|
+
});
|
|
168
|
+
if (changes.email !== undefined) {
|
|
169
|
+
await dependencies.email.send({
|
|
170
|
+
to: previousEmail,
|
|
171
|
+
subject: 'Your Kelpie sign-in email changed',
|
|
172
|
+
body: `Your Kelpie sign-in email changed from ${previousEmail} to ${updated.email}. If you did not make this change, reset your password right away.`,
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
return toAccountView(updated);
|
|
176
|
+
}
|
|
177
|
+
catch (error) {
|
|
178
|
+
if (postgresErrorCode(error) === UNIQUE_VIOLATION) {
|
|
179
|
+
// The caller typed this address, so naming the clash discloses nothing
|
|
180
|
+
// they did not already supply. Same reasoning as signup.
|
|
181
|
+
throw AppError.conflict('An account with that email already exists', [
|
|
182
|
+
{ field: 'email', message: 'Already registered' },
|
|
183
|
+
]);
|
|
184
|
+
}
|
|
185
|
+
throw error;
|
|
186
|
+
}
|
|
187
|
+
},
|
|
188
|
+
async getPreferences(actor) {
|
|
189
|
+
const stored = await repository.findPreferences(dependencies.db, actor.userId);
|
|
190
|
+
return stored === undefined ? DEFAULT_PREFERENCES : toPreferenceValues(stored);
|
|
191
|
+
},
|
|
192
|
+
/**
|
|
193
|
+
* Writes the whole row from defaults plus what is stored plus what changed,
|
|
194
|
+
* so a first save and a later one take the same path and a repeat is a no-op.
|
|
195
|
+
*/
|
|
196
|
+
async updatePreferences(actor, changes) {
|
|
197
|
+
await requireUser(actor.userId);
|
|
198
|
+
return dependencies.transaction(async ({ tx }) => {
|
|
199
|
+
const stored = await repository.findPreferences(tx, actor.userId);
|
|
200
|
+
const values = applyPreferenceChanges(stored === undefined ? undefined : toPreferenceValues(stored), changes);
|
|
201
|
+
return toPreferenceValues(await repository.upsertPreferences(tx, {
|
|
202
|
+
userId: actor.userId,
|
|
203
|
+
...values,
|
|
204
|
+
updatedAt: dependencies.now(),
|
|
205
|
+
}));
|
|
206
|
+
});
|
|
207
|
+
},
|
|
208
|
+
async listSessions(actor) {
|
|
209
|
+
const records = await repository.listSessionsForUser(dependencies.db, actor.userId);
|
|
210
|
+
return records.map((record) => ({
|
|
211
|
+
id: record.id,
|
|
212
|
+
device: record.device,
|
|
213
|
+
location: record.location,
|
|
214
|
+
lastActiveAt: record.lastActiveAt,
|
|
215
|
+
current: record.id === actor.sessionId,
|
|
216
|
+
}));
|
|
217
|
+
},
|
|
218
|
+
async revokeSession(actor, sessionId) {
|
|
219
|
+
const removed = await repository.deleteSession(dependencies.db, actor.userId, sessionId);
|
|
220
|
+
if (removed === 0) {
|
|
221
|
+
// Another user's session id is indistinguishable from one that never
|
|
222
|
+
// existed, which is what `api.md` requires of a cross-tenant miss.
|
|
223
|
+
throw AppError.notFound('Session not found');
|
|
224
|
+
}
|
|
225
|
+
},
|
|
226
|
+
/**
|
|
227
|
+
* Always resolves, whether or not the address is registered. Telling a
|
|
228
|
+
* stranger which addresses have accounts is the whole attack.
|
|
229
|
+
*/
|
|
230
|
+
async requestPasswordReset(email, resetUrlTemplate) {
|
|
231
|
+
const user = await repository.findUserByEmail(dependencies.db, normaliseEmail(email));
|
|
232
|
+
if (user === undefined) {
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
const now = dependencies.now();
|
|
236
|
+
const token = newToken();
|
|
237
|
+
await repository.insertPasswordResetToken(dependencies.db, {
|
|
238
|
+
id: dependencies.createId('passwordResetToken'),
|
|
239
|
+
userId: user.id,
|
|
240
|
+
tokenHash: hashToken(token),
|
|
241
|
+
expiresAt: new Date(now.getTime() + RESET_TOKEN_LIFETIME_MS),
|
|
242
|
+
});
|
|
243
|
+
await dependencies.email.send({
|
|
244
|
+
to: user.email,
|
|
245
|
+
subject: 'Reset your Kelpie password',
|
|
246
|
+
body: `Use this link within the hour to choose a new password:\n\n${resetUrlTemplate.replace('{token}', token)}\n\nIf you did not ask for this, ignore it.`,
|
|
247
|
+
});
|
|
248
|
+
},
|
|
249
|
+
/** Ends every session on success: a reset is how you recover a stolen account. */
|
|
250
|
+
async confirmPasswordReset(token, newPassword) {
|
|
251
|
+
if (newPassword.length < MINIMUM_PASSWORD_LENGTH) {
|
|
252
|
+
throw AppError.validationFailed('Password is too short', [
|
|
253
|
+
{ field: 'password', message: `Must be at least ${MINIMUM_PASSWORD_LENGTH} characters` },
|
|
254
|
+
]);
|
|
255
|
+
}
|
|
256
|
+
const now = dependencies.now();
|
|
257
|
+
const record = await repository.findUsablePasswordResetToken(dependencies.db, hashToken(token), now);
|
|
258
|
+
if (record === undefined) {
|
|
259
|
+
throw AppError.unauthorized('That reset link is invalid or has expired');
|
|
260
|
+
}
|
|
261
|
+
const passwordHash = await hashPassword(newPassword);
|
|
262
|
+
await dependencies.transaction(async ({ tx }) => {
|
|
263
|
+
await repository.markPasswordResetTokenUsed(tx, record.id, now);
|
|
264
|
+
await repository.updateUserPassword(tx, record.userId, passwordHash, now);
|
|
265
|
+
await repository.deleteAllSessionsForUser(tx, record.userId);
|
|
266
|
+
});
|
|
267
|
+
},
|
|
268
|
+
/** Keeps the caller signed in and ends every other session. */
|
|
269
|
+
async changePassword(actor, currentPassword, newPassword) {
|
|
270
|
+
if (newPassword.length < MINIMUM_PASSWORD_LENGTH) {
|
|
271
|
+
throw AppError.validationFailed('Password is too short', [
|
|
272
|
+
{ field: 'new_password', message: `Must be at least ${MINIMUM_PASSWORD_LENGTH} characters` },
|
|
273
|
+
]);
|
|
274
|
+
}
|
|
275
|
+
const user = await repository.findUserById(dependencies.db, actor.userId);
|
|
276
|
+
if (user === undefined || !(await verifyPassword(user.passwordHash, currentPassword))) {
|
|
277
|
+
throw AppError.unauthorized('Current password is incorrect');
|
|
278
|
+
}
|
|
279
|
+
const now = dependencies.now();
|
|
280
|
+
const passwordHash = await hashPassword(newPassword);
|
|
281
|
+
await dependencies.transaction(async ({ tx }) => {
|
|
282
|
+
await repository.updateUserPassword(tx, user.id, passwordHash, now);
|
|
283
|
+
await repository.deleteOtherSessionsForUser(tx, user.id, actor.sessionId);
|
|
284
|
+
});
|
|
285
|
+
},
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
//# sourceMappingURL=service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.js","sourceRoot":"","sources":["../../../src/modules/auth/service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAE9C,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;AAE3E,OAAO,EAAE,uBAAuB,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AAC9F,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAG9D,OAAO,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAA;AAE9E,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAA;AAE7C;;;;;;;GAOG;AAEH,MAAM,mBAAmB,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAA;AACpD,MAAM,uBAAuB,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAA;AAyD9C,SAAS,aAAa,CAAC,IAA2B;IAChD,OAAO,EAAE,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAA;AAC5D,CAAC;AAED,SAAS,kBAAkB,CAAC,MAAwC;IAClE,OAAO;QACL,QAAQ,EAAE,MAAM,CAAC,QAAQ;QACzB,KAAK,EAAE,MAAM,CAAC,KAAK;QACnB,WAAW,EAAE,MAAM,CAAC,WAAW;QAC/B,aAAa,EAAE,MAAM,CAAC,aAAa;QACnC,cAAc,EAAE,MAAM,CAAC,cAAc;KACtC,CAAA;AACH,CAAC;AAED,iEAAiE;AACjE,SAAS,cAAc,CAAC,KAAa;IACnC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EAAE,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,oBAAoB,uBAAuB,aAAa,EAAE;iBAC7F,CAAC,CAAA;YACJ,CAAC;YAED,MAAM,IAAI,GAAG,MAAM,UAAU,CAAC,YAAY,CAAC,YAAY,CAAC,EAAE,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;YAEzE,IAAI,IAAI,KAAK,SAAS,IAAI,CAAC,CAAC,MAAM,cAAc,CAAC,IAAI,CAAC,YAAY,EAAE,eAAe,CAAC,CAAC,EAAE,CAAC;gBACtF,MAAM,QAAQ,CAAC,YAAY,CAAC,+BAA+B,CAAC,CAAA;YAC9D,CAAC;YAED,MAAM,GAAG,GAAG,YAAY,CAAC,GAAG,EAAE,CAAA;YAC9B,MAAM,YAAY,GAAG,MAAM,YAAY,CAAC,WAAW,CAAC,CAAA;YAEpD,MAAM,YAAY,CAAC,WAAW,CAAC,KAAK,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE;gBAC9C,MAAM,UAAU,CAAC,kBAAkB,CAAC,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,YAAY,EAAE,GAAG,CAAC,CAAA;gBACnE,MAAM,UAAU,CAAC,0BAA0B,CAAC,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,KAAK,CAAC,SAAS,CAAC,CAAA;YAC3E,CAAC,CAAC,CAAA;QACJ,CAAC;KACF,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Context } from 'hono';
|
|
2
|
+
/**
|
|
3
|
+
* The session cookie. Turning credentials into an actor lives in
|
|
4
|
+
* `credentials.ts`, which handles bearer keys too.
|
|
5
|
+
*
|
|
6
|
+
* `api.md`: the workspace is always implicit. It comes from the session or the
|
|
7
|
+
* key, never from a header, a path segment, or a request body.
|
|
8
|
+
*/
|
|
9
|
+
export declare const SESSION_COOKIE = "kelpie_session";
|
|
10
|
+
export interface SessionCookieOptions {
|
|
11
|
+
/** Only sent over HTTPS outside development. */
|
|
12
|
+
readonly secure: boolean;
|
|
13
|
+
}
|
|
14
|
+
export declare function writeSessionCookie(context: Context, token: string, options: SessionCookieOptions): void;
|
|
15
|
+
export declare function clearSessionCookie(context: Context, options: SessionCookieOptions): void;
|
|
16
|
+
//# sourceMappingURL=session.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../../src/modules/auth/session.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AAEnC;;;;;;GAMG;AAEH,eAAO,MAAM,cAAc,mBAAmB,CAAA;AAK9C,MAAM,WAAW,oBAAoB;IACnC,gDAAgD;IAChD,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAA;CACzB;AAED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,oBAAoB,GAAG,IAAI,CAQvG;AAED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,oBAAoB,GAAG,IAAI,CAQxF"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { setCookie } from 'hono/cookie';
|
|
2
|
+
/**
|
|
3
|
+
* The session cookie. Turning credentials into an actor lives in
|
|
4
|
+
* `credentials.ts`, which handles bearer keys too.
|
|
5
|
+
*
|
|
6
|
+
* `api.md`: the workspace is always implicit. It comes from the session or the
|
|
7
|
+
* key, never from a header, a path segment, or a request body.
|
|
8
|
+
*/
|
|
9
|
+
export const SESSION_COOKIE = 'kelpie_session';
|
|
10
|
+
/** Thirty days, matching the session row's expiry. */
|
|
11
|
+
const COOKIE_MAX_AGE_SECONDS = 30 * 24 * 60 * 60;
|
|
12
|
+
export function writeSessionCookie(context, token, options) {
|
|
13
|
+
setCookie(context, SESSION_COOKIE, token, {
|
|
14
|
+
httpOnly: true,
|
|
15
|
+
sameSite: 'Lax',
|
|
16
|
+
secure: options.secure,
|
|
17
|
+
path: '/',
|
|
18
|
+
maxAge: COOKIE_MAX_AGE_SECONDS,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
export function clearSessionCookie(context, options) {
|
|
22
|
+
setCookie(context, SESSION_COOKIE, '', {
|
|
23
|
+
httpOnly: true,
|
|
24
|
+
sameSite: 'Lax',
|
|
25
|
+
secure: options.secure,
|
|
26
|
+
path: '/',
|
|
27
|
+
maxAge: 0,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=session.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session.js","sourceRoot":"","sources":["../../../src/modules/auth/session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAGvC;;;;;;GAMG;AAEH,MAAM,CAAC,MAAM,cAAc,GAAG,gBAAgB,CAAA;AAE9C,sDAAsD;AACtD,MAAM,sBAAsB,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAA;AAOhD,MAAM,UAAU,kBAAkB,CAAC,OAAgB,EAAE,KAAa,EAAE,OAA6B;IAC/F,SAAS,CAAC,OAAO,EAAE,cAAc,EAAE,KAAK,EAAE;QACxC,QAAQ,EAAE,IAAI;QACd,QAAQ,EAAE,KAAK;QACf,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,IAAI,EAAE,GAAG;QACT,MAAM,EAAE,sBAAsB;KAC/B,CAAC,CAAA;AACJ,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,OAAgB,EAAE,OAA6B;IAChF,SAAS,CAAC,OAAO,EAAE,cAAc,EAAE,EAAE,EAAE;QACrC,QAAQ,EAAE,IAAI;QACd,QAAQ,EAAE,KAAK;QACf,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,IAAI,EAAE,GAAG;QACT,MAAM,EAAE,CAAC;KACV,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { KelpieModule } from '../../runtime/module.ts';
|
|
2
|
+
/**
|
|
3
|
+
* Companies: the organisations behind the people.
|
|
4
|
+
*
|
|
5
|
+
* Requires `workspace` only. People reach companies through Position, which is
|
|
6
|
+
* its own module, so nothing here depends on `people`.
|
|
7
|
+
*/
|
|
8
|
+
export declare function createCompaniesModule(migrationsDirectory: string): KelpieModule;
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/modules/companies/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAO3D;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,mBAAmB,EAAE,MAAM,GAAG,YAAY,CA6B/E"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { createActivityRecorder } from '../activities/index.js';
|
|
2
|
+
import { mountCompaniesRoutes } from './routes.js';
|
|
3
|
+
import * as schema from './schema.js';
|
|
4
|
+
import { createCompaniesService } from './service.js';
|
|
5
|
+
import { registerCompaniesTools } from './tools.js';
|
|
6
|
+
/**
|
|
7
|
+
* Companies: the organisations behind the people.
|
|
8
|
+
*
|
|
9
|
+
* Requires `workspace` only. People reach companies through Position, which is
|
|
10
|
+
* its own module, so nothing here depends on `people`.
|
|
11
|
+
*/
|
|
12
|
+
export function createCompaniesModule(migrationsDirectory) {
|
|
13
|
+
return {
|
|
14
|
+
id: 'companies',
|
|
15
|
+
requires: ['workspace', 'activities'],
|
|
16
|
+
structural: true,
|
|
17
|
+
register(context) {
|
|
18
|
+
const service = createCompaniesService({
|
|
19
|
+
db: context.db,
|
|
20
|
+
transaction: context.transaction,
|
|
21
|
+
createId: context.createId,
|
|
22
|
+
now: context.now,
|
|
23
|
+
recordActivity: createActivityRecorder({
|
|
24
|
+
createId: context.createId,
|
|
25
|
+
now: context.now,
|
|
26
|
+
}),
|
|
27
|
+
});
|
|
28
|
+
context.schema(schema, migrationsDirectory);
|
|
29
|
+
context.routes((router) => {
|
|
30
|
+
mountCompaniesRoutes(router, { db: context.db, now: context.now, service });
|
|
31
|
+
});
|
|
32
|
+
registerCompaniesTools(context.mcp, service);
|
|
33
|
+
return Promise.resolve();
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/modules/companies/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAA;AAC/D,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAClD,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AACrC,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAA;AACrD,OAAO,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAA;AAEnD;;;;;GAKG;AACH,MAAM,UAAU,qBAAqB,CAAC,mBAA2B;IAC/D,OAAO;QACL,EAAE,EAAE,WAAW;QACf,QAAQ,EAAE,CAAC,WAAW,EAAE,YAAY,CAAC;QACrC,UAAU,EAAE,IAAI;QAEhB,QAAQ,CAAC,OAAO;YACd,MAAM,OAAO,GAAG,sBAAsB,CAAC;gBACrC,EAAE,EAAE,OAAO,CAAC,EAAE;gBACd,WAAW,EAAE,OAAO,CAAC,WAAW;gBAChC,QAAQ,EAAE,OAAO,CAAC,QAAQ;gBAC1B,GAAG,EAAE,OAAO,CAAC,GAAG;gBAChB,cAAc,EAAE,sBAAsB,CAAC;oBACrC,QAAQ,EAAE,OAAO,CAAC,QAAQ;oBAC1B,GAAG,EAAE,OAAO,CAAC,GAAG;iBACjB,CAAC;aACH,CAAC,CAAA;YAEF,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAA;YAE3C,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE;gBACxB,oBAAoB,CAAC,MAAM,EAAE,EAAE,EAAE,EAAE,OAAO,CAAC,EAAE,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,OAAO,EAAE,CAAC,CAAA;YAC7E,CAAC,CAAC,CAAA;YAEF,sBAAsB,CAAC,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,CAAA;YAE5C,OAAO,OAAO,CAAC,OAAO,EAAE,CAAA;QAC1B,CAAC;KACF,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { ListWindow, SortableFields } from '../../lib/pagination.ts';
|
|
2
|
+
import type { Queryable } from '../../runtime/transaction.ts';
|
|
3
|
+
import { companies } from './schema.ts';
|
|
4
|
+
export type CompanyRecord = typeof companies.$inferSelect;
|
|
5
|
+
/** The writable column shape. Services build one of these; nothing else knows the column names. */
|
|
6
|
+
export type CompanyColumns = typeof companies.$inferInsert;
|
|
7
|
+
/** The sort fields `?sort=` documents for companies. Nullable columns stay out: a keyset cannot seek past a null. */
|
|
8
|
+
export declare const COMPANY_SORTS: SortableFields<CompanyRecord>;
|
|
9
|
+
export declare const DEFAULT_COMPANY_SORT = "-created_at";
|
|
10
|
+
export interface CompanyFilters {
|
|
11
|
+
/** `?q=`, matched the way the mockup's Companies filter matches. */
|
|
12
|
+
readonly term?: string | undefined;
|
|
13
|
+
/** `?person_id=`, repeatable: companies where any of these people holds a position. */
|
|
14
|
+
readonly personIds?: readonly string[] | undefined;
|
|
15
|
+
}
|
|
16
|
+
/** @returns Up to `window.fetchLimit` rows: one more than the page, so the caller can tell there is a next one. */
|
|
17
|
+
export declare function listCompanies(db: Queryable, workspaceId: string, filters: CompanyFilters, window: ListWindow<CompanyRecord>): Promise<CompanyRecord[]>;
|
|
18
|
+
export declare function findCompany(db: Queryable, workspaceId: string, id: string): Promise<CompanyRecord | undefined>;
|
|
19
|
+
/**
|
|
20
|
+
* The one company in this workspace on a domain. `domain` is unique per
|
|
21
|
+
* workspace and `citext`, so the comparison matches whatever case arrived.
|
|
22
|
+
*/
|
|
23
|
+
export declare function findCompanyByDomain(db: Queryable, workspaceId: string, domain: string): Promise<CompanyRecord | undefined>;
|
|
24
|
+
/**
|
|
25
|
+
* A company matched by name, for a form submit that was given a name and no
|
|
26
|
+
* domain.
|
|
27
|
+
*
|
|
28
|
+
* Names are not unique, so this is a weaker match than the domain one and is
|
|
29
|
+
* only ever tried second (`forms.md` submit rule 4). The oldest row wins, which
|
|
30
|
+
* makes a repeat submission attach to the same company every time rather than
|
|
31
|
+
* following whichever duplicate was edited last.
|
|
32
|
+
*
|
|
33
|
+
* `lower(…) = lower(…)` rather than `ilike`: the name is caller data, and
|
|
34
|
+
* `ilike` would read a `%` or `_` inside it as a wildcard.
|
|
35
|
+
*/
|
|
36
|
+
export declare function findCompanyByName(db: Queryable, workspaceId: string, name: string): Promise<CompanyRecord | undefined>;
|
|
37
|
+
export declare function insertCompany(db: Queryable, values: CompanyColumns): Promise<CompanyRecord>;
|
|
38
|
+
export declare function updateCompany(db: Queryable, workspaceId: string, id: string, changes: Partial<CompanyColumns>): Promise<CompanyRecord | undefined>;
|
|
39
|
+
export declare function deleteCompany(db: Queryable, workspaceId: string, id: string): Promise<number>;
|
|
40
|
+
//# sourceMappingURL=repository.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"repository.d.ts","sourceRoot":"","sources":["../../../src/modules/companies/repository.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAEzE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAA;AAE7D,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAEvC,MAAM,MAAM,aAAa,GAAG,OAAO,SAAS,CAAC,YAAY,CAAA;AAEzD,mGAAmG;AACnG,MAAM,MAAM,cAAc,GAAG,OAAO,SAAS,CAAC,Y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Aa,GAAG,SAAS,CAAC,CAQpC;AAED,wBAAsB,aAAa,CACjC,EAAE,EAAE,SAAS,EACb,WAAW,EAAE,MAAM,EACnB,EAAE,EAAE,MAAM,GACT,OAAO,CAAC,MAAM,CAAC,CAOjB"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { and, asc, eq, ilike, inArray, or, sql } from 'drizzle-orm';
|
|
2
|
+
import { keysetCondition, orderByWindow, textSort, timestampSort } from '../../lib/pagination.js';
|
|
3
|
+
import { arrayContainsPattern, containsPattern } from '../../lib/search.js';
|
|
4
|
+
import { positions } from '../positions/schema.js';
|
|
5
|
+
import { companies } from './schema.js';
|
|
6
|
+
/** The sort fields `?sort=` documents for companies. Nullable columns stay out: a keyset cannot seek past a null. */
|
|
7
|
+
export const COMPANY_SORTS = {
|
|
8
|
+
name: textSort(companies.name, (company) => company.name),
|
|
9
|
+
created_at: timestampSort(companies.createdAt, (company) => company.createdAt),
|
|
10
|
+
updated_at: timestampSort(companies.updatedAt, (company) => company.updatedAt),
|
|
11
|
+
};
|
|
12
|
+
export const DEFAULT_COMPANY_SORT = '-created_at';
|
|
13
|
+
/**
|
|
14
|
+
* `api.md` has no `include` expansion, so without this filter a person detail
|
|
15
|
+
* page would fetch the person's positions and then one company per position.
|
|
16
|
+
*
|
|
17
|
+
* Reads the `positions` table, never its repository. See the same note in the
|
|
18
|
+
* people repository.
|
|
19
|
+
*/
|
|
20
|
+
function employsAnyOf(personIds) {
|
|
21
|
+
return sql `exists (
|
|
22
|
+
select 1
|
|
23
|
+
from ${positions}
|
|
24
|
+
where ${positions.companyId} = ${companies.id}
|
|
25
|
+
and ${positions.workspaceId} = ${companies.workspaceId}
|
|
26
|
+
and ${inArray(positions.personId, personIds)}
|
|
27
|
+
)`;
|
|
28
|
+
}
|
|
29
|
+
function matchesTerm(term) {
|
|
30
|
+
const pattern = containsPattern(term);
|
|
31
|
+
return or(ilike(companies.name, pattern), ilike(companies.domain, pattern), ilike(companies.industry, pattern), ilike(companies.summary, pattern), ilike(companies.accountType, pattern), arrayContainsPattern(companies.tags, pattern));
|
|
32
|
+
}
|
|
33
|
+
function conditionsFor(workspaceId, filters) {
|
|
34
|
+
return [
|
|
35
|
+
eq(companies.workspaceId, workspaceId),
|
|
36
|
+
filters.term === undefined ? undefined : matchesTerm(filters.term),
|
|
37
|
+
filters.personIds === undefined ? undefined : employsAnyOf(filters.personIds),
|
|
38
|
+
];
|
|
39
|
+
}
|
|
40
|
+
/** @returns Up to `window.fetchLimit` rows: one more than the page, so the caller can tell there is a next one. */
|
|
41
|
+
export function listCompanies(db, workspaceId, filters, window) {
|
|
42
|
+
return db
|
|
43
|
+
.select()
|
|
44
|
+
.from(companies)
|
|
45
|
+
.where(and(...conditionsFor(workspaceId, filters), keysetCondition(window, companies.id)))
|
|
46
|
+
.orderBy(...orderByWindow(window, companies.id))
|
|
47
|
+
.limit(window.fetchLimit);
|
|
48
|
+
}
|
|
49
|
+
export async function findCompany(db, workspaceId, id) {
|
|
50
|
+
const [found] = await db
|
|
51
|
+
.select()
|
|
52
|
+
.from(companies)
|
|
53
|
+
.where(and(eq(companies.workspaceId, workspaceId), eq(companies.id, id)))
|
|
54
|
+
.limit(1);
|
|
55
|
+
return found;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* The one company in this workspace on a domain. `domain` is unique per
|
|
59
|
+
* workspace and `citext`, so the comparison matches whatever case arrived.
|
|
60
|
+
*/
|
|
61
|
+
export async function findCompanyByDomain(db, workspaceId, domain) {
|
|
62
|
+
const [found] = await db
|
|
63
|
+
.select()
|
|
64
|
+
.from(companies)
|
|
65
|
+
.where(and(eq(companies.workspaceId, workspaceId), eq(companies.domain, domain)))
|
|
66
|
+
.limit(1);
|
|
67
|
+
return found;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* A company matched by name, for a form submit that was given a name and no
|
|
71
|
+
* domain.
|
|
72
|
+
*
|
|
73
|
+
* Names are not unique, so this is a weaker match than the domain one and is
|
|
74
|
+
* only ever tried second (`forms.md` submit rule 4). The oldest row wins, which
|
|
75
|
+
* makes a repeat submission attach to the same company every time rather than
|
|
76
|
+
* following whichever duplicate was edited last.
|
|
77
|
+
*
|
|
78
|
+
* `lower(…) = lower(…)` rather than `ilike`: the name is caller data, and
|
|
79
|
+
* `ilike` would read a `%` or `_` inside it as a wildcard.
|
|
80
|
+
*/
|
|
81
|
+
export async function findCompanyByName(db, workspaceId, name) {
|
|
82
|
+
const [found] = await db
|
|
83
|
+
.select()
|
|
84
|
+
.from(companies)
|
|
85
|
+
.where(and(eq(companies.workspaceId, workspaceId), sql `lower(${companies.name}) = lower(${sql.param(name, companies.name)})`))
|
|
86
|
+
.orderBy(asc(companies.createdAt), asc(companies.id))
|
|
87
|
+
.limit(1);
|
|
88
|
+
return found;
|
|
89
|
+
}
|
|
90
|
+
export async function insertCompany(db, values) {
|
|
91
|
+
const [created] = await db.insert(companies).values(values).returning();
|
|
92
|
+
if (created === undefined) {
|
|
93
|
+
throw new Error(`Inserting company ${values.id} returned no row`);
|
|
94
|
+
}
|
|
95
|
+
return created;
|
|
96
|
+
}
|
|
97
|
+
export async function updateCompany(db, workspaceId, id, changes) {
|
|
98
|
+
const [updated] = await db
|
|
99
|
+
.update(companies)
|
|
100
|
+
.set(changes)
|
|
101
|
+
.where(and(eq(companies.workspaceId, workspaceId), eq(companies.id, id)))
|
|
102
|
+
.returning();
|
|
103
|
+
return updated;
|
|
104
|
+
}
|
|
105
|
+
export async function deleteCompany(db, workspaceId, id) {
|
|
106
|
+
const deleted = await db
|
|
107
|
+
.delete(companies)
|
|
108
|
+
.where(and(eq(companies.workspaceId, workspaceId), eq(companies.id, id)))
|
|
109
|
+
.returning({ id: companies.id });
|
|
110
|
+
return deleted.length;
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=repository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"repository.js","sourceRoot":"","sources":["../../../src/modules/companies/repository.ts"],"names":[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