@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,237 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { describeThrown } from '../../lib/errors.js';
|
|
3
|
+
import * as repository from './repository.js';
|
|
4
|
+
import { deliveryBody, deliveryHeaders, renderDeliveryBody, signDeliveryBody } from './signing.js';
|
|
5
|
+
/**
|
|
6
|
+
* The delivery engine: a consumer of the internal event bus that turns one
|
|
7
|
+
* domain event into one signed HTTP request per subscribed webhook.
|
|
8
|
+
*
|
|
9
|
+
* It runs after the emitting transaction commits and is not awaited by the
|
|
10
|
+
* request that caused it (`runtime/transaction.ts`), so an unreachable endpoint
|
|
11
|
+
* slows nobody down.
|
|
12
|
+
*
|
|
13
|
+
* Delivery is at-least-once and there is no durable queue, the same caveat the
|
|
14
|
+
* bus itself carries. A crash between the commit and the last attempt loses the
|
|
15
|
+
* delivery; the retry budget below is deliberately small so a graceful shutdown
|
|
16
|
+
* is not held open for minutes waiting for an endpoint that is already gone.
|
|
17
|
+
*/
|
|
18
|
+
/** How long one attempt may take before it counts as failed. */
|
|
19
|
+
export const DELIVERY_TIMEOUT_MS = 10_000;
|
|
20
|
+
/** Waits between attempts. Its length plus one is the attempt budget. */
|
|
21
|
+
export const RETRY_DELAYS_MS = [1_000, 5_000, 15_000];
|
|
22
|
+
export const MAX_DELIVERY_ATTEMPTS = RETRY_DELAYS_MS.length + 1;
|
|
23
|
+
/**
|
|
24
|
+
* @param attempts How many attempts have already been made.
|
|
25
|
+
* @returns How long to wait before the next one, or undefined when the budget
|
|
26
|
+
* is spent and the delivery has failed for good.
|
|
27
|
+
*/
|
|
28
|
+
export function retryDelayAfter(attempts) {
|
|
29
|
+
return RETRY_DELAYS_MS[attempts - 1];
|
|
30
|
+
}
|
|
31
|
+
const DAY_MS = 86_400_000;
|
|
32
|
+
/** What an unset `WEBHOOK_DELIVERY_RETENTION_DAYS` means. */
|
|
33
|
+
export const DEFAULT_DELIVERY_RETENTION_DAYS = 30;
|
|
34
|
+
/**
|
|
35
|
+
* The environment slice for the delivery log's retention window. Validated at
|
|
36
|
+
* boot through `context.config`, so a malformed value stops the service with
|
|
37
|
+
* the module named rather than quietly pruning by the wrong window.
|
|
38
|
+
*
|
|
39
|
+
* Optional with a stated default, unlike most of the environment: absence is
|
|
40
|
+
* the normal state for an operator who does not care how long the log is, and
|
|
41
|
+
* the README's configuration table carries the default so it is not silent.
|
|
42
|
+
* Blank counts as absent, the `SECRET_ENCRYPTION_KEY_PREVIOUS` rule: operators
|
|
43
|
+
* empty a line far more often than they delete it.
|
|
44
|
+
*/
|
|
45
|
+
export const deliveryRetentionConfigSchema = z.object({
|
|
46
|
+
WEBHOOK_DELIVERY_RETENTION_DAYS: z
|
|
47
|
+
.string()
|
|
48
|
+
.optional()
|
|
49
|
+
.transform((value) => (value === undefined || value.trim().length === 0 ? undefined : value))
|
|
50
|
+
.refine((value) => value === undefined || (Number.isInteger(Number(value)) && Number(value) >= 1), { message: 'must be a whole number of days, at least 1' })
|
|
51
|
+
.transform((value) => value === undefined ? DEFAULT_DELIVERY_RETENTION_DAYS : Number(value)),
|
|
52
|
+
});
|
|
53
|
+
/** The moment a log row written before has outlived its retention. */
|
|
54
|
+
export function retentionCutoff(at, retentionDays) {
|
|
55
|
+
return new Date(at.getTime() - retentionDays * DAY_MS);
|
|
56
|
+
}
|
|
57
|
+
export function sleepFor(milliseconds) {
|
|
58
|
+
return new Promise((resolve) => {
|
|
59
|
+
setTimeout(resolve, milliseconds);
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* The real sender.
|
|
64
|
+
*
|
|
65
|
+
* Redirects are not followed. A customer whose endpoint moved should see the
|
|
66
|
+
* `301` and update the registration, rather than have Kelpie quietly post
|
|
67
|
+
* workspace data to whichever host the old one now points at.
|
|
68
|
+
*
|
|
69
|
+
* The catch is broad because this is the process boundary: `fetch` rejects with
|
|
70
|
+
* anything from a DNS failure to an abort, the set is open, and turning all of
|
|
71
|
+
* it into one outcome is the port's whole job. Nothing is swallowed — the
|
|
72
|
+
* reason reaches the log and the delivery is recorded as failed.
|
|
73
|
+
*/
|
|
74
|
+
export function createHttpSender(fetchImplementation = fetch) {
|
|
75
|
+
return async (request) => {
|
|
76
|
+
try {
|
|
77
|
+
const response = await fetchImplementation(request.url, {
|
|
78
|
+
method: 'POST',
|
|
79
|
+
body: request.body,
|
|
80
|
+
headers: request.headers,
|
|
81
|
+
redirect: 'manual',
|
|
82
|
+
signal: AbortSignal.timeout(DELIVERY_TIMEOUT_MS),
|
|
83
|
+
});
|
|
84
|
+
return response.ok
|
|
85
|
+
? { delivered: true, status: response.status, reason: null }
|
|
86
|
+
: {
|
|
87
|
+
delivered: false,
|
|
88
|
+
status: response.status,
|
|
89
|
+
reason: `endpoint answered ${String(response.status)}`,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
catch (error) {
|
|
93
|
+
return { delivered: false, status: null, reason: describeThrown(error) };
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
export function createDeliveryEngine(dependencies) {
|
|
98
|
+
/**
|
|
99
|
+
* Writes the outcome: one log row, the expired rows gone, and the webhook's
|
|
100
|
+
* status when it moved.
|
|
101
|
+
*
|
|
102
|
+
* One transaction, so a reader never sees a hook marked failing with no
|
|
103
|
+
* failure recorded against it.
|
|
104
|
+
*
|
|
105
|
+
* Retention is enforced here rather than by a schedule because there is no
|
|
106
|
+
* scheduler in the service, and the log only grows through this function —
|
|
107
|
+
* pruning on every append caps the table exactly where the growth happens.
|
|
108
|
+
* The cost is the documented residue: a hook that stops delivering keeps its
|
|
109
|
+
* last window of rows until the hook or the workspace is deleted.
|
|
110
|
+
*/
|
|
111
|
+
async function record(webhook, payload, delivery) {
|
|
112
|
+
const nextStatus = delivery.outcome.delivered ? 'active' : 'failing';
|
|
113
|
+
const pruned = await dependencies.transaction(async ({ tx }) => {
|
|
114
|
+
await repository.insertDelivery(tx, {
|
|
115
|
+
id: delivery.id,
|
|
116
|
+
workspaceId: webhook.workspaceId,
|
|
117
|
+
webhookId: webhook.id,
|
|
118
|
+
event: payload.event,
|
|
119
|
+
payload: delivery.body,
|
|
120
|
+
status: delivery.outcome.delivered ? 'success' : 'failed',
|
|
121
|
+
attempts: delivery.attempts,
|
|
122
|
+
// `created_at` is when the delivery was built, which is the `created_at`
|
|
123
|
+
// inside the payload too, so the log row and what the receiver holds
|
|
124
|
+
// agree. `delivered_at` is when it actually landed, up to the whole
|
|
125
|
+
// retry budget later.
|
|
126
|
+
deliveredAt: delivery.outcome.delivered ? dependencies.now() : null,
|
|
127
|
+
createdAt: delivery.sentAt,
|
|
128
|
+
});
|
|
129
|
+
// The cutoff is later than the row above's `created_at` for any positive
|
|
130
|
+
// window, so a prune can never take the delivery it arrived with, and
|
|
131
|
+
// `last_delivery_*` always has a row to read.
|
|
132
|
+
const expired = await repository.deleteExpiredDeliveries(tx, webhook.id, retentionCutoff(dependencies.now(), dependencies.retentionDays));
|
|
133
|
+
// A paused webhook is never selected for delivery, so the only statuses
|
|
134
|
+
// reachable here are the two the engine owns. Leaving an unchanged one
|
|
135
|
+
// alone keeps a healthy endpoint from being rewritten on every event.
|
|
136
|
+
if (webhook.status !== nextStatus) {
|
|
137
|
+
await repository.setWebhookStatus(tx, webhook.id, nextStatus);
|
|
138
|
+
}
|
|
139
|
+
return expired;
|
|
140
|
+
});
|
|
141
|
+
// After the transaction settles: a rollback would make this line a lie.
|
|
142
|
+
if (pruned > 0) {
|
|
143
|
+
dependencies.log.debug('pruned expired webhook deliveries', {
|
|
144
|
+
webhookId: webhook.id,
|
|
145
|
+
pruned,
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
async function attemptUntilDelivered(request) {
|
|
150
|
+
let attempts = 0;
|
|
151
|
+
for (;;) {
|
|
152
|
+
attempts += 1;
|
|
153
|
+
const outcome = await dependencies.send(request);
|
|
154
|
+
if (outcome.delivered) {
|
|
155
|
+
return { attempts, outcome };
|
|
156
|
+
}
|
|
157
|
+
const delay = retryDelayAfter(attempts);
|
|
158
|
+
if (delay === undefined) {
|
|
159
|
+
return { attempts, outcome };
|
|
160
|
+
}
|
|
161
|
+
await dependencies.sleep(delay);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Every secret this delivery should be signed under, newest first.
|
|
166
|
+
*
|
|
167
|
+
* A secret that will not decrypt throws, and the caller logs it against this
|
|
168
|
+
* webhook. Deliberately not recorded as a failed delivery: the endpoint did
|
|
169
|
+
* nothing wrong, Kelpie's key did, and marking the registration `failing`
|
|
170
|
+
* would send the customer debugging their own server while the real fault is
|
|
171
|
+
* `SECRET_ENCRYPTION_KEY`.
|
|
172
|
+
*
|
|
173
|
+
* The expiry is read here rather than swept by a job. There is no scheduler in
|
|
174
|
+
* the service, and an overlap that has run out simply stops being signed with;
|
|
175
|
+
* the column is cleared by the next rotation or by deleting the registration.
|
|
176
|
+
*/
|
|
177
|
+
function signaturesFor(webhook, text, at) {
|
|
178
|
+
const signatures = [signDeliveryBody(dependencies.cipher.open(webhook.secretEncrypted), text)];
|
|
179
|
+
const expiresAt = webhook.previousSecretExpiresAt;
|
|
180
|
+
if (webhook.previousSecretEncrypted !== null && expiresAt !== null && expiresAt > at) {
|
|
181
|
+
signatures.push(signDeliveryBody(dependencies.cipher.open(webhook.previousSecretEncrypted), text));
|
|
182
|
+
}
|
|
183
|
+
return signatures;
|
|
184
|
+
}
|
|
185
|
+
async function deliverTo(webhook, payload) {
|
|
186
|
+
const deliveryId = dependencies.createId('webhookDelivery');
|
|
187
|
+
const envelope = {
|
|
188
|
+
deliveryId,
|
|
189
|
+
event: payload.event,
|
|
190
|
+
sentAt: dependencies.now(),
|
|
191
|
+
workspaceId: payload.workspaceId,
|
|
192
|
+
data: payload.data,
|
|
193
|
+
};
|
|
194
|
+
const body = deliveryBody(envelope);
|
|
195
|
+
const text = renderDeliveryBody(body);
|
|
196
|
+
const { attempts, outcome } = await attemptUntilDelivered({
|
|
197
|
+
url: webhook.url,
|
|
198
|
+
body: text,
|
|
199
|
+
headers: deliveryHeaders(envelope, signaturesFor(webhook, text, envelope.sentAt)),
|
|
200
|
+
});
|
|
201
|
+
if (!outcome.delivered) {
|
|
202
|
+
dependencies.log.warn('webhook delivery failed', {
|
|
203
|
+
webhookId: webhook.id,
|
|
204
|
+
deliveryId,
|
|
205
|
+
event: payload.event,
|
|
206
|
+
attempts,
|
|
207
|
+
status: outcome.status,
|
|
208
|
+
reason: outcome.reason,
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
// The body is stored as it was sent, so the log answers "what did they
|
|
212
|
+
// actually receive" rather than "what would we build for this event today".
|
|
213
|
+
await record(webhook, payload, { id: deliveryId, sentAt: envelope.sentAt, body, attempts, outcome });
|
|
214
|
+
}
|
|
215
|
+
return {
|
|
216
|
+
async deliver(payload) {
|
|
217
|
+
const subscribed = await repository.listSubscribed(dependencies.db, payload.workspaceId, payload.event);
|
|
218
|
+
if (subscribed.length === 0) {
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
// One unreachable endpoint, or one row whose secret will not decrypt,
|
|
222
|
+
// must not stop the others. Same reason the bus settles its handlers
|
|
223
|
+
// rather than racing them.
|
|
224
|
+
const outcomes = await Promise.allSettled(subscribed.map((webhook) => deliverTo(webhook, payload)));
|
|
225
|
+
for (const [index, outcome] of outcomes.entries()) {
|
|
226
|
+
if (outcome.status === 'rejected') {
|
|
227
|
+
dependencies.log.error('webhook delivery could not be attempted', {
|
|
228
|
+
webhookId: subscribed[index]?.id,
|
|
229
|
+
event: payload.event,
|
|
230
|
+
error: describeThrown(outcome.reason),
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
},
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
//# sourceMappingURL=delivery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delivery.js","sourceRoot":"","sources":["../../../src/modules/webhooks/delivery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAGvB,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAMpD,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAA;AAE7C,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAGlG;;;;;;;;;;;;GAYG;AAEH,gEAAgE;AAChE,MAAM,CAAC,MAAM,mBAAmB,GAAG,MAAM,CAAA;AAEzC,yEAAyE;AACzE,MAAM,CAAC,MAAM,eAAe,GAAsB,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC,CAAA;AAExE,MAAM,CAAC,MAAM,qBAAqB,GAAG,eAAe,CAAC,MAAM,GAAG,CAAC,CAAA;AAE/D;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,QAAgB;IAC9C,OAAO,eAAe,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAA;AACtC,CAAC;AAED,MAAM,MAAM,GAAG,UAAU,CAAA;AAEzB,6DAA6D;AAC7D,MAAM,CAAC,MAAM,+BAA+B,GAAG,EAAE,CAAA;AAEjD;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAAC,CAAC,MAAM,CAAC;IACpD,+BAA+B,EAAE,CAAC;SAC/B,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,SAAS,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,KAAK,SAAS,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,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KAAK,UAAU,EAAE,CAAC;oBAClC,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC,yCAAyC,EAAE;wBAChE,SAAS,EAAE,UAAU,CAAC,KAAK,CAAC,EAAE,EAAE;wBAChC,KAAK,EAAE,OAAO,CAAC,KAAK;wBACpB,KAAK,EAAE,cAAc,CAAC,OAAO,CAAC,MAAM,CAAC;qBACtC,CAAC,CAAA;gBACJ,CAAC;YACH,CAAC;QACH,CAAC;KACF,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { KelpieModule } from '../../runtime/module.ts';
|
|
2
|
+
import type { SendDelivery, Sleep } from './delivery.ts';
|
|
3
|
+
/**
|
|
4
|
+
* Webhooks: registration, and the engine that bridges the internal event bus to
|
|
5
|
+
* outbound HTTP.
|
|
6
|
+
*
|
|
7
|
+
* `requires` is `workspace` alone. The engine consumes events by name and never
|
|
8
|
+
* reads the tables behind them, so it does not depend on the modules that emit
|
|
9
|
+
* them — a payload carries the record's type and id and nothing else, which is
|
|
10
|
+
* what keeps this module from growing a dependency on every CRM module in turn.
|
|
11
|
+
*
|
|
12
|
+
* Subscription happens during `register`, and `architecture.md` fixes this
|
|
13
|
+
* module near the end of the core order, so every emitting module is already in
|
|
14
|
+
* place. Nothing depends on that: the bus resolves handlers at publication.
|
|
15
|
+
*/
|
|
16
|
+
export interface WebhooksModuleOptions {
|
|
17
|
+
/** Injected by tests so no suite makes a network call. */
|
|
18
|
+
readonly send?: SendDelivery;
|
|
19
|
+
/** Injected by tests so no suite spends the retry budget in real time. */
|
|
20
|
+
readonly sleep?: Sleep;
|
|
21
|
+
}
|
|
22
|
+
export declare function createWebhooksModule(migrationsDirectory: string, options?: WebhooksModuleOptions): KelpieModule;
|
|
23
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/modules/webhooks/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAO3D,OAAO,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AAOxD;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,qBAAqB;IACpC,0DAA0D;IAC1D,QAAQ,CAAC,IAAI,CAAC,EAAE,YAAY,CAAA;IAC5B,0EAA0E;IAC1E,QAAQ,CAAC,KAAK,CAAC,EAAE,KAAK,CAAA;CACvB;AAED,wBAAgB,oBAAoB,CAClC,mBAAmB,EAAE,MAAM,EAC3B,OAAO,GAAE,qBAA0B,GAClC,YAAY,CA8Cd"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { createSecretCipher, secretEncryptionConfigSchema } from '../../lib/secrets.js';
|
|
2
|
+
import { createDeliveryEngine, createHttpSender, deliveryRetentionConfigSchema, sleepFor, } from './delivery.js';
|
|
3
|
+
import { subscribeDeliverableEvents } from './payloads.js';
|
|
4
|
+
import { mountWebhooksRoutes } from './routes.js';
|
|
5
|
+
import * as schema from './schema.js';
|
|
6
|
+
import { createWebhooksService } from './service.js';
|
|
7
|
+
import { registerWebhooksTools } from './tools.js';
|
|
8
|
+
export function createWebhooksModule(migrationsDirectory, options = {}) {
|
|
9
|
+
return {
|
|
10
|
+
id: 'webhooks',
|
|
11
|
+
requires: ['workspace'],
|
|
12
|
+
register(context) {
|
|
13
|
+
// Validated at boot rather than on the first delivery: a missing or
|
|
14
|
+
// malformed key means no webhook can ever be signed, and finding that out
|
|
15
|
+
// when a customer's endpoint goes quiet is far too late. The retention
|
|
16
|
+
// window is validated the same way for the same reason — a bad value
|
|
17
|
+
// should stop boot, not prune by the wrong window.
|
|
18
|
+
const cipher = createSecretCipher(context.config(secretEncryptionConfigSchema));
|
|
19
|
+
const retention = context.config(deliveryRetentionConfigSchema);
|
|
20
|
+
const service = createWebhooksService({
|
|
21
|
+
db: context.db,
|
|
22
|
+
transaction: context.transaction,
|
|
23
|
+
createId: context.createId,
|
|
24
|
+
now: context.now,
|
|
25
|
+
cipher,
|
|
26
|
+
});
|
|
27
|
+
const engine = createDeliveryEngine({
|
|
28
|
+
db: context.db,
|
|
29
|
+
transaction: context.transaction,
|
|
30
|
+
createId: context.createId,
|
|
31
|
+
now: context.now,
|
|
32
|
+
cipher,
|
|
33
|
+
send: options.send ?? createHttpSender(),
|
|
34
|
+
sleep: options.sleep ?? sleepFor,
|
|
35
|
+
retentionDays: retention.WEBHOOK_DELIVERY_RETENTION_DAYS,
|
|
36
|
+
log: context.log,
|
|
37
|
+
});
|
|
38
|
+
context.schema(schema, migrationsDirectory);
|
|
39
|
+
subscribeDeliverableEvents(context.events, (payload) => engine.deliver(payload));
|
|
40
|
+
context.routes((router) => {
|
|
41
|
+
mountWebhooksRoutes(router, { db: context.db, now: context.now, service });
|
|
42
|
+
});
|
|
43
|
+
registerWebhooksTools(context.mcp, service);
|
|
44
|
+
return Promise.resolve();
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/modules/webhooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,4BAA4B,EAAE,MAAM,sBAAsB,CAAA;AAEvF,OAAO,EACL,oBAAoB,EACpB,gBAAgB,EAChB,6BAA6B,EAC7B,QAAQ,GACT,MAAM,eAAe,CAAA;AAEtB,OAAO,EAAE,0BAA0B,EAAE,MAAM,eAAe,CAAA;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AACjD,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AACrC,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAA;AACpD,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAA;AAsBlD,MAAM,UAAU,oBAAoB,CAClC,mBAA2B,EAC3B,OAAO,G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MAAM,EAAE,EAAE,EAAE,EAAE,OAAO,CAAC,EAAE,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,OAAO,EAAE,CAAC,CAAA;YAC5E,CAAC,CAAC,CAAA;YAEF,qBAAqB,CAAC,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,CAAA;YAE3C,OAAO,OAAO,CAAC,OAAO,EAAE,CAAA;QAC1B,CAAC;KACF,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { WebhookEvent } from '@kelpie/schemas';
|
|
2
|
+
import type { EventBus } from '../../runtime/events.ts';
|
|
3
|
+
/**
|
|
4
|
+
* The bridge from the internal event catalog to what a webhook receiver sees.
|
|
5
|
+
*
|
|
6
|
+
* `modules.md` makes the webhooks engine a consumer of the bus, so this is the
|
|
7
|
+
* only place that knows both vocabularies. Everything downstream works with a
|
|
8
|
+
* `WebhookEventPayload` and never sees a `DomainEvents` key.
|
|
9
|
+
*
|
|
10
|
+
* Payload keys are `snake_case`, matching `api.md`, because a receiver has no
|
|
11
|
+
* reason to expect a different convention from a webhook than from the REST
|
|
12
|
+
* surface it also calls.
|
|
13
|
+
*/
|
|
14
|
+
export type { WebhookEvent };
|
|
15
|
+
/** One event, resolved to the workspace it belongs to and the body to send. */
|
|
16
|
+
export interface WebhookEventPayload {
|
|
17
|
+
readonly workspaceId: string;
|
|
18
|
+
readonly event: WebhookEvent;
|
|
19
|
+
/** The `data` object of the delivery body. */
|
|
20
|
+
readonly data: Record<string, unknown>;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Subscribes the engine to every deliverable event.
|
|
24
|
+
*
|
|
25
|
+
* Written out one call at a time rather than looped over `WEBHOOK_EVENTS`,
|
|
26
|
+
* because TypeScript cannot correlate a payload type with a generic key: a loop
|
|
27
|
+
* would need a cast, and the cast is exactly what would let a wrong payload
|
|
28
|
+
* through. A literal key indexes `builders` at its precise signature.
|
|
29
|
+
*/
|
|
30
|
+
export declare function subscribeDeliverableEvents(bus: EventBus, deliver: (payload: WebhookEventPayload) => Promise<void>): void;
|
|
31
|
+
//# sourceMappingURL=payloads.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payloads.d.ts","sourceRoot":"","sources":["../../../src/modules/webhooks/payloads.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAEnD,OAAO,KAAK,EAAgB,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AAErE;;;;;;;;;;GAUG;AAEH,YAAY,EAAE,YAAY,EAAE,CAAA;AAE5B,+EAA+E;AAC/E,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAC5B,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAA;IAC5B,8CAA8C;IAC9C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CACvC;AA2CD;;;;;;;GAOG;AACH,wBAAgB,0BAA0B,CACxC,GAAG,EAAE,QAAQ,EACb,OAAO,EAAE,CAAC,OAAO,EAAE,mBAAmB,KAAK,OAAO,CAAC,IAAI,CAAC,GACvD,IAAI,CAKN"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Payload builders, one per deliverable event.
|
|
3
|
+
*
|
|
4
|
+
* `satisfies` is what keeps this honest: adding a name to `WEBHOOK_EVENTS`
|
|
5
|
+
* without a builder here is a compile error rather than an event that resolves
|
|
6
|
+
* to nothing at runtime.
|
|
7
|
+
*/
|
|
8
|
+
const builders = {
|
|
9
|
+
'record.created': (payload) => ({
|
|
10
|
+
workspaceId: payload.workspaceId,
|
|
11
|
+
event: 'record.created',
|
|
12
|
+
data: { object_type: payload.objectType, record_id: payload.recordId },
|
|
13
|
+
}),
|
|
14
|
+
'record.updated': (payload) => ({
|
|
15
|
+
workspaceId: payload.workspaceId,
|
|
16
|
+
event: 'record.updated',
|
|
17
|
+
data: {
|
|
18
|
+
object_type: payload.objectType,
|
|
19
|
+
record_id: payload.recordId,
|
|
20
|
+
// The values stay as the emitting service named them, which is camelCase
|
|
21
|
+
// (`parentId`, `sortOrder`) even though the keys around them are not.
|
|
22
|
+
// Translating them to the wire spelling would mean a second copy of every
|
|
23
|
+
// module's column naming, kept in step by hand.
|
|
24
|
+
changed_fields: [...payload.changedFields],
|
|
25
|
+
},
|
|
26
|
+
}),
|
|
27
|
+
'record.deleted': (payload) => ({
|
|
28
|
+
workspaceId: payload.workspaceId,
|
|
29
|
+
event: 'record.deleted',
|
|
30
|
+
data: { object_type: payload.objectType, record_id: payload.recordId },
|
|
31
|
+
}),
|
|
32
|
+
'form.submitted': (payload) => ({
|
|
33
|
+
workspaceId: payload.workspaceId,
|
|
34
|
+
event: 'form.submitted',
|
|
35
|
+
data: { form_id: payload.formId, submission_id: payload.submissionId },
|
|
36
|
+
}),
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Subscribes the engine to every deliverable event.
|
|
40
|
+
*
|
|
41
|
+
* Written out one call at a time rather than looped over `WEBHOOK_EVENTS`,
|
|
42
|
+
* because TypeScript cannot correlate a payload type with a generic key: a loop
|
|
43
|
+
* would need a cast, and the cast is exactly what would let a wrong payload
|
|
44
|
+
* through. A literal key indexes `builders` at its precise signature.
|
|
45
|
+
*/
|
|
46
|
+
export function subscribeDeliverableEvents(bus, deliver) {
|
|
47
|
+
bus.subscribe('record.created', (payload) => deliver(builders['record.created'](payload)));
|
|
48
|
+
bus.subscribe('record.updated', (payload) => deliver(builders['record.updated'](payload)));
|
|
49
|
+
bus.subscribe('record.deleted', (payload) => deliver(builders['record.deleted'](payload)));
|
|
50
|
+
bus.subscribe('form.submitted', (payload) => deliver(builders['form.submitted'](payload)));
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=payloads.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payloads.js","s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,SAAS,CAAC,gBAAgB,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAA;IAC1F,GAAG,CAAC,SAAS,CAAC,gBAAgB,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAA;IAC1F,GAAG,CAAC,SAAS,CAAC,gBAAgB,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAA;IAC1F,GAAG,CAAC,SAAS,CAAC,gBAAgB,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAA;AAC5F,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { WebhookDeliveryStatus, WebhookEvent, WebhookStatus } from '@kelpie/schemas';
|
|
2
|
+
import type { ListWindow, SortableFields } from '../../lib/pagination.ts';
|
|
3
|
+
import type { Queryable } from '../../runtime/transaction.ts';
|
|
4
|
+
import { webhookDeliveries, webhooks } from './schema.ts';
|
|
5
|
+
export type WebhookRecord = typeof webhooks.$inferSelect;
|
|
6
|
+
export type WebhookColumns = typeof webhooks.$inferInsert;
|
|
7
|
+
export type DeliveryRecord = typeof webhookDeliveries.$inferSelect;
|
|
8
|
+
export type DeliveryColumns = typeof webhookDeliveries.$inferInsert;
|
|
9
|
+
export declare const WEBHOOK_SORTS: SortableFields<WebhookRecord>;
|
|
10
|
+
export declare const DEFAULT_WEBHOOK_SORT = "-created_at";
|
|
11
|
+
export declare const DELIVERY_SORTS: SortableFields<DeliveryRecord>;
|
|
12
|
+
/** Newest first: a delivery log is read to find out what just happened. */
|
|
13
|
+
export declare const DEFAULT_DELIVERY_SORT = "-created_at";
|
|
14
|
+
export interface WebhookFilters {
|
|
15
|
+
readonly status?: WebhookStatus | undefined;
|
|
16
|
+
}
|
|
17
|
+
export interface DeliveryFilters {
|
|
18
|
+
readonly status?: WebhookDeliveryStatus | undefined;
|
|
19
|
+
}
|
|
20
|
+
/** The last settled delivery for one webhook, as the list view reports it. */
|
|
21
|
+
export interface LastDelivery {
|
|
22
|
+
readonly at: Date;
|
|
23
|
+
readonly status: WebhookDeliveryStatus;
|
|
24
|
+
}
|
|
25
|
+
export declare function listWebhooks(db: Queryable, workspaceId: string, filters: WebhookFilters, window: ListWindow<WebhookRecord>): Promise<WebhookRecord[]>;
|
|
26
|
+
export declare function findWebhook(db: Queryable, workspaceId: string, id: string): Promise<WebhookRecord | undefined>;
|
|
27
|
+
/**
|
|
28
|
+
* The registrations one event should reach.
|
|
29
|
+
*
|
|
30
|
+
* `paused` is excluded and `failing` is not: pausing is the customer saying
|
|
31
|
+
* stop, while failing is a report on the endpoint. A failing webhook keeps
|
|
32
|
+
* being tried, which is the only way it can return to `active` by itself.
|
|
33
|
+
*/
|
|
34
|
+
export declare function listSubscribed(db: Queryable, workspaceId: string, event: WebhookEvent): Promise<WebhookRecord[]>;
|
|
35
|
+
/**
|
|
36
|
+
* The most recent settled delivery per webhook, for the `last_delivery_*` fields.
|
|
37
|
+
*
|
|
38
|
+
* Derived rather than stored. `schema.md` gives `webhooks` no delivery columns,
|
|
39
|
+
* and a denormalised copy of the log's newest row is a second source of truth
|
|
40
|
+
* that can only ever drift from it.
|
|
41
|
+
*
|
|
42
|
+
* @param webhookIds At most one page of ids, so the `in` list is bounded by the
|
|
43
|
+
* same ceiling `?limit=` is.
|
|
44
|
+
*/
|
|
45
|
+
export declare function findLastDeliveries(db: Queryable, webhookIds: readonly string[]): Promise<ReadonlyMap<string, LastDelivery>>;
|
|
46
|
+
export declare function insertWebhook(db: Queryable, values: WebhookColumns): Promise<WebhookRecord>;
|
|
47
|
+
export declare function updateWebhook(db: Queryable, workspaceId: string, id: string, changes: Partial<WebhookColumns>): Promise<WebhookRecord | undefined>;
|
|
48
|
+
/**
|
|
49
|
+
* Moves a webhook between `active` and `failing` after a delivery settles.
|
|
50
|
+
*
|
|
51
|
+
* Deliberately does not touch `updated_at`. That column answers "when did
|
|
52
|
+
* somebody last change this registration", and a customer compares it against
|
|
53
|
+
* `last_delivery_at` to see whether their fix took effect. The engine moving it
|
|
54
|
+
* would destroy that comparison.
|
|
55
|
+
*/
|
|
56
|
+
export declare function setWebhookStatus(db: Queryable, id: string, status: WebhookStatus): Promise<void>;
|
|
57
|
+
export declare function deleteWebhook(db: Queryable, workspaceId: string, id: string): Promise<number>;
|
|
58
|
+
export declare function insertDelivery(db: Queryable, values: DeliveryColumns): Promise<DeliveryRecord>;
|
|
59
|
+
/**
|
|
60
|
+
* Deletes this webhook's log rows older than the cutoff.
|
|
61
|
+
*
|
|
62
|
+
* Scoped to one webhook rather than the workspace so the delete walks
|
|
63
|
+
* `webhook_deliveries_webhook_idx` — the workspace column has no index here,
|
|
64
|
+
* and the engine calls this on every recorded delivery.
|
|
65
|
+
*
|
|
66
|
+
* @returns How many rows went, for the engine's log line.
|
|
67
|
+
*/
|
|
68
|
+
export declare function deleteExpiredDeliveries(db: Queryable, webhookId: string, before: Date): Promise<number>;
|
|
69
|
+
export declare function listDeliveries(db: Queryable, workspaceId: string, webhookId: string, filters: DeliveryFilters, window: ListWindow<DeliveryRecord>): Promise<DeliveryRecord[]>;
|
|
70
|
+
//# sourceMappingURL=repository.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"repository.d.ts","sourceRoot":"","sources":["../../../src/modules/webhooks/repository.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAKzF,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AACzE,OAAO,KAA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xB,MAAM,EAAE,UAAU,CAAC,cAAc,CAAC,GACjC,OAAO,CAAC,cAAc,EAAE,CAAC,CAc3B"}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { and, arrayContains, desc, eq, inArray, lt, ne } from 'drizzle-orm';
|
|
2
|
+
import { keysetCondition, orderByWindow, timestampSort } from '../../lib/pagination.js';
|
|
3
|
+
import { webhookDeliveries, webhooks } from './schema.js';
|
|
4
|
+
export const WEBHOOK_SORTS = {
|
|
5
|
+
created_at: timestampSort(webhooks.createdAt, (webhook) => webhook.createdAt),
|
|
6
|
+
updated_at: timestampSort(webhooks.updatedAt, (webhook) => webhook.updatedAt),
|
|
7
|
+
};
|
|
8
|
+
export const DEFAULT_WEBHOOK_SORT = '-created_at';
|
|
9
|
+
export const DELIVERY_SORTS = {
|
|
10
|
+
created_at: timestampSort(webhookDeliveries.createdAt, (delivery) => delivery.createdAt),
|
|
11
|
+
};
|
|
12
|
+
/** Newest first: a delivery log is read to find out what just happened. */
|
|
13
|
+
export const DEFAULT_DELIVERY_SORT = '-created_at';
|
|
14
|
+
function conditionsFor(workspaceId, filters) {
|
|
15
|
+
return [
|
|
16
|
+
eq(webhooks.workspaceId, workspaceId),
|
|
17
|
+
filters.status === undefined ? undefined : eq(webhooks.status, filters.status),
|
|
18
|
+
];
|
|
19
|
+
}
|
|
20
|
+
export function listWebhooks(db, workspaceId, filters, window) {
|
|
21
|
+
return db
|
|
22
|
+
.select()
|
|
23
|
+
.from(webhooks)
|
|
24
|
+
.where(and(...conditionsFor(workspaceId, filters), keysetCondition(window, webhooks.id)))
|
|
25
|
+
.orderBy(...orderByWindow(window, webhooks.id))
|
|
26
|
+
.limit(window.fetchLimit);
|
|
27
|
+
}
|
|
28
|
+
export async function findWebhook(db, workspaceId, id) {
|
|
29
|
+
const [found] = await db
|
|
30
|
+
.select()
|
|
31
|
+
.from(webhooks)
|
|
32
|
+
.where(and(eq(webhooks.workspaceId, workspaceId), eq(webhooks.id, id)))
|
|
33
|
+
.limit(1);
|
|
34
|
+
return found;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* The registrations one event should reach.
|
|
38
|
+
*
|
|
39
|
+
* `paused` is excluded and `failing` is not: pausing is the customer saying
|
|
40
|
+
* stop, while failing is a report on the endpoint. A failing webhook keeps
|
|
41
|
+
* being tried, which is the only way it can return to `active` by itself.
|
|
42
|
+
*/
|
|
43
|
+
export function listSubscribed(db, workspaceId, event) {
|
|
44
|
+
return db
|
|
45
|
+
.select()
|
|
46
|
+
.from(webhooks)
|
|
47
|
+
.where(and(eq(webhooks.workspaceId, workspaceId), ne(webhooks.status, 'paused'), arrayContains(webhooks.events, [event])));
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* The most recent settled delivery per webhook, for the `last_delivery_*` fields.
|
|
51
|
+
*
|
|
52
|
+
* Derived rather than stored. `schema.md` gives `webhooks` no delivery columns,
|
|
53
|
+
* and a denormalised copy of the log's newest row is a second source of truth
|
|
54
|
+
* that can only ever drift from it.
|
|
55
|
+
*
|
|
56
|
+
* @param webhookIds At most one page of ids, so the `in` list is bounded by the
|
|
57
|
+
* same ceiling `?limit=` is.
|
|
58
|
+
*/
|
|
59
|
+
export async function findLastDeliveries(db, webhookIds) {
|
|
60
|
+
if (webhookIds.length === 0) {
|
|
61
|
+
return new Map();
|
|
62
|
+
}
|
|
63
|
+
const rows = await db
|
|
64
|
+
.selectDistinctOn([webhookDeliveries.webhookId], {
|
|
65
|
+
webhookId: webhookDeliveries.webhookId,
|
|
66
|
+
createdAt: webhookDeliveries.createdAt,
|
|
67
|
+
status: webhookDeliveries.status,
|
|
68
|
+
})
|
|
69
|
+
.from(webhookDeliveries)
|
|
70
|
+
.where(inArray(webhookDeliveries.webhookId, [...webhookIds]))
|
|
71
|
+
// The id breaks a tie: several deliveries of one event land in the same
|
|
72
|
+
// millisecond, and ULIDs order by creation within one.
|
|
73
|
+
.orderBy(webhookDeliveries.webhookId, desc(webhookDeliveries.createdAt), desc(webhookDeliveries.id));
|
|
74
|
+
return new Map(rows.map((row) => [row.webhookId, { at: row.createdAt, status: row.status }]));
|
|
75
|
+
}
|
|
76
|
+
export async function insertWebhook(db, values) {
|
|
77
|
+
const [created] = await db.insert(webhooks).values(values).returning();
|
|
78
|
+
if (created === undefined) {
|
|
79
|
+
throw new Error(`Inserting webhook ${values.id} returned no row`);
|
|
80
|
+
}
|
|
81
|
+
return created;
|
|
82
|
+
}
|
|
83
|
+
export async function updateWebhook(db, workspaceId, id, changes) {
|
|
84
|
+
const [updated] = await db
|
|
85
|
+
.update(webhooks)
|
|
86
|
+
.set(changes)
|
|
87
|
+
.where(and(eq(webhooks.workspaceId, workspaceId), eq(webhooks.id, id)))
|
|
88
|
+
.returning();
|
|
89
|
+
return updated;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Moves a webhook between `active` and `failing` after a delivery settles.
|
|
93
|
+
*
|
|
94
|
+
* Deliberately does not touch `updated_at`. That column answers "when did
|
|
95
|
+
* somebody last change this registration", and a customer compares it against
|
|
96
|
+
* `last_delivery_at` to see whether their fix took effect. The engine moving it
|
|
97
|
+
* would destroy that comparison.
|
|
98
|
+
*/
|
|
99
|
+
export async function setWebhookStatus(db, id, status) {
|
|
100
|
+
await db.update(webhooks).set({ status }).where(eq(webhooks.id, id));
|
|
101
|
+
}
|
|
102
|
+
export async function deleteWebhook(db, workspaceId, id) {
|
|
103
|
+
const deleted = await db
|
|
104
|
+
.delete(webhooks)
|
|
105
|
+
.where(and(eq(webhooks.workspaceId, workspaceId), eq(webhooks.id, id)))
|
|
106
|
+
.returning({ id: webhooks.id });
|
|
107
|
+
return deleted.length;
|
|
108
|
+
}
|
|
109
|
+
export async function insertDelivery(db, values) {
|
|
110
|
+
const [created] = await db.insert(webhookDeliveries).values(values).returning();
|
|
111
|
+
if (created === undefined) {
|
|
112
|
+
throw new Error(`Inserting webhook delivery ${values.id} returned no row`);
|
|
113
|
+
}
|
|
114
|
+
return created;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Deletes this webhook's log rows older than the cutoff.
|
|
118
|
+
*
|
|
119
|
+
* Scoped to one webhook rather than the workspace so the delete walks
|
|
120
|
+
* `webhook_deliveries_webhook_idx` — the workspace column has no index here,
|
|
121
|
+
* and the engine calls this on every recorded delivery.
|
|
122
|
+
*
|
|
123
|
+
* @returns How many rows went, for the engine's log line.
|
|
124
|
+
*/
|
|
125
|
+
export async function deleteExpiredDeliveries(db, webhookId, before) {
|
|
126
|
+
const deleted = await db
|
|
127
|
+
.delete(webhookDeliveries)
|
|
128
|
+
.where(and(eq(webhookDeliveries.webhookId, webhookId), lt(webhookDeliveries.createdAt, before)))
|
|
129
|
+
.returning({ id: webhookDeliveries.id });
|
|
130
|
+
return deleted.length;
|
|
131
|
+
}
|
|
132
|
+
export function listDeliveries(db, workspaceId, webhookId, filters, window) {
|
|
133
|
+
return db
|
|
134
|
+
.select()
|
|
135
|
+
.from(webhookDeliveries)
|
|
136
|
+
.where(and(eq(webhookDeliveries.workspaceId, workspaceId), eq(webhookDeliveries.webhookId, webhookId), filters.status === undefined ? undefined : eq(webhookDeliveries.status, filters.status), keysetCondition(window, webhookDeliveries.id)))
|
|
137
|
+
.orderBy(...orderByWindow(window, webhookDeliveries.id))
|
|
138
|
+
.limit(window.fetchLimit);
|
|
139
|
+
}
|
|
140
|
+
//# sourceMappingURL=repository.js.map
|