@sixb/core 0.0.1
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 +21 -0
- package/README.md +470 -0
- package/dist/actions/builders/define-action.d.ts +7 -0
- package/dist/actions/builders/define-action.d.ts.map +1 -0
- package/dist/actions/builders/params.d.ts +23 -0
- package/dist/actions/builders/params.d.ts.map +1 -0
- package/dist/actions/builders.d.ts +3 -0
- package/dist/actions/builders.d.ts.map +1 -0
- package/dist/actions/commit-edits.d.ts +54 -0
- package/dist/actions/commit-edits.d.ts.map +1 -0
- package/dist/actions/errors.d.ts +9 -0
- package/dist/actions/errors.d.ts.map +1 -0
- package/dist/actions/index.d.ts +14 -0
- package/dist/actions/index.d.ts.map +1 -0
- package/dist/actions/index.js +73 -0
- package/dist/actions/index.js.map +9 -0
- package/dist/actions/read-facade.d.ts +56 -0
- package/dist/actions/read-facade.d.ts.map +1 -0
- package/dist/actions/registry.d.ts +17 -0
- package/dist/actions/registry.d.ts.map +1 -0
- package/dist/actions/request.d.ts +37 -0
- package/dist/actions/request.d.ts.map +1 -0
- package/dist/actions/run-id.d.ts +3 -0
- package/dist/actions/run-id.d.ts.map +1 -0
- package/dist/actions/runtime.d.ts +11 -0
- package/dist/actions/runtime.d.ts.map +1 -0
- package/dist/actions/types/context.d.ts +147 -0
- package/dist/actions/types/context.d.ts.map +1 -0
- package/dist/actions/types/definitions.d.ts +67 -0
- package/dist/actions/types/definitions.d.ts.map +1 -0
- package/dist/actions/types/handlers.d.ts +19 -0
- package/dist/actions/types/handlers.d.ts.map +1 -0
- package/dist/actions/types/params.d.ts +45 -0
- package/dist/actions/types/params.d.ts.map +1 -0
- package/dist/actions/types.d.ts +5 -0
- package/dist/actions/types.d.ts.map +1 -0
- package/dist/actions/validation.d.ts +33 -0
- package/dist/actions/validation.d.ts.map +1 -0
- package/dist/actions/validators.d.ts +8 -0
- package/dist/actions/validators.d.ts.map +1 -0
- package/dist/actions/worker.d.ts +3 -0
- package/dist/actions/worker.d.ts.map +1 -0
- package/dist/actions/worker.js +324 -0
- package/dist/actions/worker.js.map +11 -0
- package/dist/agents/adapters.d.ts +185 -0
- package/dist/agents/adapters.d.ts.map +1 -0
- package/dist/agents/api-gateway.d.ts +21 -0
- package/dist/agents/api-gateway.d.ts.map +1 -0
- package/dist/agents/builders.d.ts +10 -0
- package/dist/agents/builders.d.ts.map +1 -0
- package/dist/agents/context-model.d.ts +4 -0
- package/dist/agents/context-model.d.ts.map +1 -0
- package/dist/agents/context-resolution.d.ts +5 -0
- package/dist/agents/context-resolution.d.ts.map +1 -0
- package/dist/agents/context.d.ts +57 -0
- package/dist/agents/context.d.ts.map +1 -0
- package/dist/agents/context.js +23 -0
- package/dist/agents/context.js.map +9 -0
- package/dist/agents/dispatch.d.ts +36 -0
- package/dist/agents/dispatch.d.ts.map +1 -0
- package/dist/agents/errors.d.ts +27 -0
- package/dist/agents/errors.d.ts.map +1 -0
- package/dist/agents/ids.d.ts +11 -0
- package/dist/agents/ids.d.ts.map +1 -0
- package/dist/agents/index.d.ts +24 -0
- package/dist/agents/index.d.ts.map +1 -0
- package/dist/agents/index.js +121 -0
- package/dist/agents/index.js.map +9 -0
- package/dist/agents/message.d.ts +78 -0
- package/dist/agents/message.d.ts.map +1 -0
- package/dist/agents/prompt.d.ts +15 -0
- package/dist/agents/prompt.d.ts.map +1 -0
- package/dist/agents/request.d.ts +42 -0
- package/dist/agents/request.d.ts.map +1 -0
- package/dist/agents/runtime.d.ts +41 -0
- package/dist/agents/runtime.d.ts.map +1 -0
- package/dist/agents/streams.d.ts +72 -0
- package/dist/agents/streams.d.ts.map +1 -0
- package/dist/agents/streams.js +32 -0
- package/dist/agents/streams.js.map +9 -0
- package/dist/agents/types.d.ts +52 -0
- package/dist/agents/types.d.ts.map +1 -0
- package/dist/agents/validation.d.ts +10 -0
- package/dist/agents/validation.d.ts.map +1 -0
- package/dist/auth/access-tokens.d.ts +19 -0
- package/dist/auth/access-tokens.d.ts.map +1 -0
- package/dist/auth/audience.d.ts +8 -0
- package/dist/auth/audience.d.ts.map +1 -0
- package/dist/auth/cookies.d.ts +50 -0
- package/dist/auth/cookies.d.ts.map +1 -0
- package/dist/auth/csrf.d.ts +8 -0
- package/dist/auth/csrf.d.ts.map +1 -0
- package/dist/auth/errors.d.ts +7 -0
- package/dist/auth/errors.d.ts.map +1 -0
- package/dist/auth/index.d.ts +15 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +101 -0
- package/dist/auth/index.js.map +9 -0
- package/dist/auth/runtime.d.ts +129 -0
- package/dist/auth/runtime.d.ts.map +1 -0
- package/dist/auth/session-cache.d.ts +44 -0
- package/dist/auth/session-cache.d.ts.map +1 -0
- package/dist/auth/sessions.d.ts +16 -0
- package/dist/auth/sessions.d.ts.map +1 -0
- package/dist/auth/strategy.d.ts +11 -0
- package/dist/auth/strategy.d.ts.map +1 -0
- package/dist/auth/strategy.js +14 -0
- package/dist/auth/strategy.js.map +9 -0
- package/dist/auth/types.d.ts +460 -0
- package/dist/auth/types.d.ts.map +1 -0
- package/dist/auth/validation.d.ts +26 -0
- package/dist/auth/validation.d.ts.map +1 -0
- package/dist/authorization/application-access.d.ts +18 -0
- package/dist/authorization/application-access.d.ts.map +1 -0
- package/dist/authorization/decision.d.ts +104 -0
- package/dist/authorization/decision.d.ts.map +1 -0
- package/dist/authorization/errors.d.ts +10 -0
- package/dist/authorization/errors.d.ts.map +1 -0
- package/dist/authorization/event-visibility.d.ts +16 -0
- package/dist/authorization/event-visibility.d.ts.map +1 -0
- package/dist/authorization/grant-kinds.d.ts +48 -0
- package/dist/authorization/grant-kinds.d.ts.map +1 -0
- package/dist/authorization/index.d.ts +11 -0
- package/dist/authorization/index.d.ts.map +1 -0
- package/dist/authorization/index.js +48 -0
- package/dist/authorization/index.js.map +9 -0
- package/dist/authorization/resolve.d.ts +28 -0
- package/dist/authorization/resolve.d.ts.map +1 -0
- package/dist/authorization/run-visibility.d.ts +15 -0
- package/dist/authorization/run-visibility.d.ts.map +1 -0
- package/dist/authorization/types.d.ts +46 -0
- package/dist/authorization/types.d.ts.map +1 -0
- package/dist/blob-storage/browser.d.ts +14 -0
- package/dist/blob-storage/browser.d.ts.map +1 -0
- package/dist/blob-storage/browser.js +22 -0
- package/dist/blob-storage/browser.js.map +9 -0
- package/dist/blob-storage/constants.d.ts +10 -0
- package/dist/blob-storage/constants.d.ts.map +1 -0
- package/dist/blob-storage/derive.d.ts +4 -0
- package/dist/blob-storage/derive.d.ts.map +1 -0
- package/dist/blob-storage/errors.d.ts +7 -0
- package/dist/blob-storage/errors.d.ts.map +1 -0
- package/dist/blob-storage/in-memory.d.ts +10 -0
- package/dist/blob-storage/in-memory.d.ts.map +1 -0
- package/dist/blob-storage/index.d.ts +8 -0
- package/dist/blob-storage/index.d.ts.map +1 -0
- package/dist/blob-storage/index.js +44 -0
- package/dist/blob-storage/index.js.map +9 -0
- package/dist/blob-storage/types.d.ts +126 -0
- package/dist/blob-storage/types.d.ts.map +1 -0
- package/dist/blob-storage/utils.d.ts +9 -0
- package/dist/blob-storage/utils.d.ts.map +1 -0
- package/dist/blob-storage/validation.d.ts +6 -0
- package/dist/blob-storage/validation.d.ts.map +1 -0
- package/dist/bootstrap/discovery.d.ts +34 -0
- package/dist/bootstrap/discovery.d.ts.map +1 -0
- package/dist/bootstrap/index.d.ts +4 -0
- package/dist/bootstrap/index.d.ts.map +1 -0
- package/dist/bootstrap/index.js +80 -0
- package/dist/bootstrap/index.js.map +9 -0
- package/dist/bootstrap/ontology-type-manifest.d.ts +22 -0
- package/dist/bootstrap/ontology-type-manifest.d.ts.map +1 -0
- package/dist/broker/errors.d.ts +12 -0
- package/dist/broker/errors.d.ts.map +1 -0
- package/dist/broker/in-memory.d.ts +53 -0
- package/dist/broker/in-memory.d.ts.map +1 -0
- package/dist/broker/index.d.ts +5 -0
- package/dist/broker/index.d.ts.map +1 -0
- package/dist/broker/index.js +15 -0
- package/dist/broker/index.js.map +9 -0
- package/dist/broker/types.d.ts +119 -0
- package/dist/broker/types.d.ts.map +1 -0
- package/dist/chunk-04b07a9q.js +89 -0
- package/dist/chunk-04b07a9q.js.map +10 -0
- package/dist/chunk-0fygrz37.js +354 -0
- package/dist/chunk-0fygrz37.js.map +17 -0
- package/dist/chunk-0psb6kdw.js +989 -0
- package/dist/chunk-0psb6kdw.js.map +15 -0
- package/dist/chunk-1evzqhks.js +76 -0
- package/dist/chunk-1evzqhks.js.map +10 -0
- package/dist/chunk-1vffvydj.js +109 -0
- package/dist/chunk-1vffvydj.js.map +10 -0
- package/dist/chunk-2ab72m2h.js +59 -0
- package/dist/chunk-2ab72m2h.js.map +10 -0
- package/dist/chunk-2gpr6jsz.js +1968 -0
- package/dist/chunk-2gpr6jsz.js.map +13 -0
- package/dist/chunk-2s6sydsh.js +368 -0
- package/dist/chunk-2s6sydsh.js.map +12 -0
- package/dist/chunk-45tw90k7.js +72 -0
- package/dist/chunk-45tw90k7.js.map +11 -0
- package/dist/chunk-4pycxcj3.js +35 -0
- package/dist/chunk-4pycxcj3.js.map +11 -0
- package/dist/chunk-50kv63vj.js +523 -0
- package/dist/chunk-50kv63vj.js.map +12 -0
- package/dist/chunk-51fjndv0.js +17 -0
- package/dist/chunk-51fjndv0.js.map +11 -0
- package/dist/chunk-590dejbp.js +49 -0
- package/dist/chunk-590dejbp.js.map +10 -0
- package/dist/chunk-5yny9z0e.js +60 -0
- package/dist/chunk-5yny9z0e.js.map +10 -0
- package/dist/chunk-6wetht33.js +89 -0
- package/dist/chunk-6wetht33.js.map +10 -0
- package/dist/chunk-74drx9gd.js +362 -0
- package/dist/chunk-74drx9gd.js.map +11 -0
- package/dist/chunk-867jxh7c.js +1156 -0
- package/dist/chunk-867jxh7c.js.map +19 -0
- package/dist/chunk-88ppkr54.js +257 -0
- package/dist/chunk-88ppkr54.js.map +12 -0
- package/dist/chunk-8r8cw2xw.js +373 -0
- package/dist/chunk-8r8cw2xw.js.map +11 -0
- package/dist/chunk-8ydjhh27.js +95 -0
- package/dist/chunk-8ydjhh27.js.map +11 -0
- package/dist/chunk-9dzba0f2.js +43 -0
- package/dist/chunk-9dzba0f2.js.map +10 -0
- package/dist/chunk-aebzcsxr.js +5272 -0
- package/dist/chunk-aebzcsxr.js.map +48 -0
- package/dist/chunk-b49dgvsj.js +49 -0
- package/dist/chunk-b49dgvsj.js.map +10 -0
- package/dist/chunk-btpe64e4.js +554 -0
- package/dist/chunk-btpe64e4.js.map +13 -0
- package/dist/chunk-c3zd880g.js +629 -0
- package/dist/chunk-c3zd880g.js.map +14 -0
- package/dist/chunk-dcgrzj1t.js +2954 -0
- package/dist/chunk-dcgrzj1t.js.map +36 -0
- package/dist/chunk-dhmj53mx.js +501 -0
- package/dist/chunk-dhmj53mx.js.map +16 -0
- package/dist/chunk-dktq02ne.js +16 -0
- package/dist/chunk-dktq02ne.js.map +10 -0
- package/dist/chunk-f2b5e2gf.js +141 -0
- package/dist/chunk-f2b5e2gf.js.map +11 -0
- package/dist/chunk-gqdd7508.js +273 -0
- package/dist/chunk-gqdd7508.js.map +11 -0
- package/dist/chunk-hsv43v58.js +1390 -0
- package/dist/chunk-hsv43v58.js.map +21 -0
- package/dist/chunk-jdwx7vzs.js +454 -0
- package/dist/chunk-jdwx7vzs.js.map +14 -0
- package/dist/chunk-k25jm1x5.js +102 -0
- package/dist/chunk-k25jm1x5.js.map +10 -0
- package/dist/chunk-k41ajtz7.js +352 -0
- package/dist/chunk-k41ajtz7.js.map +13 -0
- package/dist/chunk-k6j72mtt.js +9 -0
- package/dist/chunk-k6j72mtt.js.map +10 -0
- package/dist/chunk-mx84y05q.js +426 -0
- package/dist/chunk-mx84y05q.js.map +11 -0
- package/dist/chunk-nvamz5dv.js +819 -0
- package/dist/chunk-nvamz5dv.js.map +21 -0
- package/dist/chunk-p6r5g77m.js +113 -0
- package/dist/chunk-p6r5g77m.js.map +10 -0
- package/dist/chunk-pv1yad91.js +1165 -0
- package/dist/chunk-pv1yad91.js.map +27 -0
- package/dist/chunk-q4qzq0ea.js +832 -0
- package/dist/chunk-q4qzq0ea.js.map +14 -0
- package/dist/chunk-r65yscvk.js +187 -0
- package/dist/chunk-r65yscvk.js.map +11 -0
- package/dist/chunk-ry24jbr1.js +50 -0
- package/dist/chunk-ry24jbr1.js.map +10 -0
- package/dist/chunk-t358gywy.js +991 -0
- package/dist/chunk-t358gywy.js.map +34 -0
- package/dist/chunk-t72dvahb.js +167 -0
- package/dist/chunk-t72dvahb.js.map +12 -0
- package/dist/chunk-tsk2bxs3.js +1254 -0
- package/dist/chunk-tsk2bxs3.js.map +17 -0
- package/dist/chunk-v5c085yp.js +49 -0
- package/dist/chunk-v5c085yp.js.map +10 -0
- package/dist/chunk-vj723r3p.js +146 -0
- package/dist/chunk-vj723r3p.js.map +12 -0
- package/dist/chunk-wj01s5hr.js +363 -0
- package/dist/chunk-wj01s5hr.js.map +11 -0
- package/dist/chunk-wxhdnwh4.js +37 -0
- package/dist/chunk-wxhdnwh4.js.map +10 -0
- package/dist/chunk-xqbtf4wn.js +170 -0
- package/dist/chunk-xqbtf4wn.js.map +10 -0
- package/dist/chunk-xwnf87e1.js +324 -0
- package/dist/chunk-xwnf87e1.js.map +13 -0
- package/dist/chunk-xz5g49bp.js +239 -0
- package/dist/chunk-xz5g49bp.js.map +11 -0
- package/dist/chunk-y64skrwp.js +19 -0
- package/dist/chunk-y64skrwp.js.map +9 -0
- package/dist/chunk-ya6brh8a.js +136 -0
- package/dist/chunk-ya6brh8a.js.map +11 -0
- package/dist/chunk-yt8wphsx.js +12 -0
- package/dist/chunk-yt8wphsx.js.map +10 -0
- package/dist/chunk-yvef9xwc.js +3842 -0
- package/dist/chunk-yvef9xwc.js.map +44 -0
- package/dist/chunk-yxss87qa.js +821 -0
- package/dist/chunk-yxss87qa.js.map +14 -0
- package/dist/connectors/builders.d.ts +10 -0
- package/dist/connectors/builders.d.ts.map +1 -0
- package/dist/connectors/errors.d.ts +14 -0
- package/dist/connectors/errors.d.ts.map +1 -0
- package/dist/connectors/index.d.ts +5 -0
- package/dist/connectors/index.d.ts.map +1 -0
- package/dist/connectors/runtime.d.ts +13 -0
- package/dist/connectors/runtime.d.ts.map +1 -0
- package/dist/connectors/types.d.ts +39 -0
- package/dist/connectors/types.d.ts.map +1 -0
- package/dist/datasets/builders.d.ts +54 -0
- package/dist/datasets/builders.d.ts.map +1 -0
- package/dist/datasets/errors.d.ts +4 -0
- package/dist/datasets/errors.d.ts.map +1 -0
- package/dist/datasets/index.d.ts +5 -0
- package/dist/datasets/index.d.ts.map +1 -0
- package/dist/datasets/types.d.ts +23 -0
- package/dist/datasets/types.d.ts.map +1 -0
- package/dist/datasets/validation.d.ts +8 -0
- package/dist/datasets/validation.d.ts.map +1 -0
- package/dist/edits/errors.d.ts +4 -0
- package/dist/edits/errors.d.ts.map +1 -0
- package/dist/edits/index.d.ts +4 -0
- package/dist/edits/index.d.ts.map +1 -0
- package/dist/edits/index.js +14 -0
- package/dist/edits/index.js.map +9 -0
- package/dist/edits/normalize.d.ts +14 -0
- package/dist/edits/normalize.d.ts.map +1 -0
- package/dist/edits/properties.d.ts +25 -0
- package/dist/edits/properties.d.ts.map +1 -0
- package/dist/edits/recorder.d.ts +4 -0
- package/dist/edits/recorder.d.ts.map +1 -0
- package/dist/edits/types.d.ts +159 -0
- package/dist/edits/types.d.ts.map +1 -0
- package/dist/error-reporting/capability.d.ts +57 -0
- package/dist/error-reporting/capability.d.ts.map +1 -0
- package/dist/error-reporting/internal.d.ts +4 -0
- package/dist/error-reporting/internal.d.ts.map +1 -0
- package/dist/error-reporting/internal.js +24 -0
- package/dist/error-reporting/internal.js.map +9 -0
- package/dist/error-reporting/normalize.d.ts +3 -0
- package/dist/error-reporting/normalize.d.ts.map +1 -0
- package/dist/error-reporting/reporter.d.ts +10 -0
- package/dist/error-reporting/reporter.d.ts.map +1 -0
- package/dist/error-reporting/types.d.ts +112 -0
- package/dist/error-reporting/types.d.ts.map +1 -0
- package/dist/events/definitions.d.ts +76 -0
- package/dist/events/definitions.d.ts.map +1 -0
- package/dist/events/envelope.d.ts +56 -0
- package/dist/events/envelope.d.ts.map +1 -0
- package/dist/events/errors.d.ts +8 -0
- package/dist/events/errors.d.ts.map +1 -0
- package/dist/events/index.d.ts +11 -0
- package/dist/events/index.d.ts.map +1 -0
- package/dist/events/index.js +68 -0
- package/dist/events/index.js.map +9 -0
- package/dist/events/outbox-dispatcher.d.ts +82 -0
- package/dist/events/outbox-dispatcher.d.ts.map +1 -0
- package/dist/events/property-changes.d.ts +16 -0
- package/dist/events/property-changes.d.ts.map +1 -0
- package/dist/events/runtime.d.ts +87 -0
- package/dist/events/runtime.d.ts.map +1 -0
- package/dist/events/scope.d.ts +25 -0
- package/dist/events/scope.d.ts.map +1 -0
- package/dist/events/scope.js +10 -0
- package/dist/events/scope.js.map +9 -0
- package/dist/events/selectors/builder.d.ts +64 -0
- package/dist/events/selectors/builder.d.ts.map +1 -0
- package/dist/events/selectors/index.d.ts +5 -0
- package/dist/events/selectors/index.d.ts.map +1 -0
- package/dist/events/selectors/index.js +15 -0
- package/dist/events/selectors/index.js.map +9 -0
- package/dist/events/selectors/predicate.d.ts +5 -0
- package/dist/events/selectors/predicate.d.ts.map +1 -0
- package/dist/events/selectors/types.d.ts +141 -0
- package/dist/events/selectors/types.d.ts.map +1 -0
- package/dist/events/toStoredEvent.d.ts +10 -0
- package/dist/events/toStoredEvent.d.ts.map +1 -0
- package/dist/events/types/actions.d.ts +39 -0
- package/dist/events/types/actions.d.ts.map +1 -0
- package/dist/events/types/datasets.d.ts +20 -0
- package/dist/events/types/datasets.d.ts.map +1 -0
- package/dist/events/types/index.d.ts +137 -0
- package/dist/events/types/index.d.ts.map +1 -0
- package/dist/events/types/links.d.ts +37 -0
- package/dist/events/types/links.d.ts.map +1 -0
- package/dist/events/types/objects.d.ts +33 -0
- package/dist/events/types/objects.d.ts.map +1 -0
- package/dist/events/types/pipelines.d.ts +59 -0
- package/dist/events/types/pipelines.d.ts.map +1 -0
- package/dist/events/types/rules.d.ts +28 -0
- package/dist/events/types/rules.d.ts.map +1 -0
- package/dist/events/types/schedules.d.ts +14 -0
- package/dist/events/types/schedules.d.ts.map +1 -0
- package/dist/events/types/syncs.d.ts +25 -0
- package/dist/events/types/syncs.d.ts.map +1 -0
- package/dist/events/types/telemetry.d.ts +17 -0
- package/dist/events/types/telemetry.d.ts.map +1 -0
- package/dist/events/types/workflows.d.ts +150 -0
- package/dist/events/types/workflows.d.ts.map +1 -0
- package/dist/http/api-routes.d.ts +24 -0
- package/dist/http/api-routes.d.ts.map +1 -0
- package/dist/http/index.d.ts +4 -0
- package/dist/http/index.d.ts.map +1 -0
- package/dist/http/index.js +16 -0
- package/dist/http/index.js.map +9 -0
- package/dist/http/route-pattern.d.ts +14 -0
- package/dist/http/route-pattern.d.ts.map +1 -0
- package/dist/index.d.ts +70 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +430 -0
- package/dist/index.js.map +9 -0
- package/dist/json.d.ts +14 -0
- package/dist/json.d.ts.map +1 -0
- package/dist/lake-storage/definition-updates.d.ts +40 -0
- package/dist/lake-storage/definition-updates.d.ts.map +1 -0
- package/dist/lake-storage/errors.d.ts +7 -0
- package/dist/lake-storage/errors.d.ts.map +1 -0
- package/dist/lake-storage/in-memory.d.ts +25 -0
- package/dist/lake-storage/in-memory.d.ts.map +1 -0
- package/dist/lake-storage/index.d.ts +9 -0
- package/dist/lake-storage/index.d.ts.map +1 -0
- package/dist/lake-storage/index.js +24 -0
- package/dist/lake-storage/index.js.map +9 -0
- package/dist/lake-storage/sql-transforms.d.ts +45 -0
- package/dist/lake-storage/sql-transforms.d.ts.map +1 -0
- package/dist/lake-storage/types.d.ts +114 -0
- package/dist/lake-storage/types.d.ts.map +1 -0
- package/dist/logging/console-logger.d.ts +17 -0
- package/dist/logging/console-logger.d.ts.map +1 -0
- package/dist/logging/index.d.ts +5 -0
- package/dist/logging/index.d.ts.map +1 -0
- package/dist/logging/index.js +45 -0
- package/dist/logging/index.js.map +9 -0
- package/dist/logging/record.d.ts +10 -0
- package/dist/logging/record.d.ts.map +1 -0
- package/dist/logging/run-logger.d.ts +61 -0
- package/dist/logging/run-logger.d.ts.map +1 -0
- package/dist/logging/runtime.d.ts +87 -0
- package/dist/logging/runtime.d.ts.map +1 -0
- package/dist/logging/stream.d.ts +24 -0
- package/dist/logging/stream.d.ts.map +1 -0
- package/dist/logging/types.d.ts +82 -0
- package/dist/logging/types.d.ts.map +1 -0
- package/dist/logging/types.js +27 -0
- package/dist/logging/types.js.map +9 -0
- package/dist/maintenance/index.d.ts +3 -0
- package/dist/maintenance/index.d.ts.map +1 -0
- package/dist/maintenance/ontology-maintenance.d.ts +48 -0
- package/dist/maintenance/ontology-maintenance.d.ts.map +1 -0
- package/dist/maintenance/types.d.ts +53 -0
- package/dist/maintenance/types.d.ts.map +1 -0
- package/dist/materialization/dataset-watermark.d.ts +5 -0
- package/dist/materialization/dataset-watermark.d.ts.map +1 -0
- package/dist/materialization/errors.d.ts +37 -0
- package/dist/materialization/errors.d.ts.map +1 -0
- package/dist/materialization/events.d.ts +57 -0
- package/dist/materialization/events.d.ts.map +1 -0
- package/dist/materialization/identity.d.ts +8 -0
- package/dist/materialization/identity.d.ts.map +1 -0
- package/dist/materialization/index.d.ts +13 -0
- package/dist/materialization/index.d.ts.map +1 -0
- package/dist/materialization/index.js +56 -0
- package/dist/materialization/index.js.map +9 -0
- package/dist/materialization/model.d.ts +342 -0
- package/dist/materialization/model.d.ts.map +1 -0
- package/dist/materialization/refs.d.ts +24 -0
- package/dist/materialization/refs.d.ts.map +1 -0
- package/dist/materializer/context.d.ts +34 -0
- package/dist/materializer/context.d.ts.map +1 -0
- package/dist/materializer/edits/apply.d.ts +35 -0
- package/dist/materializer/edits/apply.d.ts.map +1 -0
- package/dist/materializer/edits/commit.d.ts +4 -0
- package/dist/materializer/edits/commit.d.ts.map +1 -0
- package/dist/materializer/edits/execution-units.d.ts +14 -0
- package/dist/materializer/edits/execution-units.d.ts.map +1 -0
- package/dist/materializer/edits/load-state.d.ts +6 -0
- package/dist/materializer/edits/load-state.d.ts.map +1 -0
- package/dist/materializer/edits/operations.d.ts +32 -0
- package/dist/materializer/edits/operations.d.ts.map +1 -0
- package/dist/materializer/edits/plan.d.ts +18 -0
- package/dist/materializer/edits/plan.d.ts.map +1 -0
- package/dist/materializer/edits/read-set.d.ts +8 -0
- package/dist/materializer/edits/read-set.d.ts.map +1 -0
- package/dist/materializer/edits/working-state.d.ts +30 -0
- package/dist/materializer/edits/working-state.d.ts.map +1 -0
- package/dist/materializer/effective/build-events.d.ts +26 -0
- package/dist/materializer/effective/build-events.d.ts.map +1 -0
- package/dist/materializer/effective/diff.d.ts +15 -0
- package/dist/materializer/effective/diff.d.ts.map +1 -0
- package/dist/materializer/effective/load-state.d.ts +7 -0
- package/dist/materializer/effective/load-state.d.ts.map +1 -0
- package/dist/materializer/effective/resolve.d.ts +26 -0
- package/dist/materializer/effective/resolve.d.ts.map +1 -0
- package/dist/materializer/effective/validate.d.ts +11 -0
- package/dist/materializer/effective/validate.d.ts.map +1 -0
- package/dist/materializer/execution/commit-lifecycle.d.ts +8 -0
- package/dist/materializer/execution/commit-lifecycle.d.ts.map +1 -0
- package/dist/materializer/execution/plan-stream.d.ts +8 -0
- package/dist/materializer/execution/plan-stream.d.ts.map +1 -0
- package/dist/materializer/execution/run-correlation.d.ts +19 -0
- package/dist/materializer/execution/run-correlation.d.ts.map +1 -0
- package/dist/materializer/execution/work-executor.d.ts +13 -0
- package/dist/materializer/execution/work-executor.d.ts.map +1 -0
- package/dist/materializer/execution/work-records.d.ts +15 -0
- package/dist/materializer/execution/work-records.d.ts.map +1 -0
- package/dist/materializer/index.d.ts +15 -0
- package/dist/materializer/index.d.ts.map +1 -0
- package/dist/materializer/index.js +134 -0
- package/dist/materializer/index.js.map +9 -0
- package/dist/materializer/materializer.d.ts +27 -0
- package/dist/materializer/materializer.d.ts.map +1 -0
- package/dist/materializer/projections/entry-validator.d.ts +8 -0
- package/dist/materializer/projections/entry-validator.d.ts.map +1 -0
- package/dist/materializer/projections/finish-run.d.ts +4 -0
- package/dist/materializer/projections/finish-run.d.ts.map +1 -0
- package/dist/materializer/projections/replace.d.ts +4 -0
- package/dist/materializer/projections/replace.d.ts.map +1 -0
- package/dist/materializer/projections/replacement-plan.d.ts +14 -0
- package/dist/materializer/projections/replacement-plan.d.ts.map +1 -0
- package/dist/materializer/projections/source-materialization.d.ts +27 -0
- package/dist/materializer/projections/source-materialization.d.ts.map +1 -0
- package/dist/materializer/shared/abort.d.ts +2 -0
- package/dist/materializer/shared/abort.d.ts.map +1 -0
- package/dist/materializer/shared/batching.d.ts +11 -0
- package/dist/materializer/shared/batching.d.ts.map +1 -0
- package/dist/materializer/shared/chunking.d.ts +6 -0
- package/dist/materializer/shared/chunking.d.ts.map +1 -0
- package/dist/materializer/shared/identity.d.ts +38 -0
- package/dist/materializer/shared/identity.d.ts.map +1 -0
- package/dist/materializer/shared/normalize.d.ts +10 -0
- package/dist/materializer/shared/normalize.d.ts.map +1 -0
- package/dist/materializer/shared/projection-run.d.ts +19 -0
- package/dist/materializer/shared/projection-run.d.ts.map +1 -0
- package/dist/materializer/telemetry/append.d.ts +4 -0
- package/dist/materializer/telemetry/append.d.ts.map +1 -0
- package/dist/materializer/telemetry/plan.d.ts +12 -0
- package/dist/materializer/telemetry/plan.d.ts.map +1 -0
- package/dist/objects/action/errors.d.ts +39 -0
- package/dist/objects/action/errors.d.ts.map +1 -0
- package/dist/objects/action/index.d.ts +4 -0
- package/dist/objects/action/index.d.ts.map +1 -0
- package/dist/objects/action/request.d.ts +23 -0
- package/dist/objects/action/request.d.ts.map +1 -0
- package/dist/objects/context/index.d.ts +3 -0
- package/dist/objects/context/index.d.ts.map +1 -0
- package/dist/objects/context/resolve.d.ts +27 -0
- package/dist/objects/context/resolve.d.ts.map +1 -0
- package/dist/objects/context/types.d.ts +28 -0
- package/dist/objects/context/types.d.ts.map +1 -0
- package/dist/objects/contexts.d.ts +45 -0
- package/dist/objects/contexts.d.ts.map +1 -0
- package/dist/objects/errors.d.ts +8 -0
- package/dist/objects/errors.d.ts.map +1 -0
- package/dist/objects/helpers.d.ts +7 -0
- package/dist/objects/helpers.d.ts.map +1 -0
- package/dist/objects/index.d.ts +18 -0
- package/dist/objects/index.d.ts.map +1 -0
- package/dist/objects/index.js +71 -0
- package/dist/objects/index.js.map +9 -0
- package/dist/objects/link/authorization.d.ts +25 -0
- package/dist/objects/link/authorization.d.ts.map +1 -0
- package/dist/objects/link/endpoints.d.ts +28 -0
- package/dist/objects/link/endpoints.d.ts.map +1 -0
- package/dist/objects/link/index.d.ts +4 -0
- package/dist/objects/link/index.d.ts.map +1 -0
- package/dist/objects/link/remove.d.ts +8 -0
- package/dist/objects/link/remove.d.ts.map +1 -0
- package/dist/objects/link/upsert-batch.d.ts +11 -0
- package/dist/objects/link/upsert-batch.d.ts.map +1 -0
- package/dist/objects/link/upsert.d.ts +12 -0
- package/dist/objects/link/upsert.d.ts.map +1 -0
- package/dist/objects/materializer-adapter.d.ts +114 -0
- package/dist/objects/materializer-adapter.d.ts.map +1 -0
- package/dist/objects/object/delete.d.ts +17 -0
- package/dist/objects/object/delete.d.ts.map +1 -0
- package/dist/objects/object/index.d.ts +4 -0
- package/dist/objects/object/index.d.ts.map +1 -0
- package/dist/objects/object/upsert-batch.d.ts +7 -0
- package/dist/objects/object/upsert-batch.d.ts.map +1 -0
- package/dist/objects/object/upsert.d.ts +7 -0
- package/dist/objects/object/upsert.d.ts.map +1 -0
- package/dist/objects/query/errors.d.ts +23 -0
- package/dist/objects/query/errors.d.ts.map +1 -0
- package/dist/objects/query/executor.d.ts +63 -0
- package/dist/objects/query/executor.d.ts.map +1 -0
- package/dist/objects/query/explain-format.d.ts +10 -0
- package/dist/objects/query/explain-format.d.ts.map +1 -0
- package/dist/objects/query/explain.d.ts +26 -0
- package/dist/objects/query/explain.d.ts.map +1 -0
- package/dist/objects/query/index.d.ts +14 -0
- package/dist/objects/query/index.d.ts.map +1 -0
- package/dist/objects/query/index.js +54 -0
- package/dist/objects/query/index.js.map +9 -0
- package/dist/objects/query/ir.d.ts +166 -0
- package/dist/objects/query/ir.d.ts.map +1 -0
- package/dist/objects/query/normalize.d.ts +12 -0
- package/dist/objects/query/normalize.d.ts.map +1 -0
- package/dist/objects/query/planner.d.ts +32 -0
- package/dist/objects/query/planner.d.ts.map +1 -0
- package/dist/objects/query/scalar-values.d.ts +6 -0
- package/dist/objects/query/scalar-values.d.ts.map +1 -0
- package/dist/objects/query/validate.d.ts +23 -0
- package/dist/objects/query/validate.d.ts.map +1 -0
- package/dist/objects/runtime-batch.d.ts +29 -0
- package/dist/objects/runtime-batch.d.ts.map +1 -0
- package/dist/objects/sdk/index.d.ts +3 -0
- package/dist/objects/sdk/index.d.ts.map +1 -0
- package/dist/objects/sdk/object-handle.d.ts +6 -0
- package/dist/objects/sdk/object-handle.d.ts.map +1 -0
- package/dist/objects/sdk/object-set.d.ts +14 -0
- package/dist/objects/sdk/object-set.d.ts.map +1 -0
- package/dist/objects/sdk/query-builder.d.ts +20 -0
- package/dist/objects/sdk/query-builder.d.ts.map +1 -0
- package/dist/objects/sdk/query-executor.d.ts +51 -0
- package/dist/objects/sdk/query-executor.d.ts.map +1 -0
- package/dist/objects/sdk/runtime-query-executor.d.ts +16 -0
- package/dist/objects/sdk/runtime-query-executor.d.ts.map +1 -0
- package/dist/objects/sdk/telemetry-channel.d.ts +6 -0
- package/dist/objects/sdk/telemetry-channel.d.ts.map +1 -0
- package/dist/objects/sdk/where.d.ts +15 -0
- package/dist/objects/sdk/where.d.ts.map +1 -0
- package/dist/objects/service/action-service.d.ts +12 -0
- package/dist/objects/service/action-service.d.ts.map +1 -0
- package/dist/objects/service/index.d.ts +7 -0
- package/dist/objects/service/index.d.ts.map +1 -0
- package/dist/objects/service/link-service.d.ts +26 -0
- package/dist/objects/service/link-service.d.ts.map +1 -0
- package/dist/objects/service/list-service.d.ts +24 -0
- package/dist/objects/service/list-service.d.ts.map +1 -0
- package/dist/objects/service/object-service.d.ts +12 -0
- package/dist/objects/service/object-service.d.ts.map +1 -0
- package/dist/objects/service/telemetry-service.d.ts +12 -0
- package/dist/objects/service/telemetry-service.d.ts.map +1 -0
- package/dist/objects/telemetry/append-batch.d.ts +10 -0
- package/dist/objects/telemetry/append-batch.d.ts.map +1 -0
- package/dist/objects/telemetry/history.d.ts +8 -0
- package/dist/objects/telemetry/history.d.ts.map +1 -0
- package/dist/objects/telemetry/index.d.ts +5 -0
- package/dist/objects/telemetry/index.d.ts.map +1 -0
- package/dist/objects/telemetry/write-batch.d.ts +8 -0
- package/dist/objects/telemetry/write-batch.d.ts.map +1 -0
- package/dist/ontology/builders.d.ts +323 -0
- package/dist/ontology/builders.d.ts.map +1 -0
- package/dist/ontology/decimal.d.ts +28 -0
- package/dist/ontology/decimal.d.ts.map +1 -0
- package/dist/ontology/errors.d.ts +20 -0
- package/dist/ontology/errors.d.ts.map +1 -0
- package/dist/ontology/index.d.ts +23 -0
- package/dist/ontology/index.d.ts.map +1 -0
- package/dist/ontology/index.js +120 -0
- package/dist/ontology/index.js.map +9 -0
- package/dist/ontology/inference/index.d.ts +112 -0
- package/dist/ontology/inference/index.d.ts.map +1 -0
- package/dist/ontology/internal.d.ts +4 -0
- package/dist/ontology/internal.d.ts.map +1 -0
- package/dist/ontology/internal.js +118 -0
- package/dist/ontology/internal.js.map +10 -0
- package/dist/ontology/json-schema.d.ts +9 -0
- package/dist/ontology/json-schema.d.ts.map +1 -0
- package/dist/ontology/refs.d.ts +16 -0
- package/dist/ontology/refs.d.ts.map +1 -0
- package/dist/ontology/registry.d.ts +82 -0
- package/dist/ontology/registry.d.ts.map +1 -0
- package/dist/ontology/tokens.d.ts +54 -0
- package/dist/ontology/tokens.d.ts.map +1 -0
- package/dist/ontology/types.d.ts +402 -0
- package/dist/ontology/types.d.ts.map +1 -0
- package/dist/ontology/units/index.d.ts +74 -0
- package/dist/ontology/units/index.d.ts.map +1 -0
- package/dist/ontology/units/quantitative-types.d.ts +1605 -0
- package/dist/ontology/units/quantitative-types.d.ts.map +1 -0
- package/dist/ontology/units/types.d.ts +26 -0
- package/dist/ontology/units/types.d.ts.map +1 -0
- package/dist/ontology/validation/index.d.ts +7 -0
- package/dist/ontology/validation/index.d.ts.map +1 -0
- package/dist/ontology/validation/links.d.ts +18 -0
- package/dist/ontology/validation/links.d.ts.map +1 -0
- package/dist/ontology/validation/normalize.d.ts +21 -0
- package/dist/ontology/validation/normalize.d.ts.map +1 -0
- package/dist/ontology/validation/properties.d.ts +19 -0
- package/dist/ontology/validation/properties.d.ts.map +1 -0
- package/dist/ontology/validation/query.d.ts +3 -0
- package/dist/ontology/validation/query.d.ts.map +1 -0
- package/dist/ontology/validation/schema.d.ts +7 -0
- package/dist/ontology/validation/schema.d.ts.map +1 -0
- package/dist/ontology/validation/telemetry.d.ts +7 -0
- package/dist/ontology/validation/telemetry.d.ts.map +1 -0
- package/dist/pipelines/builders.d.ts +14 -0
- package/dist/pipelines/builders.d.ts.map +1 -0
- package/dist/pipelines/errors.d.ts +4 -0
- package/dist/pipelines/errors.d.ts.map +1 -0
- package/dist/pipelines/index.d.ts +7 -0
- package/dist/pipelines/index.d.ts.map +1 -0
- package/dist/pipelines/request.d.ts +31 -0
- package/dist/pipelines/request.d.ts.map +1 -0
- package/dist/pipelines/types.d.ts +84 -0
- package/dist/pipelines/types.d.ts.map +1 -0
- package/dist/predicates/builders.d.ts +24 -0
- package/dist/predicates/builders.d.ts.map +1 -0
- package/dist/predicates/evaluate.d.ts +8 -0
- package/dist/predicates/evaluate.d.ts.map +1 -0
- package/dist/predicates/index.d.ts +5 -0
- package/dist/predicates/index.d.ts.map +1 -0
- package/dist/predicates/types.d.ts +69 -0
- package/dist/predicates/types.d.ts.map +1 -0
- package/dist/predicates/validation.d.ts +15 -0
- package/dist/predicates/validation.d.ts.map +1 -0
- package/dist/projections/builders.d.ts +212 -0
- package/dist/projections/builders.d.ts.map +1 -0
- package/dist/projections/errors.d.ts +4 -0
- package/dist/projections/errors.d.ts.map +1 -0
- package/dist/projections/index.d.ts +5 -0
- package/dist/projections/index.d.ts.map +1 -0
- package/dist/projections/internal.d.ts +24 -0
- package/dist/projections/internal.d.ts.map +1 -0
- package/dist/projections/internal.js +26 -0
- package/dist/projections/internal.js.map +9 -0
- package/dist/projections/ownership.d.ts +9 -0
- package/dist/projections/ownership.d.ts.map +1 -0
- package/dist/projections/registry.d.ts +30 -0
- package/dist/projections/registry.d.ts.map +1 -0
- package/dist/projections/revision.d.ts +7 -0
- package/dist/projections/revision.d.ts.map +1 -0
- package/dist/projections/types.d.ts +153 -0
- package/dist/projections/types.d.ts.map +1 -0
- package/dist/projections/validation.d.ts +97 -0
- package/dist/projections/validation.d.ts.map +1 -0
- package/dist/provider-scope.d.ts +12 -0
- package/dist/provider-scope.d.ts.map +1 -0
- package/dist/query.d.ts +17 -0
- package/dist/query.d.ts.map +1 -0
- package/dist/query.js +21 -0
- package/dist/query.js.map +9 -0
- package/dist/queues/errors.d.ts +7 -0
- package/dist/queues/errors.d.ts.map +1 -0
- package/dist/queues/in-memory.d.ts +73 -0
- package/dist/queues/in-memory.d.ts.map +1 -0
- package/dist/queues/index.d.ts +5 -0
- package/dist/queues/index.d.ts.map +1 -0
- package/dist/queues/index.js +12 -0
- package/dist/queues/index.js.map +9 -0
- package/dist/queues/types.d.ts +182 -0
- package/dist/queues/types.d.ts.map +1 -0
- package/dist/rules/builders.d.ts +10 -0
- package/dist/rules/builders.d.ts.map +1 -0
- package/dist/rules/dependencies.d.ts +9 -0
- package/dist/rules/dependencies.d.ts.map +1 -0
- package/dist/rules/errors.d.ts +11 -0
- package/dist/rules/errors.d.ts.map +1 -0
- package/dist/rules/index.d.ts +6 -0
- package/dist/rules/index.d.ts.map +1 -0
- package/dist/rules/internal.d.ts +9 -0
- package/dist/rules/internal.d.ts.map +1 -0
- package/dist/rules/internal.js +10 -0
- package/dist/rules/internal.js.map +9 -0
- package/dist/rules/types.d.ts +72 -0
- package/dist/rules/types.d.ts.map +1 -0
- package/dist/rules/validation.d.ts +23 -0
- package/dist/rules/validation.d.ts.map +1 -0
- package/dist/runtime/create.d.ts +68 -0
- package/dist/runtime/create.d.ts.map +1 -0
- package/dist/runtime/errors.d.ts +9 -0
- package/dist/runtime/errors.d.ts.map +1 -0
- package/dist/runtime/index.d.ts +26 -0
- package/dist/runtime/index.d.ts.map +1 -0
- package/dist/runtime/internal.d.ts +3 -0
- package/dist/runtime/internal.d.ts.map +1 -0
- package/dist/runtime/internal.js +16 -0
- package/dist/runtime/internal.js.map +9 -0
- package/dist/runtime/ontology-mutations.d.ts +16 -0
- package/dist/runtime/ontology-mutations.d.ts.map +1 -0
- package/dist/runtime/scoped.d.ts +158 -0
- package/dist/runtime/scoped.d.ts.map +1 -0
- package/dist/runtime/sixb.d.ts +226 -0
- package/dist/runtime/sixb.d.ts.map +1 -0
- package/dist/runtime/storage-readiness.d.ts +20 -0
- package/dist/runtime/storage-readiness.d.ts.map +1 -0
- package/dist/runtime/types.d.ts +840 -0
- package/dist/runtime/types.d.ts.map +1 -0
- package/dist/sandboxes/errors.d.ts +20 -0
- package/dist/sandboxes/errors.d.ts.map +1 -0
- package/dist/sandboxes/exec.d.ts +17 -0
- package/dist/sandboxes/exec.d.ts.map +1 -0
- package/dist/sandboxes/index.d.ts +5 -0
- package/dist/sandboxes/index.d.ts.map +1 -0
- package/dist/sandboxes/index.js +18 -0
- package/dist/sandboxes/index.js.map +9 -0
- package/dist/sandboxes/sandbox.d.ts +110 -0
- package/dist/sandboxes/sandbox.d.ts.map +1 -0
- package/dist/scheduler/errors.d.ts +7 -0
- package/dist/scheduler/errors.d.ts.map +1 -0
- package/dist/scheduler/index.d.ts +4 -0
- package/dist/scheduler/index.d.ts.map +1 -0
- package/dist/scheduler/index.js +18 -0
- package/dist/scheduler/index.js.map +9 -0
- package/dist/scheduler/runtime.d.ts +32 -0
- package/dist/scheduler/runtime.d.ts.map +1 -0
- package/dist/schedules/builders.d.ts +4 -0
- package/dist/schedules/builders.d.ts.map +1 -0
- package/dist/schedules/cron.d.ts +14 -0
- package/dist/schedules/cron.d.ts.map +1 -0
- package/dist/schedules/errors.d.ts +7 -0
- package/dist/schedules/errors.d.ts.map +1 -0
- package/dist/schedules/index.d.ts +12 -0
- package/dist/schedules/index.d.ts.map +1 -0
- package/dist/schedules/index.js +37 -0
- package/dist/schedules/index.js.map +9 -0
- package/dist/schedules/next-occurrence.d.ts +11 -0
- package/dist/schedules/next-occurrence.d.ts.map +1 -0
- package/dist/schedules/runtime.d.ts +17 -0
- package/dist/schedules/runtime.d.ts.map +1 -0
- package/dist/schedules/types.d.ts +99 -0
- package/dist/schedules/types.d.ts.map +1 -0
- package/dist/schedules/validation.d.ts +13 -0
- package/dist/schedules/validation.d.ts.map +1 -0
- package/dist/security/applications.d.ts +15 -0
- package/dist/security/applications.d.ts.map +1 -0
- package/dist/security/builders.d.ts +20 -0
- package/dist/security/builders.d.ts.map +1 -0
- package/dist/security/errors.d.ts +4 -0
- package/dist/security/errors.d.ts.map +1 -0
- package/dist/security/every.d.ts +68 -0
- package/dist/security/every.d.ts.map +1 -0
- package/dist/security/grants.d.ts +40 -0
- package/dist/security/grants.d.ts.map +1 -0
- package/dist/security/index.d.ts +12 -0
- package/dist/security/index.d.ts.map +1 -0
- package/dist/security/membership-policies.d.ts +17 -0
- package/dist/security/membership-policies.d.ts.map +1 -0
- package/dist/security/runtime.d.ts +16 -0
- package/dist/security/runtime.d.ts.map +1 -0
- package/dist/security/types.d.ts +133 -0
- package/dist/security/types.d.ts.map +1 -0
- package/dist/security/validation.d.ts +36 -0
- package/dist/security/validation.d.ts.map +1 -0
- package/dist/storage/action-runs/errors.d.ts +10 -0
- package/dist/storage/action-runs/errors.d.ts.map +1 -0
- package/dist/storage/action-runs/idempotency.d.ts +10 -0
- package/dist/storage/action-runs/idempotency.d.ts.map +1 -0
- package/dist/storage/action-runs/in-memory.d.ts +28 -0
- package/dist/storage/action-runs/in-memory.d.ts.map +1 -0
- package/dist/storage/action-runs/index.d.ts +6 -0
- package/dist/storage/action-runs/index.d.ts.map +1 -0
- package/dist/storage/action-runs/types.d.ts +138 -0
- package/dist/storage/action-runs/types.d.ts.map +1 -0
- package/dist/storage/agents/errors.d.ts +11 -0
- package/dist/storage/agents/errors.d.ts.map +1 -0
- package/dist/storage/agents/in-memory.d.ts +70 -0
- package/dist/storage/agents/in-memory.d.ts.map +1 -0
- package/dist/storage/agents/index.d.ts +7 -0
- package/dist/storage/agents/index.d.ts.map +1 -0
- package/dist/storage/agents/types.d.ts +295 -0
- package/dist/storage/agents/types.d.ts.map +1 -0
- package/dist/storage/auth/errors.d.ts +10 -0
- package/dist/storage/auth/errors.d.ts.map +1 -0
- package/dist/storage/auth/in-memory/access-tokens.d.ts +32 -0
- package/dist/storage/auth/in-memory/access-tokens.d.ts.map +1 -0
- package/dist/storage/auth/in-memory/auth-storage.d.ts +36 -0
- package/dist/storage/auth/in-memory/auth-storage.d.ts.map +1 -0
- package/dist/storage/auth/in-memory/group-memberships.d.ts +21 -0
- package/dist/storage/auth/in-memory/group-memberships.d.ts.map +1 -0
- package/dist/storage/auth/in-memory/identities.d.ts +17 -0
- package/dist/storage/auth/in-memory/identities.d.ts.map +1 -0
- package/dist/storage/auth/in-memory/index.d.ts +2 -0
- package/dist/storage/auth/in-memory/index.d.ts.map +1 -0
- package/dist/storage/auth/in-memory/invitations.d.ts +28 -0
- package/dist/storage/auth/in-memory/invitations.d.ts.map +1 -0
- package/dist/storage/auth/in-memory/magic-links.d.ts +28 -0
- package/dist/storage/auth/in-memory/magic-links.d.ts.map +1 -0
- package/dist/storage/auth/in-memory/oidc-attempts.d.ts +18 -0
- package/dist/storage/auth/in-memory/oidc-attempts.d.ts.map +1 -0
- package/dist/storage/auth/in-memory/service-account-group-memberships.d.ts +17 -0
- package/dist/storage/auth/in-memory/service-account-group-memberships.d.ts.map +1 -0
- package/dist/storage/auth/in-memory/service-accounts.d.ts +14 -0
- package/dist/storage/auth/in-memory/service-accounts.d.ts.map +1 -0
- package/dist/storage/auth/in-memory/sessions.d.ts +55 -0
- package/dist/storage/auth/in-memory/sessions.d.ts.map +1 -0
- package/dist/storage/auth/in-memory/shared.d.ts +71 -0
- package/dist/storage/auth/in-memory/shared.d.ts.map +1 -0
- package/dist/storage/auth/in-memory/users.d.ts +19 -0
- package/dist/storage/auth/in-memory/users.d.ts.map +1 -0
- package/dist/storage/auth/in-memory.d.ts +2 -0
- package/dist/storage/auth/in-memory.d.ts.map +1 -0
- package/dist/storage/auth/index.d.ts +5 -0
- package/dist/storage/auth/index.d.ts.map +1 -0
- package/dist/storage/auth/types.d.ts +584 -0
- package/dist/storage/auth/types.d.ts.map +1 -0
- package/dist/storage/errors.d.ts +27 -0
- package/dist/storage/errors.d.ts.map +1 -0
- package/dist/storage/file-upload-sessions/errors.d.ts +15 -0
- package/dist/storage/file-upload-sessions/errors.d.ts.map +1 -0
- package/dist/storage/file-upload-sessions/in-memory.d.ts +27 -0
- package/dist/storage/file-upload-sessions/in-memory.d.ts.map +1 -0
- package/dist/storage/file-upload-sessions/index.d.ts +6 -0
- package/dist/storage/file-upload-sessions/index.d.ts.map +1 -0
- package/dist/storage/file-upload-sessions/types.d.ts +53 -0
- package/dist/storage/file-upload-sessions/types.d.ts.map +1 -0
- package/dist/storage/file-upload-sessions/utils.d.ts +11 -0
- package/dist/storage/file-upload-sessions/utils.d.ts.map +1 -0
- package/dist/storage/in-memory/index.d.ts +105 -0
- package/dist/storage/in-memory/index.d.ts.map +1 -0
- package/dist/storage/in-memory/testing.d.ts +8 -0
- package/dist/storage/in-memory/testing.d.ts.map +1 -0
- package/dist/storage/index.d.ts +44 -0
- package/dist/storage/index.d.ts.map +1 -0
- package/dist/storage/index.js +144 -0
- package/dist/storage/index.js.map +9 -0
- package/dist/storage/migrations/check-schema.d.ts +19 -0
- package/dist/storage/migrations/check-schema.d.ts.map +1 -0
- package/dist/storage/migrations/index.d.ts +5 -0
- package/dist/storage/migrations/index.d.ts.map +1 -0
- package/dist/storage/migrations/migrate-storage.d.ts +6 -0
- package/dist/storage/migrations/migrate-storage.d.ts.map +1 -0
- package/dist/storage/migrations/migration-set.d.ts +27 -0
- package/dist/storage/migrations/migration-set.d.ts.map +1 -0
- package/dist/storage/migrations/types.d.ts +115 -0
- package/dist/storage/migrations/types.d.ts.map +1 -0
- package/dist/storage/objects/in-memory.d.ts +126 -0
- package/dist/storage/objects/in-memory.d.ts.map +1 -0
- package/dist/storage/objects/index.d.ts +2 -0
- package/dist/storage/objects/index.d.ts.map +1 -0
- package/dist/storage/objects/types.d.ts +222 -0
- package/dist/storage/objects/types.d.ts.map +1 -0
- package/dist/storage/ontology/commits.d.ts +117 -0
- package/dist/storage/ontology/commits.d.ts.map +1 -0
- package/dist/storage/ontology/in-memory/commits.d.ts +12 -0
- package/dist/storage/ontology/in-memory/commits.d.ts.map +1 -0
- package/dist/storage/ontology/in-memory/index.d.ts +36 -0
- package/dist/storage/ontology/in-memory/index.d.ts.map +1 -0
- package/dist/storage/ontology/in-memory/materializations-finalization.d.ts +5 -0
- package/dist/storage/ontology/in-memory/materializations-finalization.d.ts.map +1 -0
- package/dist/storage/ontology/in-memory/materializations-state.d.ts +20 -0
- package/dist/storage/ontology/in-memory/materializations-state.d.ts.map +1 -0
- package/dist/storage/ontology/in-memory/materializations-work.d.ts +6 -0
- package/dist/storage/ontology/in-memory/materializations-work.d.ts.map +1 -0
- package/dist/storage/ontology/in-memory/materializations.d.ts +101 -0
- package/dist/storage/ontology/in-memory/materializations.d.ts.map +1 -0
- package/dist/storage/ontology/in-memory/outbox.d.ts +19 -0
- package/dist/storage/ontology/in-memory/outbox.d.ts.map +1 -0
- package/dist/storage/ontology/in-memory/shared-state.d.ts +48 -0
- package/dist/storage/ontology/in-memory/shared-state.d.ts.map +1 -0
- package/dist/storage/ontology/in-memory/sources.d.ts +23 -0
- package/dist/storage/ontology/in-memory/sources.d.ts.map +1 -0
- package/dist/storage/ontology/in-memory/testing.d.ts +11 -0
- package/dist/storage/ontology/in-memory/testing.d.ts.map +1 -0
- package/dist/storage/ontology/index.d.ts +16 -0
- package/dist/storage/ontology/index.d.ts.map +1 -0
- package/dist/storage/ontology/materializations.d.ts +333 -0
- package/dist/storage/ontology/materializations.d.ts.map +1 -0
- package/dist/storage/ontology/outbox.d.ts +66 -0
- package/dist/storage/ontology/outbox.d.ts.map +1 -0
- package/dist/storage/ontology/provider-header-validation.d.ts +4 -0
- package/dist/storage/ontology/provider-header-validation.d.ts.map +1 -0
- package/dist/storage/ontology/provider-validation.d.ts +6 -0
- package/dist/storage/ontology/provider-validation.d.ts.map +1 -0
- package/dist/storage/ontology/provider-work.d.ts +12 -0
- package/dist/storage/ontology/provider-work.d.ts.map +1 -0
- package/dist/storage/ontology/provider.d.ts +191 -0
- package/dist/storage/ontology/provider.d.ts.map +1 -0
- package/dist/storage/ontology/provider.js +115 -0
- package/dist/storage/ontology/provider.js.map +9 -0
- package/dist/storage/ontology/sources.d.ts +151 -0
- package/dist/storage/ontology/sources.d.ts.map +1 -0
- package/dist/storage/operation-scope.d.ts +32 -0
- package/dist/storage/operation-scope.d.ts.map +1 -0
- package/dist/storage/operation-scope.js +22 -0
- package/dist/storage/operation-scope.js.map +9 -0
- package/dist/storage/pagination.d.ts +11 -0
- package/dist/storage/pagination.d.ts.map +1 -0
- package/dist/storage/pipeline-runs/errors.d.ts +7 -0
- package/dist/storage/pipeline-runs/errors.d.ts.map +1 -0
- package/dist/storage/pipeline-runs/in-memory.d.ts +26 -0
- package/dist/storage/pipeline-runs/in-memory.d.ts.map +1 -0
- package/dist/storage/pipeline-runs/index.d.ts +4 -0
- package/dist/storage/pipeline-runs/index.d.ts.map +1 -0
- package/dist/storage/pipeline-runs/types.d.ts +133 -0
- package/dist/storage/pipeline-runs/types.d.ts.map +1 -0
- package/dist/storage/projection-runs/errors.d.ts +9 -0
- package/dist/storage/projection-runs/errors.d.ts.map +1 -0
- package/dist/storage/projection-runs/in-memory.d.ts +42 -0
- package/dist/storage/projection-runs/in-memory.d.ts.map +1 -0
- package/dist/storage/projection-runs/index.d.ts +5 -0
- package/dist/storage/projection-runs/index.d.ts.map +1 -0
- package/dist/storage/projection-runs/lifecycle.d.ts +93 -0
- package/dist/storage/projection-runs/lifecycle.d.ts.map +1 -0
- package/dist/storage/projection-runs/lifecycle.js +64 -0
- package/dist/storage/projection-runs/lifecycle.js.map +9 -0
- package/dist/storage/projection-runs/types.d.ts +175 -0
- package/dist/storage/projection-runs/types.d.ts.map +1 -0
- package/dist/storage/rules/in-memory.d.ts +26 -0
- package/dist/storage/rules/in-memory.d.ts.map +1 -0
- package/dist/storage/rules/index.d.ts +3 -0
- package/dist/storage/rules/index.d.ts.map +1 -0
- package/dist/storage/rules/types.d.ts +60 -0
- package/dist/storage/rules/types.d.ts.map +1 -0
- package/dist/storage/run-listing.d.ts +36 -0
- package/dist/storage/run-listing.d.ts.map +1 -0
- package/dist/storage/sync-runs/errors.d.ts +8 -0
- package/dist/storage/sync-runs/errors.d.ts.map +1 -0
- package/dist/storage/sync-runs/in-memory.d.ts +16 -0
- package/dist/storage/sync-runs/in-memory.d.ts.map +1 -0
- package/dist/storage/sync-runs/index.d.ts +4 -0
- package/dist/storage/sync-runs/index.d.ts.map +1 -0
- package/dist/storage/sync-runs/types.d.ts +85 -0
- package/dist/storage/sync-runs/types.d.ts.map +1 -0
- package/dist/storage/timeseries/index.d.ts +2 -0
- package/dist/storage/timeseries/index.d.ts.map +1 -0
- package/dist/storage/timeseries/store.d.ts +46 -0
- package/dist/storage/timeseries/store.d.ts.map +1 -0
- package/dist/storage/timeseries/types.d.ts +50 -0
- package/dist/storage/timeseries/types.d.ts.map +1 -0
- package/dist/storage/transaction.d.ts +4 -0
- package/dist/storage/transaction.d.ts.map +1 -0
- package/dist/storage/types.d.ts +78 -0
- package/dist/storage/types.d.ts.map +1 -0
- package/dist/storage/webhook-deliveries/in-memory.d.ts +18 -0
- package/dist/storage/webhook-deliveries/in-memory.d.ts.map +1 -0
- package/dist/storage/webhook-deliveries/index.d.ts +3 -0
- package/dist/storage/webhook-deliveries/index.d.ts.map +1 -0
- package/dist/storage/webhook-deliveries/types.d.ts +43 -0
- package/dist/storage/webhook-deliveries/types.d.ts.map +1 -0
- package/dist/storage/webhook-runs/errors.d.ts +7 -0
- package/dist/storage/webhook-runs/errors.d.ts.map +1 -0
- package/dist/storage/webhook-runs/in-memory.d.ts +16 -0
- package/dist/storage/webhook-runs/in-memory.d.ts.map +1 -0
- package/dist/storage/webhook-runs/index.d.ts +4 -0
- package/dist/storage/webhook-runs/index.d.ts.map +1 -0
- package/dist/storage/webhook-runs/types.d.ts +66 -0
- package/dist/storage/webhook-runs/types.d.ts.map +1 -0
- package/dist/storage/workflow-interventions/errors.d.ts +7 -0
- package/dist/storage/workflow-interventions/errors.d.ts.map +1 -0
- package/dist/storage/workflow-interventions/in-memory.d.ts +18 -0
- package/dist/storage/workflow-interventions/in-memory.d.ts.map +1 -0
- package/dist/storage/workflow-interventions/index.d.ts +4 -0
- package/dist/storage/workflow-interventions/index.d.ts.map +1 -0
- package/dist/storage/workflow-interventions/types.d.ts +94 -0
- package/dist/storage/workflow-interventions/types.d.ts.map +1 -0
- package/dist/storage/workflow-runs/errors.d.ts +7 -0
- package/dist/storage/workflow-runs/errors.d.ts.map +1 -0
- package/dist/storage/workflow-runs/in-memory.d.ts +83 -0
- package/dist/storage/workflow-runs/in-memory.d.ts.map +1 -0
- package/dist/storage/workflow-runs/index.d.ts +4 -0
- package/dist/storage/workflow-runs/index.d.ts.map +1 -0
- package/dist/storage/workflow-runs/types.d.ts +305 -0
- package/dist/storage/workflow-runs/types.d.ts.map +1 -0
- package/dist/syncs/builders.d.ts +9 -0
- package/dist/syncs/builders.d.ts.map +1 -0
- package/dist/syncs/errors.d.ts +4 -0
- package/dist/syncs/errors.d.ts.map +1 -0
- package/dist/syncs/index.d.ts +7 -0
- package/dist/syncs/index.d.ts.map +1 -0
- package/dist/syncs/request.d.ts +41 -0
- package/dist/syncs/request.d.ts.map +1 -0
- package/dist/syncs/types.d.ts +76 -0
- package/dist/syncs/types.d.ts.map +1 -0
- package/dist/testing/agent-storage-contract.d.ts +16 -0
- package/dist/testing/agent-storage-contract.d.ts.map +1 -0
- package/dist/testing/auth-storage-contract.d.ts +16 -0
- package/dist/testing/auth-storage-contract.d.ts.map +1 -0
- package/dist/testing/blob-storage-contract.d.ts +10 -0
- package/dist/testing/blob-storage-contract.d.ts.map +1 -0
- package/dist/testing/broker-contract.d.ts +39 -0
- package/dist/testing/broker-contract.d.ts.map +1 -0
- package/dist/testing/effective-storage-contract.d.ts +7 -0
- package/dist/testing/effective-storage-contract.d.ts.map +1 -0
- package/dist/testing/index.d.ts +15 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +7000 -0
- package/dist/testing/index.js.map +24 -0
- package/dist/testing/lake-storage-contract.d.ts +29 -0
- package/dist/testing/lake-storage-contract.d.ts.map +1 -0
- package/dist/testing/materialization-failure-contract.d.ts +26 -0
- package/dist/testing/materialization-failure-contract.d.ts.map +1 -0
- package/dist/testing/materializer-fixture.d.ts +35 -0
- package/dist/testing/materializer-fixture.d.ts.map +1 -0
- package/dist/testing/materializer-storage-contract.d.ts +7 -0
- package/dist/testing/materializer-storage-contract.d.ts.map +1 -0
- package/dist/testing/object-query-contract.d.ts +21 -0
- package/dist/testing/object-query-contract.d.ts.map +1 -0
- package/dist/testing/ontology-contract-fixture.d.ts +33 -0
- package/dist/testing/ontology-contract-fixture.d.ts.map +1 -0
- package/dist/testing/ontology-storage-contract.d.ts +21 -0
- package/dist/testing/ontology-storage-contract.d.ts.map +1 -0
- package/dist/testing/projection-run-storage-contract.d.ts +10 -0
- package/dist/testing/projection-run-storage-contract.d.ts.map +1 -0
- package/dist/testing/queues-contract.d.ts +31 -0
- package/dist/testing/queues-contract.d.ts.map +1 -0
- package/dist/testing/sandboxes-contract.d.ts +31 -0
- package/dist/testing/sandboxes-contract.d.ts.map +1 -0
- package/dist/tsconfig.json +5 -0
- package/dist/webhooks/builders.d.ts +41 -0
- package/dist/webhooks/builders.d.ts.map +1 -0
- package/dist/webhooks/connector.d.ts +10 -0
- package/dist/webhooks/connector.d.ts.map +1 -0
- package/dist/webhooks/errors.d.ts +4 -0
- package/dist/webhooks/errors.d.ts.map +1 -0
- package/dist/webhooks/index.d.ts +9 -0
- package/dist/webhooks/index.d.ts.map +1 -0
- package/dist/webhooks/registry.d.ts +7 -0
- package/dist/webhooks/registry.d.ts.map +1 -0
- package/dist/webhooks/types.d.ts +79 -0
- package/dist/webhooks/types.d.ts.map +1 -0
- package/dist/webhooks/unverified.d.ts +57 -0
- package/dist/webhooks/unverified.d.ts.map +1 -0
- package/dist/workers/errors.d.ts +17 -0
- package/dist/workers/errors.d.ts.map +1 -0
- package/dist/workers/index.d.ts +7 -0
- package/dist/workers/index.d.ts.map +1 -0
- package/dist/workers/index.js +506 -0
- package/dist/workers/index.js.map +13 -0
- package/dist/workers/queue-delivery.d.ts +38 -0
- package/dist/workers/queue-delivery.d.ts.map +1 -0
- package/dist/workers/queue-worker.d.ts +30 -0
- package/dist/workers/queue-worker.d.ts.map +1 -0
- package/dist/workers/worker.d.ts +14 -0
- package/dist/workers/worker.d.ts.map +1 -0
- package/dist/workflows/builders.d.ts +27 -0
- package/dist/workflows/builders.d.ts.map +1 -0
- package/dist/workflows/errors.d.ts +11 -0
- package/dist/workflows/errors.d.ts.map +1 -0
- package/dist/workflows/index.d.ts +9 -0
- package/dist/workflows/index.d.ts.map +1 -0
- package/dist/workflows/index.js +108 -0
- package/dist/workflows/index.js.map +9 -0
- package/dist/workflows/request.d.ts +29 -0
- package/dist/workflows/request.d.ts.map +1 -0
- package/dist/workflows/runtime.d.ts +33 -0
- package/dist/workflows/runtime.d.ts.map +1 -0
- package/dist/workflows/snapshot.d.ts +55 -0
- package/dist/workflows/snapshot.d.ts.map +1 -0
- package/dist/workflows/types.d.ts +288 -0
- package/dist/workflows/types.d.ts.map +1 -0
- package/dist/workflows/validation.d.ts +66 -0
- package/dist/workflows/validation.d.ts.map +1 -0
- package/package.json +312 -0
- package/src/actions/builders/define-action.ts +243 -0
- package/src/actions/builders/params.ts +48 -0
- package/src/actions/builders.ts +2 -0
- package/src/actions/commit-edits.ts +110 -0
- package/src/actions/errors.ts +15 -0
- package/src/actions/index.ts +75 -0
- package/src/actions/read-facade.ts +224 -0
- package/src/actions/registry.ts +135 -0
- package/src/actions/request.ts +407 -0
- package/src/actions/run-id.ts +17 -0
- package/src/actions/runtime.ts +31 -0
- package/src/actions/types/context.ts +224 -0
- package/src/actions/types/definitions.ts +181 -0
- package/src/actions/types/handlers.ts +68 -0
- package/src/actions/types/params.ts +82 -0
- package/src/actions/types.ts +4 -0
- package/src/actions/validation.ts +186 -0
- package/src/actions/validators.ts +56 -0
- package/src/actions/worker.ts +2 -0
- package/src/agents/adapters.ts +647 -0
- package/src/agents/api-gateway.ts +57 -0
- package/src/agents/builders.ts +46 -0
- package/src/agents/context-model.ts +41 -0
- package/src/agents/context-resolution.ts +43 -0
- package/src/agents/context.ts +185 -0
- package/src/agents/dispatch.ts +107 -0
- package/src/agents/errors.ts +40 -0
- package/src/agents/ids.ts +24 -0
- package/src/agents/index.ts +122 -0
- package/src/agents/message.ts +91 -0
- package/src/agents/prompt.ts +45 -0
- package/src/agents/request.ts +198 -0
- package/src/agents/runtime.ts +124 -0
- package/src/agents/streams.ts +194 -0
- package/src/agents/types.ts +70 -0
- package/src/agents/validation.ts +151 -0
- package/src/auth/access-tokens.ts +125 -0
- package/src/auth/audience.ts +28 -0
- package/src/auth/cookies.ts +263 -0
- package/src/auth/csrf.ts +41 -0
- package/src/auth/errors.ts +19 -0
- package/src/auth/index.ts +149 -0
- package/src/auth/runtime.ts +1642 -0
- package/src/auth/session-cache.ts +112 -0
- package/src/auth/sessions.ts +55 -0
- package/src/auth/strategy.ts +46 -0
- package/src/auth/types.ts +573 -0
- package/src/auth/validation.ts +241 -0
- package/src/authorization/application-access.ts +34 -0
- package/src/authorization/decision.ts +215 -0
- package/src/authorization/errors.ts +12 -0
- package/src/authorization/event-visibility.ts +99 -0
- package/src/authorization/grant-kinds.ts +149 -0
- package/src/authorization/index.ts +24 -0
- package/src/authorization/resolve.ts +101 -0
- package/src/authorization/run-visibility.ts +78 -0
- package/src/authorization/types.ts +52 -0
- package/src/blob-storage/browser.ts +28 -0
- package/src/blob-storage/constants.ts +9 -0
- package/src/blob-storage/derive.ts +13 -0
- package/src/blob-storage/errors.ts +6 -0
- package/src/blob-storage/in-memory.ts +74 -0
- package/src/blob-storage/index.ts +37 -0
- package/src/blob-storage/types.ts +143 -0
- package/src/blob-storage/utils.ts +126 -0
- package/src/blob-storage/validation.ts +58 -0
- package/src/bootstrap/discovery.ts +507 -0
- package/src/bootstrap/index.ts +26 -0
- package/src/bootstrap/ontology-type-manifest.ts +316 -0
- package/src/broker/errors.ts +15 -0
- package/src/broker/in-memory.ts +511 -0
- package/src/broker/index.ts +12 -0
- package/src/broker/types.ts +129 -0
- package/src/connectors/builders.ts +33 -0
- package/src/connectors/errors.ts +15 -0
- package/src/connectors/index.ts +9 -0
- package/src/connectors/runtime.ts +100 -0
- package/src/connectors/types.ts +64 -0
- package/src/datasets/builders.ts +233 -0
- package/src/datasets/errors.ts +3 -0
- package/src/datasets/index.ts +13 -0
- package/src/datasets/types.ts +52 -0
- package/src/datasets/validation.ts +251 -0
- package/src/edits/errors.ts +6 -0
- package/src/edits/index.ts +24 -0
- package/src/edits/normalize.ts +87 -0
- package/src/edits/properties.ts +153 -0
- package/src/edits/recorder.ts +312 -0
- package/src/edits/types.ts +275 -0
- package/src/error-reporting/capability.ts +160 -0
- package/src/error-reporting/internal.ts +13 -0
- package/src/error-reporting/normalize.ts +35 -0
- package/src/error-reporting/reporter.ts +65 -0
- package/src/error-reporting/types.ts +125 -0
- package/src/events/definitions.ts +241 -0
- package/src/events/envelope.ts +68 -0
- package/src/events/errors.ts +7 -0
- package/src/events/index.ts +167 -0
- package/src/events/outbox-dispatcher.ts +534 -0
- package/src/events/property-changes.ts +9 -0
- package/src/events/runtime.ts +401 -0
- package/src/events/scope.ts +71 -0
- package/src/events/selectors/builder.ts +531 -0
- package/src/events/selectors/index.ts +42 -0
- package/src/events/selectors/predicate.ts +91 -0
- package/src/events/selectors/types.ts +258 -0
- package/src/events/toStoredEvent.ts +35 -0
- package/src/events/types/actions.ts +42 -0
- package/src/events/types/datasets.ts +21 -0
- package/src/events/types/index.ts +206 -0
- package/src/events/types/links.ts +42 -0
- package/src/events/types/objects.ts +38 -0
- package/src/events/types/pipelines.ts +67 -0
- package/src/events/types/rules.ts +31 -0
- package/src/events/types/schedules.ts +15 -0
- package/src/events/types/syncs.ts +27 -0
- package/src/events/types/telemetry.ts +19 -0
- package/src/events/types/workflows.ts +172 -0
- package/src/http/api-routes.ts +384 -0
- package/src/http/index.ts +3 -0
- package/src/http/route-pattern.ts +37 -0
- package/src/index.ts +916 -0
- package/src/json.ts +137 -0
- package/src/lake-storage/definition-updates.ts +263 -0
- package/src/lake-storage/errors.ts +6 -0
- package/src/lake-storage/in-memory.ts +348 -0
- package/src/lake-storage/index.ts +48 -0
- package/src/lake-storage/sql-transforms.ts +67 -0
- package/src/lake-storage/types.ts +135 -0
- package/src/logging/console-logger.ts +63 -0
- package/src/logging/index.ts +43 -0
- package/src/logging/record.ts +126 -0
- package/src/logging/run-logger.ts +350 -0
- package/src/logging/runtime.ts +341 -0
- package/src/logging/stream.ts +38 -0
- package/src/logging/types.ts +156 -0
- package/src/maintenance/index.ts +9 -0
- package/src/maintenance/ontology-maintenance.ts +351 -0
- package/src/maintenance/types.ts +57 -0
- package/src/materialization/dataset-watermark.ts +52 -0
- package/src/materialization/errors.ts +73 -0
- package/src/materialization/events.ts +92 -0
- package/src/materialization/identity.ts +36 -0
- package/src/materialization/index.ts +75 -0
- package/src/materialization/model.ts +394 -0
- package/src/materialization/refs.ts +134 -0
- package/src/materializer/README.md +130 -0
- package/src/materializer/context.ts +75 -0
- package/src/materializer/edits/apply.ts +241 -0
- package/src/materializer/edits/commit.ts +311 -0
- package/src/materializer/edits/execution-units.ts +32 -0
- package/src/materializer/edits/load-state.ts +148 -0
- package/src/materializer/edits/operations.ts +298 -0
- package/src/materializer/edits/plan.ts +192 -0
- package/src/materializer/edits/read-set.ts +79 -0
- package/src/materializer/edits/working-state.ts +171 -0
- package/src/materializer/effective/build-events.ts +197 -0
- package/src/materializer/effective/diff.ts +169 -0
- package/src/materializer/effective/load-state.ts +75 -0
- package/src/materializer/effective/resolve.ts +96 -0
- package/src/materializer/effective/validate.ts +180 -0
- package/src/materializer/execution/commit-lifecycle.ts +57 -0
- package/src/materializer/execution/plan-stream.ts +97 -0
- package/src/materializer/execution/run-correlation.ts +73 -0
- package/src/materializer/execution/work-executor.ts +143 -0
- package/src/materializer/execution/work-records.ts +186 -0
- package/src/materializer/index.ts +109 -0
- package/src/materializer/materializer.ts +64 -0
- package/src/materializer/projections/entry-validator.ts +162 -0
- package/src/materializer/projections/finish-run.ts +194 -0
- package/src/materializer/projections/replace.ts +447 -0
- package/src/materializer/projections/replacement-plan.ts +376 -0
- package/src/materializer/projections/source-materialization.ts +99 -0
- package/src/materializer/shared/abort.ts +7 -0
- package/src/materializer/shared/batching.ts +32 -0
- package/src/materializer/shared/chunking.ts +27 -0
- package/src/materializer/shared/identity.ts +141 -0
- package/src/materializer/shared/normalize.ts +527 -0
- package/src/materializer/shared/projection-run.ts +61 -0
- package/src/materializer/telemetry/append.ts +503 -0
- package/src/materializer/telemetry/plan.ts +363 -0
- package/src/objects/action/errors.ts +56 -0
- package/src/objects/action/index.ts +3 -0
- package/src/objects/action/request.ts +63 -0
- package/src/objects/context/index.ts +6 -0
- package/src/objects/context/resolve.ts +51 -0
- package/src/objects/context/types.ts +31 -0
- package/src/objects/contexts.ts +64 -0
- package/src/objects/errors.ts +7 -0
- package/src/objects/helpers.ts +18 -0
- package/src/objects/index.ts +26 -0
- package/src/objects/link/authorization.ts +26 -0
- package/src/objects/link/endpoints.ts +66 -0
- package/src/objects/link/index.ts +3 -0
- package/src/objects/link/remove.ts +42 -0
- package/src/objects/link/upsert-batch.ts +80 -0
- package/src/objects/link/upsert.ts +56 -0
- package/src/objects/materializer-adapter.ts +307 -0
- package/src/objects/object/delete.ts +47 -0
- package/src/objects/object/index.ts +3 -0
- package/src/objects/object/upsert-batch.ts +57 -0
- package/src/objects/object/upsert.ts +38 -0
- package/src/objects/query/errors.ts +55 -0
- package/src/objects/query/executor.ts +1345 -0
- package/src/objects/query/explain-format.ts +34 -0
- package/src/objects/query/explain.ts +215 -0
- package/src/objects/query/index.ts +77 -0
- package/src/objects/query/ir.ts +211 -0
- package/src/objects/query/normalize.ts +245 -0
- package/src/objects/query/planner.ts +538 -0
- package/src/objects/query/scalar-values.ts +100 -0
- package/src/objects/query/validate.ts +1276 -0
- package/src/objects/runtime-batch.ts +105 -0
- package/src/objects/sdk/index.ts +2 -0
- package/src/objects/sdk/object-handle.ts +139 -0
- package/src/objects/sdk/object-set.ts +224 -0
- package/src/objects/sdk/query-builder.ts +386 -0
- package/src/objects/sdk/query-executor.ts +62 -0
- package/src/objects/sdk/runtime-query-executor.ts +88 -0
- package/src/objects/sdk/telemetry-channel.ts +81 -0
- package/src/objects/sdk/where.ts +87 -0
- package/src/objects/service/action-service.ts +40 -0
- package/src/objects/service/index.ts +6 -0
- package/src/objects/service/link-service.ts +74 -0
- package/src/objects/service/list-service.ts +89 -0
- package/src/objects/service/object-service.ts +28 -0
- package/src/objects/service/telemetry-service.ts +17 -0
- package/src/objects/telemetry/append-batch.ts +74 -0
- package/src/objects/telemetry/history.ts +32 -0
- package/src/objects/telemetry/index.ts +4 -0
- package/src/objects/telemetry/write-batch.ts +52 -0
- package/src/ontology/builders.ts +695 -0
- package/src/ontology/decimal.ts +120 -0
- package/src/ontology/errors.ts +25 -0
- package/src/ontology/index.ts +80 -0
- package/src/ontology/inference/index.ts +215 -0
- package/src/ontology/internal.ts +3 -0
- package/src/ontology/json-schema.ts +123 -0
- package/src/ontology/refs.ts +80 -0
- package/src/ontology/registry.ts +417 -0
- package/src/ontology/tokens.ts +113 -0
- package/src/ontology/types.ts +436 -0
- package/src/ontology/units/index.ts +115 -0
- package/src/ontology/units/quantitative-types.ts +608 -0
- package/src/ontology/units/types.ts +27 -0
- package/src/ontology/validation/index.ts +36 -0
- package/src/ontology/validation/links.ts +126 -0
- package/src/ontology/validation/normalize.ts +215 -0
- package/src/ontology/validation/properties.ts +235 -0
- package/src/ontology/validation/query.ts +300 -0
- package/src/ontology/validation/schema.ts +174 -0
- package/src/ontology/validation/telemetry.ts +53 -0
- package/src/pipelines/builders.ts +155 -0
- package/src/pipelines/errors.ts +3 -0
- package/src/pipelines/index.ts +26 -0
- package/src/pipelines/request.ts +71 -0
- package/src/pipelines/types.ts +199 -0
- package/src/predicates/builders.ts +152 -0
- package/src/predicates/evaluate.ts +107 -0
- package/src/predicates/index.ts +28 -0
- package/src/predicates/types.ts +124 -0
- package/src/predicates/validation.ts +152 -0
- package/src/projections/builders.ts +770 -0
- package/src/projections/errors.ts +3 -0
- package/src/projections/index.ts +32 -0
- package/src/projections/internal.ts +75 -0
- package/src/projections/ownership.ts +134 -0
- package/src/projections/registry.ts +269 -0
- package/src/projections/revision.ts +245 -0
- package/src/projections/types.ts +165 -0
- package/src/projections/validation.ts +531 -0
- package/src/provider-scope.ts +11 -0
- package/src/query.ts +75 -0
- package/src/queues/errors.ts +6 -0
- package/src/queues/in-memory.ts +364 -0
- package/src/queues/index.ts +23 -0
- package/src/queues/types.ts +230 -0
- package/src/rules/builders.ts +126 -0
- package/src/rules/dependencies.ts +76 -0
- package/src/rules/errors.ts +11 -0
- package/src/rules/index.ts +30 -0
- package/src/rules/internal.ts +8 -0
- package/src/rules/types.ts +113 -0
- package/src/rules/validation.ts +153 -0
- package/src/runtime/create.ts +163 -0
- package/src/runtime/errors.ts +8 -0
- package/src/runtime/index.ts +67 -0
- package/src/runtime/internal.ts +7 -0
- package/src/runtime/ontology-mutations.ts +90 -0
- package/src/runtime/scoped.ts +436 -0
- package/src/runtime/sixb.ts +822 -0
- package/src/runtime/storage-readiness.ts +91 -0
- package/src/runtime/types.ts +1401 -0
- package/src/sandboxes/errors.ts +22 -0
- package/src/sandboxes/exec.ts +102 -0
- package/src/sandboxes/index.ts +19 -0
- package/src/sandboxes/sandbox.ts +124 -0
- package/src/scheduler/errors.ts +7 -0
- package/src/scheduler/index.ts +3 -0
- package/src/scheduler/runtime.ts +174 -0
- package/src/schedules/builders.ts +257 -0
- package/src/schedules/cron.ts +166 -0
- package/src/schedules/errors.ts +7 -0
- package/src/schedules/index.ts +44 -0
- package/src/schedules/next-occurrence.ts +217 -0
- package/src/schedules/runtime.ts +241 -0
- package/src/schedules/types.ts +212 -0
- package/src/schedules/validation.ts +398 -0
- package/src/security/applications.ts +11 -0
- package/src/security/builders.ts +128 -0
- package/src/security/errors.ts +3 -0
- package/src/security/every.ts +108 -0
- package/src/security/grants.ts +215 -0
- package/src/security/index.ts +51 -0
- package/src/security/membership-policies.ts +101 -0
- package/src/security/runtime.ts +101 -0
- package/src/security/types.ts +156 -0
- package/src/security/validation.ts +430 -0
- package/src/storage/action-runs/errors.ts +13 -0
- package/src/storage/action-runs/idempotency.ts +68 -0
- package/src/storage/action-runs/in-memory.ts +420 -0
- package/src/storage/action-runs/index.ts +31 -0
- package/src/storage/action-runs/types.ts +169 -0
- package/src/storage/agents/errors.ts +22 -0
- package/src/storage/agents/in-memory.ts +498 -0
- package/src/storage/agents/index.ts +42 -0
- package/src/storage/agents/types.ts +348 -0
- package/src/storage/auth/errors.ts +40 -0
- package/src/storage/auth/in-memory/access-tokens.ts +123 -0
- package/src/storage/auth/in-memory/auth-storage.ts +559 -0
- package/src/storage/auth/in-memory/group-memberships.ts +46 -0
- package/src/storage/auth/in-memory/identities.ts +66 -0
- package/src/storage/auth/in-memory/index.ts +1 -0
- package/src/storage/auth/in-memory/invitations.ts +165 -0
- package/src/storage/auth/in-memory/magic-links.ts +98 -0
- package/src/storage/auth/in-memory/oidc-attempts.ts +75 -0
- package/src/storage/auth/in-memory/service-account-group-memberships.ts +102 -0
- package/src/storage/auth/in-memory/service-accounts.ts +80 -0
- package/src/storage/auth/in-memory/sessions.ts +177 -0
- package/src/storage/auth/in-memory/shared.ts +602 -0
- package/src/storage/auth/in-memory/users.ts +139 -0
- package/src/storage/auth/in-memory.ts +1 -0
- package/src/storage/auth/index.ts +58 -0
- package/src/storage/auth/types.ts +639 -0
- package/src/storage/errors.ts +45 -0
- package/src/storage/file-upload-sessions/errors.ts +24 -0
- package/src/storage/file-upload-sessions/in-memory.ts +161 -0
- package/src/storage/file-upload-sessions/index.ts +19 -0
- package/src/storage/file-upload-sessions/types.ts +61 -0
- package/src/storage/file-upload-sessions/utils.ts +49 -0
- package/src/storage/in-memory/index.ts +297 -0
- package/src/storage/in-memory/testing.ts +21 -0
- package/src/storage/index.ts +489 -0
- package/src/storage/migrations/check-schema.ts +49 -0
- package/src/storage/migrations/index.ts +23 -0
- package/src/storage/migrations/migrate-storage.ts +24 -0
- package/src/storage/migrations/migration-set.ts +270 -0
- package/src/storage/migrations/types.ts +129 -0
- package/src/storage/objects/in-memory.ts +1154 -0
- package/src/storage/objects/index.ts +24 -0
- package/src/storage/objects/types.ts +244 -0
- package/src/storage/ontology/commits.ts +132 -0
- package/src/storage/ontology/in-memory/commits.ts +122 -0
- package/src/storage/ontology/in-memory/index.ts +94 -0
- package/src/storage/ontology/in-memory/materializations-finalization.ts +484 -0
- package/src/storage/ontology/in-memory/materializations-state.ts +183 -0
- package/src/storage/ontology/in-memory/materializations-work.ts +62 -0
- package/src/storage/ontology/in-memory/materializations.ts +1192 -0
- package/src/storage/ontology/in-memory/outbox.ts +227 -0
- package/src/storage/ontology/in-memory/shared-state.ts +161 -0
- package/src/storage/ontology/in-memory/sources.ts +566 -0
- package/src/storage/ontology/in-memory/testing.ts +29 -0
- package/src/storage/ontology/index.ts +119 -0
- package/src/storage/ontology/materializations.ts +414 -0
- package/src/storage/ontology/outbox.ts +79 -0
- package/src/storage/ontology/provider-header-validation.ts +173 -0
- package/src/storage/ontology/provider-validation.ts +36 -0
- package/src/storage/ontology/provider-work.ts +330 -0
- package/src/storage/ontology/provider.ts +852 -0
- package/src/storage/ontology/sources.ts +195 -0
- package/src/storage/operation-scope.ts +248 -0
- package/src/storage/pagination.ts +23 -0
- package/src/storage/pipeline-runs/errors.ts +6 -0
- package/src/storage/pipeline-runs/in-memory.ts +307 -0
- package/src/storage/pipeline-runs/index.ts +19 -0
- package/src/storage/pipeline-runs/types.ts +148 -0
- package/src/storage/projection-runs/errors.ts +15 -0
- package/src/storage/projection-runs/in-memory.ts +321 -0
- package/src/storage/projection-runs/index.ts +36 -0
- package/src/storage/projection-runs/lifecycle.ts +793 -0
- package/src/storage/projection-runs/types.ts +254 -0
- package/src/storage/rules/in-memory.ts +191 -0
- package/src/storage/rules/index.ts +12 -0
- package/src/storage/rules/types.ts +80 -0
- package/src/storage/run-listing.ts +107 -0
- package/src/storage/sync-runs/errors.ts +7 -0
- package/src/storage/sync-runs/in-memory.ts +181 -0
- package/src/storage/sync-runs/index.ts +14 -0
- package/src/storage/sync-runs/types.ts +93 -0
- package/src/storage/timeseries/index.ts +7 -0
- package/src/storage/timeseries/store.ts +214 -0
- package/src/storage/timeseries/types.ts +57 -0
- package/src/storage/transaction.ts +56 -0
- package/src/storage/types.ts +299 -0
- package/src/storage/webhook-deliveries/in-memory.ts +108 -0
- package/src/storage/webhook-deliveries/index.ts +9 -0
- package/src/storage/webhook-deliveries/types.ts +41 -0
- package/src/storage/webhook-runs/errors.ts +6 -0
- package/src/storage/webhook-runs/in-memory.ts +131 -0
- package/src/storage/webhook-runs/index.ts +12 -0
- package/src/storage/webhook-runs/types.ts +69 -0
- package/src/storage/workflow-interventions/errors.ts +6 -0
- package/src/storage/workflow-interventions/in-memory.ts +192 -0
- package/src/storage/workflow-interventions/index.ts +14 -0
- package/src/storage/workflow-interventions/types.ts +100 -0
- package/src/storage/workflow-runs/errors.ts +6 -0
- package/src/storage/workflow-runs/in-memory.ts +777 -0
- package/src/storage/workflow-runs/index.ts +45 -0
- package/src/storage/workflow-runs/types.ts +344 -0
- package/src/syncs/builders.ts +101 -0
- package/src/syncs/errors.ts +3 -0
- package/src/syncs/index.ts +22 -0
- package/src/syncs/request.ts +91 -0
- package/src/syncs/types.ts +136 -0
- package/src/testing/agent-storage-contract.ts +824 -0
- package/src/testing/auth-storage-contract.ts +1932 -0
- package/src/testing/blob-storage-contract.ts +108 -0
- package/src/testing/broker-contract.ts +819 -0
- package/src/testing/effective-storage-contract.ts +182 -0
- package/src/testing/index.ts +65 -0
- package/src/testing/lake-storage-contract.ts +699 -0
- package/src/testing/materialization-failure-contract.ts +66 -0
- package/src/testing/materializer-fixture.ts +119 -0
- package/src/testing/materializer-storage-contract.ts +389 -0
- package/src/testing/object-query-contract.ts +1205 -0
- package/src/testing/ontology-contract-fixture.ts +192 -0
- package/src/testing/ontology-storage-contract.ts +922 -0
- package/src/testing/projection-run-storage-contract.ts +372 -0
- package/src/testing/queues-contract.ts +634 -0
- package/src/testing/sandboxes-contract.ts +404 -0
- package/src/webhooks/builders.ts +154 -0
- package/src/webhooks/connector.ts +19 -0
- package/src/webhooks/errors.ts +3 -0
- package/src/webhooks/index.ts +25 -0
- package/src/webhooks/registry.ts +127 -0
- package/src/webhooks/types.ts +98 -0
- package/src/webhooks/unverified.ts +82 -0
- package/src/workers/errors.ts +25 -0
- package/src/workers/index.ts +6 -0
- package/src/workers/queue-delivery.ts +309 -0
- package/src/workers/queue-worker.ts +260 -0
- package/src/workers/worker.ts +87 -0
- package/src/workflows/builders.ts +471 -0
- package/src/workflows/errors.ts +13 -0
- package/src/workflows/index.ts +94 -0
- package/src/workflows/request.ts +161 -0
- package/src/workflows/runtime.ts +68 -0
- package/src/workflows/snapshot.ts +383 -0
- package/src/workflows/types.ts +781 -0
- package/src/workflows/validation.ts +572 -0
|
@@ -0,0 +1,1932 @@
|
|
|
1
|
+
import { describe, expect, test } from "bun:test"
|
|
2
|
+
import type {
|
|
3
|
+
AuthStorage,
|
|
4
|
+
AuthStorageErrorCode,
|
|
5
|
+
CompleteAuthSessionInput,
|
|
6
|
+
UserRecord,
|
|
7
|
+
} from "../storage/auth"
|
|
8
|
+
import { AuthStorageError } from "../storage/auth"
|
|
9
|
+
|
|
10
|
+
export interface AuthStorageContractSuiteOptions<TStorage extends AuthStorage = AuthStorage> {
|
|
11
|
+
/** Factory that produces a fresh `AuthStorage` instance for each test case. */
|
|
12
|
+
readonly createStorage: () => TStorage | Promise<TStorage>
|
|
13
|
+
/** Optional cleanup invoked after every test case. */
|
|
14
|
+
readonly teardown?: (storage: TStorage) => void | Promise<void>
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const projectId = "project-a"
|
|
18
|
+
const otherProjectId = "project-b"
|
|
19
|
+
|
|
20
|
+
function at(value: string): Date {
|
|
21
|
+
return new Date(value)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function sessionInput(
|
|
25
|
+
id: string,
|
|
26
|
+
tokenHash = `${id}-hash`,
|
|
27
|
+
audience: CompleteAuthSessionInput["audience"] = "atlas",
|
|
28
|
+
absoluteExpiresAt?: Date
|
|
29
|
+
): CompleteAuthSessionInput {
|
|
30
|
+
return {
|
|
31
|
+
id,
|
|
32
|
+
audience,
|
|
33
|
+
tokenHash,
|
|
34
|
+
createdAt: at("2026-05-14T10:10:00.000Z"),
|
|
35
|
+
expiresAt: at("2026-05-21T10:10:00.000Z"),
|
|
36
|
+
absoluteExpiresAt,
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
async function expectAuthError(
|
|
41
|
+
promise: Promise<unknown>,
|
|
42
|
+
code: AuthStorageErrorCode
|
|
43
|
+
): Promise<void> {
|
|
44
|
+
await expect(promise).rejects.toBeInstanceOf(AuthStorageError)
|
|
45
|
+
await expect(promise).rejects.toMatchObject({ code })
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
async function createUser(
|
|
49
|
+
storage: AuthStorage,
|
|
50
|
+
input: {
|
|
51
|
+
readonly id?: string
|
|
52
|
+
readonly email?: string
|
|
53
|
+
readonly status?: UserRecord["status"]
|
|
54
|
+
readonly projectId?: string
|
|
55
|
+
} = {}
|
|
56
|
+
): Promise<UserRecord> {
|
|
57
|
+
return storage.users.create({
|
|
58
|
+
id: input.id ?? "usr_1",
|
|
59
|
+
projectId: input.projectId ?? projectId,
|
|
60
|
+
email: input.email ?? "ava@acme.com",
|
|
61
|
+
status: input.status,
|
|
62
|
+
createdAt: at("2026-05-14T10:00:00.000Z"),
|
|
63
|
+
})
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Runs the shared `AuthStorage` contract against any storage implementation.
|
|
68
|
+
*
|
|
69
|
+
* The suite is the storage-independent specification for Sixb auth state: users, identities,
|
|
70
|
+
* sessions, invitations, group memberships, service accounts, access tokens,
|
|
71
|
+
* magic links, OIDC attempts, and atomic sign-in completion.
|
|
72
|
+
*/
|
|
73
|
+
export function runAuthStorageContractSuite<TStorage extends AuthStorage>(
|
|
74
|
+
label: string,
|
|
75
|
+
options: AuthStorageContractSuiteOptions<TStorage>
|
|
76
|
+
): void {
|
|
77
|
+
const withStorage = async (body: (storage: TStorage) => Promise<void>): Promise<void> => {
|
|
78
|
+
const storage = await options.createStorage()
|
|
79
|
+
try {
|
|
80
|
+
await body(storage)
|
|
81
|
+
} finally {
|
|
82
|
+
await options.teardown?.(storage)
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
describe(label, () => {
|
|
87
|
+
test("creates users with normalized email and isolates projects", async () => {
|
|
88
|
+
await withStorage(async (storage) => {
|
|
89
|
+
const user = await createUser(storage, {
|
|
90
|
+
email: " Ava@Acme.COM ",
|
|
91
|
+
})
|
|
92
|
+
|
|
93
|
+
expect(user.email).toBe("ava@acme.com")
|
|
94
|
+
await expectAuthError(
|
|
95
|
+
storage.users.create({
|
|
96
|
+
id: "usr_duplicate",
|
|
97
|
+
projectId,
|
|
98
|
+
email: "ava@acme.com",
|
|
99
|
+
createdAt: at("2026-05-14T10:01:00.000Z"),
|
|
100
|
+
}),
|
|
101
|
+
"duplicate_user"
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
await expect(
|
|
105
|
+
storage.users.create({
|
|
106
|
+
id: "usr_other",
|
|
107
|
+
projectId: otherProjectId,
|
|
108
|
+
email: "ava@acme.com",
|
|
109
|
+
createdAt: at("2026-05-14T10:02:00.000Z"),
|
|
110
|
+
})
|
|
111
|
+
).resolves.toMatchObject({
|
|
112
|
+
projectId: otherProjectId,
|
|
113
|
+
email: "ava@acme.com",
|
|
114
|
+
})
|
|
115
|
+
|
|
116
|
+
const page = await storage.users.list({ projectId, statuses: ["active"] })
|
|
117
|
+
expect(page.users.map((row) => row.id)).toEqual(["usr_1"])
|
|
118
|
+
})
|
|
119
|
+
})
|
|
120
|
+
|
|
121
|
+
test("upserts identities without mutating canonical user email", async () => {
|
|
122
|
+
await withStorage(async (storage) => {
|
|
123
|
+
await createUser(storage, { id: "usr_oidc", email: "ava@acme.com" })
|
|
124
|
+
|
|
125
|
+
await storage.identities.upsert({
|
|
126
|
+
projectId,
|
|
127
|
+
strategyId: "okta",
|
|
128
|
+
subject: "00u1",
|
|
129
|
+
userId: "usr_oidc",
|
|
130
|
+
claims: { email: "ava@acme.com" },
|
|
131
|
+
createdAt: at("2026-05-14T10:01:00.000Z"),
|
|
132
|
+
})
|
|
133
|
+
const updated = await storage.identities.upsert({
|
|
134
|
+
projectId,
|
|
135
|
+
strategyId: "okta",
|
|
136
|
+
subject: "00u1",
|
|
137
|
+
userId: "usr_oidc",
|
|
138
|
+
claims: { email: "ava.renamed@acme.com" },
|
|
139
|
+
updatedAt: at("2026-05-14T10:02:00.000Z"),
|
|
140
|
+
})
|
|
141
|
+
|
|
142
|
+
expect(updated.claims).toEqual({ email: "ava.renamed@acme.com" })
|
|
143
|
+
await expect(storage.users.getById({ projectId, id: "usr_oidc" })).resolves.toMatchObject({
|
|
144
|
+
email: "ava@acme.com",
|
|
145
|
+
})
|
|
146
|
+
})
|
|
147
|
+
})
|
|
148
|
+
|
|
149
|
+
test("keeps multiple concurrent sessions per user and never extends expiry on touch", async () => {
|
|
150
|
+
await withStorage(async (storage) => {
|
|
151
|
+
await createUser(storage)
|
|
152
|
+
|
|
153
|
+
const first = await storage.sessions.create({
|
|
154
|
+
id: "ses_1",
|
|
155
|
+
projectId,
|
|
156
|
+
userId: "usr_1",
|
|
157
|
+
strategyId: "magic-link",
|
|
158
|
+
audience: "atlas",
|
|
159
|
+
tokenHash: "hash-1",
|
|
160
|
+
createdAt: at("2026-05-14T10:00:00.000Z"),
|
|
161
|
+
expiresAt: at("2026-05-21T10:00:00.000Z"),
|
|
162
|
+
})
|
|
163
|
+
const second = await storage.sessions.create({
|
|
164
|
+
id: "ses_2",
|
|
165
|
+
projectId,
|
|
166
|
+
userId: "usr_1",
|
|
167
|
+
strategyId: "magic-link",
|
|
168
|
+
audience: "atlas",
|
|
169
|
+
tokenHash: "hash-2",
|
|
170
|
+
createdAt: at("2026-05-14T10:05:00.000Z"),
|
|
171
|
+
expiresAt: at("2026-05-21T10:05:00.000Z"),
|
|
172
|
+
})
|
|
173
|
+
|
|
174
|
+
// Creating a second session in the same audience no longer revokes the
|
|
175
|
+
// first: both stay active and authenticate independently.
|
|
176
|
+
expect(first.revokedAt).toBeUndefined()
|
|
177
|
+
expect(second.revokedAt).toBeUndefined()
|
|
178
|
+
const storedFirst = await storage.sessions.getById({ projectId, id: "ses_1" })
|
|
179
|
+
expect(storedFirst?.revokedAt).toBeUndefined()
|
|
180
|
+
|
|
181
|
+
await expect(
|
|
182
|
+
storage.sessions.findValidByTokenHash({
|
|
183
|
+
projectId,
|
|
184
|
+
id: "ses_1",
|
|
185
|
+
audience: "atlas",
|
|
186
|
+
tokenHash: "hash-1",
|
|
187
|
+
now: at("2026-05-14T10:06:00.000Z"),
|
|
188
|
+
})
|
|
189
|
+
).resolves.toMatchObject({ id: "ses_1" })
|
|
190
|
+
await expect(
|
|
191
|
+
storage.sessions.findValidByTokenHash({
|
|
192
|
+
projectId,
|
|
193
|
+
id: "ses_2",
|
|
194
|
+
audience: "atlas",
|
|
195
|
+
tokenHash: "hash-2",
|
|
196
|
+
now: at("2026-05-14T10:06:00.000Z"),
|
|
197
|
+
})
|
|
198
|
+
).resolves.toMatchObject({ id: "ses_2" })
|
|
199
|
+
await expect(
|
|
200
|
+
storage.sessions.findValidByTokenHash({
|
|
201
|
+
projectId,
|
|
202
|
+
id: "ses_2",
|
|
203
|
+
audience: "atlas",
|
|
204
|
+
tokenHash: "wrong",
|
|
205
|
+
now: at("2026-05-14T10:06:00.000Z"),
|
|
206
|
+
})
|
|
207
|
+
).resolves.toBeNull()
|
|
208
|
+
|
|
209
|
+
// getActiveByUserId returns the most recently created active session.
|
|
210
|
+
await expect(
|
|
211
|
+
storage.sessions.getActiveByUserId({
|
|
212
|
+
projectId,
|
|
213
|
+
userId: "usr_1",
|
|
214
|
+
audience: "atlas",
|
|
215
|
+
now: at("2026-05-14T10:06:00.000Z"),
|
|
216
|
+
})
|
|
217
|
+
).resolves.toMatchObject({ id: "ses_2" })
|
|
218
|
+
|
|
219
|
+
const touched = await storage.sessions.touch({
|
|
220
|
+
projectId,
|
|
221
|
+
id: second.id,
|
|
222
|
+
lastSeenAt: at("2026-05-15T10:00:00.000Z"),
|
|
223
|
+
})
|
|
224
|
+
expect(touched.lastSeenAt?.toISOString()).toBe("2026-05-15T10:00:00.000Z")
|
|
225
|
+
expect(touched.expiresAt.toISOString()).toBe("2026-05-21T10:05:00.000Z")
|
|
226
|
+
|
|
227
|
+
// A session in a different audience coexists and is cookie-scoped.
|
|
228
|
+
const appSession = await storage.sessions.create({
|
|
229
|
+
id: "ses_app",
|
|
230
|
+
projectId,
|
|
231
|
+
userId: "usr_1",
|
|
232
|
+
strategyId: "magic-link",
|
|
233
|
+
audience: "app",
|
|
234
|
+
tokenHash: "hash-app",
|
|
235
|
+
createdAt: at("2026-05-14T10:06:00.000Z"),
|
|
236
|
+
expiresAt: at("2026-05-21T10:06:00.000Z"),
|
|
237
|
+
})
|
|
238
|
+
expect(appSession.revokedAt).toBeUndefined()
|
|
239
|
+
await expect(
|
|
240
|
+
storage.sessions.findValidByTokenHash({
|
|
241
|
+
projectId,
|
|
242
|
+
id: "ses_app",
|
|
243
|
+
audience: "atlas",
|
|
244
|
+
tokenHash: "hash-app",
|
|
245
|
+
now: at("2026-05-14T10:07:00.000Z"),
|
|
246
|
+
})
|
|
247
|
+
).resolves.toBeNull()
|
|
248
|
+
|
|
249
|
+
// Revoking a single session leaves the user's other sessions active.
|
|
250
|
+
await storage.sessions.revoke({
|
|
251
|
+
projectId,
|
|
252
|
+
id: "ses_1",
|
|
253
|
+
revokedAt: at("2026-05-14T10:08:00.000Z"),
|
|
254
|
+
})
|
|
255
|
+
await expect(
|
|
256
|
+
storage.sessions.findValidByTokenHash({
|
|
257
|
+
projectId,
|
|
258
|
+
id: "ses_1",
|
|
259
|
+
audience: "atlas",
|
|
260
|
+
tokenHash: "hash-1",
|
|
261
|
+
now: at("2026-05-14T10:09:00.000Z"),
|
|
262
|
+
})
|
|
263
|
+
).resolves.toBeNull()
|
|
264
|
+
await expect(
|
|
265
|
+
storage.sessions.findValidByTokenHash({
|
|
266
|
+
projectId,
|
|
267
|
+
id: "ses_2",
|
|
268
|
+
audience: "atlas",
|
|
269
|
+
tokenHash: "hash-2",
|
|
270
|
+
now: at("2026-05-14T10:09:00.000Z"),
|
|
271
|
+
})
|
|
272
|
+
).resolves.toMatchObject({ id: "ses_2" })
|
|
273
|
+
|
|
274
|
+
// "Sign out everywhere": revokeActiveForUser clears every remaining
|
|
275
|
+
// active session for the user, across audiences.
|
|
276
|
+
const revoked = await storage.sessions.revokeActiveForUser({
|
|
277
|
+
projectId,
|
|
278
|
+
userId: "usr_1",
|
|
279
|
+
revokedAt: at("2026-05-14T10:10:00.000Z"),
|
|
280
|
+
})
|
|
281
|
+
expect(revoked.map((entry) => entry.id).sort()).toEqual(["ses_2", "ses_app"])
|
|
282
|
+
await expect(
|
|
283
|
+
storage.sessions.getActiveByUserId({
|
|
284
|
+
projectId,
|
|
285
|
+
userId: "usr_1",
|
|
286
|
+
audience: "atlas",
|
|
287
|
+
now: at("2026-05-14T10:11:00.000Z"),
|
|
288
|
+
})
|
|
289
|
+
).resolves.toBeNull()
|
|
290
|
+
})
|
|
291
|
+
})
|
|
292
|
+
|
|
293
|
+
test("persists and enforces an optional absolute session deadline", async () => {
|
|
294
|
+
await withStorage(async (storage) => {
|
|
295
|
+
await createUser(storage)
|
|
296
|
+
const capped = await storage.sessions.create({
|
|
297
|
+
id: "ses_capped",
|
|
298
|
+
projectId,
|
|
299
|
+
userId: "usr_1",
|
|
300
|
+
strategyId: "magic-link",
|
|
301
|
+
audience: "atlas",
|
|
302
|
+
tokenHash: "hash-capped",
|
|
303
|
+
createdAt: at("2026-05-14T10:00:00.000Z"),
|
|
304
|
+
expiresAt: at("2026-05-21T10:00:00.000Z"),
|
|
305
|
+
absoluteExpiresAt: at("2026-05-16T10:00:00.000Z"),
|
|
306
|
+
})
|
|
307
|
+
const uncapped = await storage.sessions.create({
|
|
308
|
+
id: "ses-uncapped",
|
|
309
|
+
projectId,
|
|
310
|
+
userId: "usr_1",
|
|
311
|
+
strategyId: "magic-link",
|
|
312
|
+
audience: "app",
|
|
313
|
+
tokenHash: "hash-uncapped",
|
|
314
|
+
createdAt: at("2026-05-14T10:01:00.000Z"),
|
|
315
|
+
expiresAt: at("2026-05-21T10:01:00.000Z"),
|
|
316
|
+
})
|
|
317
|
+
|
|
318
|
+
expect(capped.absoluteExpiresAt?.toISOString()).toBe("2026-05-16T10:00:00.000Z")
|
|
319
|
+
expect(uncapped.absoluteExpiresAt).toBeUndefined()
|
|
320
|
+
await expect(
|
|
321
|
+
storage.sessions.findValidByTokenHash({
|
|
322
|
+
projectId,
|
|
323
|
+
id: capped.id,
|
|
324
|
+
audience: "atlas",
|
|
325
|
+
tokenHash: "hash-capped",
|
|
326
|
+
now: at("2026-05-16T09:59:59.999Z"),
|
|
327
|
+
})
|
|
328
|
+
).resolves.toMatchObject({ id: capped.id })
|
|
329
|
+
await expect(
|
|
330
|
+
storage.sessions.findValidByTokenHash({
|
|
331
|
+
projectId,
|
|
332
|
+
id: capped.id,
|
|
333
|
+
audience: "atlas",
|
|
334
|
+
tokenHash: "hash-capped",
|
|
335
|
+
now: at("2026-05-16T10:00:00.000Z"),
|
|
336
|
+
})
|
|
337
|
+
).resolves.toBeNull()
|
|
338
|
+
const active = await storage.sessions.listActiveByUserId({
|
|
339
|
+
projectId,
|
|
340
|
+
userId: "usr_1",
|
|
341
|
+
now: at("2026-05-16T10:00:00.000Z"),
|
|
342
|
+
})
|
|
343
|
+
expect(active.map((session) => session.id)).toEqual([uncapped.id])
|
|
344
|
+
await expect(
|
|
345
|
+
storage.sessions.getActiveByUserId({
|
|
346
|
+
projectId,
|
|
347
|
+
userId: "usr_1",
|
|
348
|
+
audience: "atlas",
|
|
349
|
+
now: at("2026-05-16T10:00:00.000Z"),
|
|
350
|
+
})
|
|
351
|
+
).resolves.toBeNull()
|
|
352
|
+
await expect(
|
|
353
|
+
storage.sessions.revokeActiveForUser({
|
|
354
|
+
projectId,
|
|
355
|
+
userId: "usr_1",
|
|
356
|
+
audience: "atlas",
|
|
357
|
+
revokedAt: at("2026-05-16T10:00:00.000Z"),
|
|
358
|
+
})
|
|
359
|
+
).resolves.toEqual([])
|
|
360
|
+
})
|
|
361
|
+
})
|
|
362
|
+
|
|
363
|
+
test("atomically renews valid sessions without exceeding the absolute deadline", async () => {
|
|
364
|
+
await withStorage(async (storage) => {
|
|
365
|
+
await createUser(storage)
|
|
366
|
+
await storage.sessions.create({
|
|
367
|
+
id: "ses_renew",
|
|
368
|
+
projectId,
|
|
369
|
+
userId: "usr_1",
|
|
370
|
+
strategyId: "magic-link",
|
|
371
|
+
audience: "atlas",
|
|
372
|
+
tokenHash: "hash-renew",
|
|
373
|
+
createdAt: at("2026-05-14T10:00:00.000Z"),
|
|
374
|
+
expiresAt: at("2026-05-15T10:00:00.000Z"),
|
|
375
|
+
absoluteExpiresAt: at("2026-05-20T10:00:00.000Z"),
|
|
376
|
+
})
|
|
377
|
+
|
|
378
|
+
const renewed = await storage.sessions.renewIfValid({
|
|
379
|
+
projectId,
|
|
380
|
+
id: "ses_renew",
|
|
381
|
+
audience: "atlas",
|
|
382
|
+
tokenHash: "hash-renew",
|
|
383
|
+
now: at("2026-05-14T11:00:00.000Z"),
|
|
384
|
+
expiresAt: at("2026-05-25T10:00:00.000Z"),
|
|
385
|
+
})
|
|
386
|
+
expect(renewed?.expiresAt.toISOString()).toBe("2026-05-20T10:00:00.000Z")
|
|
387
|
+
expect(renewed?.lastSeenAt?.toISOString()).toBe("2026-05-14T11:00:00.000Z")
|
|
388
|
+
|
|
389
|
+
const monotonic = await storage.sessions.renewIfValid({
|
|
390
|
+
projectId,
|
|
391
|
+
id: "ses_renew",
|
|
392
|
+
audience: "atlas",
|
|
393
|
+
tokenHash: "hash-renew",
|
|
394
|
+
now: at("2026-05-14T12:00:00.000Z"),
|
|
395
|
+
expiresAt: at("2026-05-18T10:00:00.000Z"),
|
|
396
|
+
})
|
|
397
|
+
expect(monotonic?.expiresAt.toISOString()).toBe("2026-05-20T10:00:00.000Z")
|
|
398
|
+
|
|
399
|
+
await expect(
|
|
400
|
+
storage.sessions.renewIfValid({
|
|
401
|
+
projectId,
|
|
402
|
+
id: "ses_renew",
|
|
403
|
+
audience: "atlas",
|
|
404
|
+
tokenHash: "wrong-hash",
|
|
405
|
+
now: at("2026-05-14T13:00:00.000Z"),
|
|
406
|
+
expiresAt: at("2026-05-19T10:00:00.000Z"),
|
|
407
|
+
})
|
|
408
|
+
).resolves.toBeNull()
|
|
409
|
+
await expect(
|
|
410
|
+
storage.sessions.renewIfValid({
|
|
411
|
+
projectId,
|
|
412
|
+
id: "ses_renew",
|
|
413
|
+
audience: "atlas",
|
|
414
|
+
tokenHash: "hash-renew",
|
|
415
|
+
now: at("2026-05-20T10:00:00.000Z"),
|
|
416
|
+
expiresAt: at("2026-05-21T10:00:00.000Z"),
|
|
417
|
+
})
|
|
418
|
+
).resolves.toBeNull()
|
|
419
|
+
|
|
420
|
+
await storage.sessions.create({
|
|
421
|
+
id: "ses_concurrent",
|
|
422
|
+
projectId,
|
|
423
|
+
userId: "usr_1",
|
|
424
|
+
strategyId: "magic-link",
|
|
425
|
+
audience: "atlas",
|
|
426
|
+
tokenHash: "hash-concurrent",
|
|
427
|
+
createdAt: at("2026-05-14T10:00:00.000Z"),
|
|
428
|
+
expiresAt: at("2026-05-15T10:00:00.000Z"),
|
|
429
|
+
})
|
|
430
|
+
await Promise.all([
|
|
431
|
+
storage.sessions.renewIfValid({
|
|
432
|
+
projectId,
|
|
433
|
+
id: "ses_concurrent",
|
|
434
|
+
audience: "atlas",
|
|
435
|
+
tokenHash: "hash-concurrent",
|
|
436
|
+
now: at("2026-05-14T11:00:00.000Z"),
|
|
437
|
+
expiresAt: at("2026-05-18T10:00:00.000Z"),
|
|
438
|
+
}),
|
|
439
|
+
storage.sessions.renewIfValid({
|
|
440
|
+
projectId,
|
|
441
|
+
id: "ses_concurrent",
|
|
442
|
+
audience: "atlas",
|
|
443
|
+
tokenHash: "hash-concurrent",
|
|
444
|
+
now: at("2026-05-14T11:00:00.000Z"),
|
|
445
|
+
expiresAt: at("2026-05-19T10:00:00.000Z"),
|
|
446
|
+
}),
|
|
447
|
+
])
|
|
448
|
+
const concurrent = await storage.sessions.getById({ projectId, id: "ses_concurrent" })
|
|
449
|
+
expect(concurrent?.expiresAt.toISOString()).toBe("2026-05-19T10:00:00.000Z")
|
|
450
|
+
})
|
|
451
|
+
})
|
|
452
|
+
|
|
453
|
+
test("persists best-effort device metadata on a session", async () => {
|
|
454
|
+
await withStorage(async (storage) => {
|
|
455
|
+
await createUser(storage)
|
|
456
|
+
|
|
457
|
+
const withDevice = await storage.sessions.create({
|
|
458
|
+
id: "ses_device",
|
|
459
|
+
projectId,
|
|
460
|
+
userId: "usr_1",
|
|
461
|
+
strategyId: "magic-link",
|
|
462
|
+
audience: "atlas",
|
|
463
|
+
tokenHash: "hash-device",
|
|
464
|
+
createdAt: at("2026-05-14T10:00:00.000Z"),
|
|
465
|
+
expiresAt: at("2026-05-21T10:00:00.000Z"),
|
|
466
|
+
userAgent: "Mozilla/5.0 (iPhone)",
|
|
467
|
+
ipAddress: "203.0.113.7",
|
|
468
|
+
})
|
|
469
|
+
expect(withDevice.userAgent).toBe("Mozilla/5.0 (iPhone)")
|
|
470
|
+
expect(withDevice.ipAddress).toBe("203.0.113.7")
|
|
471
|
+
await expect(
|
|
472
|
+
storage.sessions.getById({ projectId, id: "ses_device" })
|
|
473
|
+
).resolves.toMatchObject({
|
|
474
|
+
userAgent: "Mozilla/5.0 (iPhone)",
|
|
475
|
+
ipAddress: "203.0.113.7",
|
|
476
|
+
})
|
|
477
|
+
|
|
478
|
+
// Device metadata is optional; omitting it round-trips as undefined.
|
|
479
|
+
const withoutDevice = await storage.sessions.create({
|
|
480
|
+
id: "ses_plain",
|
|
481
|
+
projectId,
|
|
482
|
+
userId: "usr_1",
|
|
483
|
+
strategyId: "magic-link",
|
|
484
|
+
audience: "atlas",
|
|
485
|
+
tokenHash: "hash-plain",
|
|
486
|
+
createdAt: at("2026-05-14T10:01:00.000Z"),
|
|
487
|
+
expiresAt: at("2026-05-21T10:01:00.000Z"),
|
|
488
|
+
})
|
|
489
|
+
expect(withoutDevice.userAgent).toBeUndefined()
|
|
490
|
+
expect(withoutDevice.ipAddress).toBeUndefined()
|
|
491
|
+
})
|
|
492
|
+
})
|
|
493
|
+
|
|
494
|
+
test("lists a user's active sessions across audiences, newest activity first", async () => {
|
|
495
|
+
await withStorage(async (storage) => {
|
|
496
|
+
await createUser(storage)
|
|
497
|
+
|
|
498
|
+
await storage.sessions.create({
|
|
499
|
+
id: "ses_a",
|
|
500
|
+
projectId,
|
|
501
|
+
userId: "usr_1",
|
|
502
|
+
strategyId: "magic-link",
|
|
503
|
+
audience: "atlas",
|
|
504
|
+
tokenHash: "hash-a",
|
|
505
|
+
createdAt: at("2026-05-14T10:00:00.000Z"),
|
|
506
|
+
expiresAt: at("2026-05-21T10:00:00.000Z"),
|
|
507
|
+
})
|
|
508
|
+
await storage.sessions.create({
|
|
509
|
+
id: "ses_b",
|
|
510
|
+
projectId,
|
|
511
|
+
userId: "usr_1",
|
|
512
|
+
strategyId: "magic-link",
|
|
513
|
+
audience: "app",
|
|
514
|
+
tokenHash: "hash-b",
|
|
515
|
+
createdAt: at("2026-05-14T10:05:00.000Z"),
|
|
516
|
+
expiresAt: at("2026-05-21T10:05:00.000Z"),
|
|
517
|
+
})
|
|
518
|
+
|
|
519
|
+
// Revoked sessions are excluded.
|
|
520
|
+
await storage.sessions.create({
|
|
521
|
+
id: "ses_revoked",
|
|
522
|
+
projectId,
|
|
523
|
+
userId: "usr_1",
|
|
524
|
+
strategyId: "magic-link",
|
|
525
|
+
audience: "atlas",
|
|
526
|
+
tokenHash: "hash-revoked",
|
|
527
|
+
createdAt: at("2026-05-14T10:01:00.000Z"),
|
|
528
|
+
expiresAt: at("2026-05-21T10:01:00.000Z"),
|
|
529
|
+
})
|
|
530
|
+
await storage.sessions.revoke({
|
|
531
|
+
projectId,
|
|
532
|
+
id: "ses_revoked",
|
|
533
|
+
revokedAt: at("2026-05-14T10:02:00.000Z"),
|
|
534
|
+
})
|
|
535
|
+
|
|
536
|
+
// Another user's session must not leak in.
|
|
537
|
+
await createUser(storage, { id: "usr_2", email: "bo@acme.com" })
|
|
538
|
+
await storage.sessions.create({
|
|
539
|
+
id: "ses_other",
|
|
540
|
+
projectId,
|
|
541
|
+
userId: "usr_2",
|
|
542
|
+
strategyId: "magic-link",
|
|
543
|
+
audience: "atlas",
|
|
544
|
+
tokenHash: "hash-other",
|
|
545
|
+
createdAt: at("2026-05-14T10:03:00.000Z"),
|
|
546
|
+
expiresAt: at("2026-05-21T10:03:00.000Z"),
|
|
547
|
+
})
|
|
548
|
+
|
|
549
|
+
// ses_a is older than ses_b but has more recent activity, so it sorts first.
|
|
550
|
+
await storage.sessions.touch({
|
|
551
|
+
projectId,
|
|
552
|
+
id: "ses_a",
|
|
553
|
+
lastSeenAt: at("2026-05-15T10:00:00.000Z"),
|
|
554
|
+
})
|
|
555
|
+
|
|
556
|
+
const active = await storage.sessions.listActiveByUserId({
|
|
557
|
+
projectId,
|
|
558
|
+
userId: "usr_1",
|
|
559
|
+
now: at("2026-05-15T11:00:00.000Z"),
|
|
560
|
+
})
|
|
561
|
+
expect(active.map((session) => session.id)).toEqual(["ses_a", "ses_b"])
|
|
562
|
+
})
|
|
563
|
+
})
|
|
564
|
+
|
|
565
|
+
test("keeps one active invitation per normalized email", async () => {
|
|
566
|
+
await withStorage(async (storage) => {
|
|
567
|
+
const first = await storage.invitations.createOrUpdateActive({
|
|
568
|
+
id: "inv_1",
|
|
569
|
+
projectId,
|
|
570
|
+
email: " Ava@Acme.COM ",
|
|
571
|
+
groupIds: ["commercial"],
|
|
572
|
+
createdAt: at("2026-05-14T10:00:00.000Z"),
|
|
573
|
+
expiresAt: at("2026-05-21T10:00:00.000Z"),
|
|
574
|
+
})
|
|
575
|
+
const updated = await storage.invitations.createOrUpdateActive({
|
|
576
|
+
id: "inv_2",
|
|
577
|
+
projectId,
|
|
578
|
+
email: "ava@acme.com",
|
|
579
|
+
groupIds: ["finance"],
|
|
580
|
+
updatedAt: at("2026-05-14T10:01:00.000Z"),
|
|
581
|
+
expiresAt: at("2026-05-22T10:00:00.000Z"),
|
|
582
|
+
})
|
|
583
|
+
|
|
584
|
+
expect(updated.id).toBe(first.id)
|
|
585
|
+
expect(updated.groupIds).toEqual(["finance"])
|
|
586
|
+
await expect(
|
|
587
|
+
storage.invitations.getActiveByEmail({
|
|
588
|
+
projectId,
|
|
589
|
+
email: "ava@acme.com",
|
|
590
|
+
now: at("2026-05-14T10:02:00.000Z"),
|
|
591
|
+
})
|
|
592
|
+
).resolves.toMatchObject({ id: "inv_1" })
|
|
593
|
+
|
|
594
|
+
await storage.invitations.revoke({
|
|
595
|
+
projectId,
|
|
596
|
+
id: "inv_1",
|
|
597
|
+
revokedAt: at("2026-05-14T10:03:00.000Z"),
|
|
598
|
+
})
|
|
599
|
+
await expect(
|
|
600
|
+
storage.invitations.getActiveByEmail({
|
|
601
|
+
projectId,
|
|
602
|
+
email: "ava@acme.com",
|
|
603
|
+
now: at("2026-05-14T10:04:00.000Z"),
|
|
604
|
+
})
|
|
605
|
+
).resolves.toBeNull()
|
|
606
|
+
})
|
|
607
|
+
})
|
|
608
|
+
|
|
609
|
+
test("upserts group memberships idempotently and preserves source", async () => {
|
|
610
|
+
await withStorage(async (storage) => {
|
|
611
|
+
await createUser(storage)
|
|
612
|
+
|
|
613
|
+
await storage.groupMemberships.upsert({
|
|
614
|
+
projectId,
|
|
615
|
+
userId: "usr_1",
|
|
616
|
+
groupId: "commercial",
|
|
617
|
+
source: "invitation",
|
|
618
|
+
createdAt: at("2026-05-14T10:00:00.000Z"),
|
|
619
|
+
})
|
|
620
|
+
const repeated = await storage.groupMemberships.upsert({
|
|
621
|
+
projectId,
|
|
622
|
+
userId: "usr_1",
|
|
623
|
+
groupId: "commercial",
|
|
624
|
+
source: "manual",
|
|
625
|
+
createdAt: at("2026-05-14T10:01:00.000Z"),
|
|
626
|
+
})
|
|
627
|
+
|
|
628
|
+
expect(repeated.source).toBe("invitation")
|
|
629
|
+
await expect(
|
|
630
|
+
storage.groupMemberships.listForUser({ projectId, userId: "usr_1" })
|
|
631
|
+
).resolves.toHaveLength(1)
|
|
632
|
+
})
|
|
633
|
+
})
|
|
634
|
+
|
|
635
|
+
test("rejects group memberships for missing users", async () => {
|
|
636
|
+
await withStorage(async (storage) => {
|
|
637
|
+
await expectAuthError(
|
|
638
|
+
storage.groupMemberships.upsert({
|
|
639
|
+
projectId,
|
|
640
|
+
userId: "usr_missing",
|
|
641
|
+
groupId: "commercial",
|
|
642
|
+
source: "manual",
|
|
643
|
+
createdAt: at("2026-05-14T10:00:00.000Z"),
|
|
644
|
+
}),
|
|
645
|
+
"missing_user"
|
|
646
|
+
)
|
|
647
|
+
})
|
|
648
|
+
})
|
|
649
|
+
|
|
650
|
+
test("removes group memberships and is idempotent for missing rows", async () => {
|
|
651
|
+
await withStorage(async (storage) => {
|
|
652
|
+
await createUser(storage)
|
|
653
|
+
|
|
654
|
+
await storage.groupMemberships.upsert({
|
|
655
|
+
projectId,
|
|
656
|
+
userId: "usr_1",
|
|
657
|
+
groupId: "commercial",
|
|
658
|
+
source: "manual",
|
|
659
|
+
createdAt: at("2026-05-14T10:00:00.000Z"),
|
|
660
|
+
})
|
|
661
|
+
|
|
662
|
+
const removed = await storage.groupMemberships.remove({
|
|
663
|
+
projectId,
|
|
664
|
+
userId: "usr_1",
|
|
665
|
+
groupId: "commercial",
|
|
666
|
+
})
|
|
667
|
+
expect(removed).toMatchObject({
|
|
668
|
+
projectId,
|
|
669
|
+
userId: "usr_1",
|
|
670
|
+
groupId: "commercial",
|
|
671
|
+
source: "manual",
|
|
672
|
+
})
|
|
673
|
+
await expect(
|
|
674
|
+
storage.groupMemberships.listForUser({ projectId, userId: "usr_1" })
|
|
675
|
+
).resolves.toHaveLength(0)
|
|
676
|
+
|
|
677
|
+
// Removing an already-removed membership is a no-op that returns null.
|
|
678
|
+
await expect(
|
|
679
|
+
storage.groupMemberships.remove({ projectId, userId: "usr_1", groupId: "commercial" })
|
|
680
|
+
).resolves.toBeNull()
|
|
681
|
+
})
|
|
682
|
+
})
|
|
683
|
+
|
|
684
|
+
test("returns null when removing a membership for a missing user", async () => {
|
|
685
|
+
await withStorage(async (storage) => {
|
|
686
|
+
await expect(
|
|
687
|
+
storage.groupMemberships.remove({
|
|
688
|
+
projectId,
|
|
689
|
+
userId: "usr_missing",
|
|
690
|
+
groupId: "commercial",
|
|
691
|
+
})
|
|
692
|
+
).resolves.toBeNull()
|
|
693
|
+
})
|
|
694
|
+
})
|
|
695
|
+
|
|
696
|
+
test("manages service accounts and their group memberships", async () => {
|
|
697
|
+
await withStorage(async (storage) => {
|
|
698
|
+
const serviceAccount = await storage.serviceAccounts.create({
|
|
699
|
+
id: "svc_ingest",
|
|
700
|
+
projectId,
|
|
701
|
+
name: "Ingest worker",
|
|
702
|
+
description: "Reads source data into Sixb.",
|
|
703
|
+
createdAt: at("2026-05-14T10:00:00.000Z"),
|
|
704
|
+
})
|
|
705
|
+
expect(serviceAccount).toMatchObject({
|
|
706
|
+
id: "svc_ingest",
|
|
707
|
+
name: "Ingest worker",
|
|
708
|
+
status: "active",
|
|
709
|
+
})
|
|
710
|
+
|
|
711
|
+
const membership = await storage.serviceAccountGroupMemberships.upsert({
|
|
712
|
+
projectId,
|
|
713
|
+
serviceAccountId: "svc_ingest",
|
|
714
|
+
groupId: "commercial",
|
|
715
|
+
source: "manual",
|
|
716
|
+
createdAt: at("2026-05-14T10:01:00.000Z"),
|
|
717
|
+
})
|
|
718
|
+
expect(membership.groupId).toBe("commercial")
|
|
719
|
+
const repeated = await storage.serviceAccountGroupMemberships.upsert({
|
|
720
|
+
projectId,
|
|
721
|
+
serviceAccountId: "svc_ingest",
|
|
722
|
+
groupId: "commercial",
|
|
723
|
+
source: "invitation",
|
|
724
|
+
createdAt: at("2026-05-14T10:02:00.000Z"),
|
|
725
|
+
})
|
|
726
|
+
expect(repeated.source).toBe("manual")
|
|
727
|
+
|
|
728
|
+
await expect(
|
|
729
|
+
storage.serviceAccountGroupMemberships.listForServiceAccount({
|
|
730
|
+
projectId,
|
|
731
|
+
serviceAccountId: "svc_ingest",
|
|
732
|
+
})
|
|
733
|
+
).resolves.toHaveLength(1)
|
|
734
|
+
await expect(
|
|
735
|
+
storage.serviceAccountGroupMemberships.listForGroup({
|
|
736
|
+
projectId,
|
|
737
|
+
groupId: "commercial",
|
|
738
|
+
})
|
|
739
|
+
).resolves.toMatchObject([{ serviceAccountId: "svc_ingest" }])
|
|
740
|
+
|
|
741
|
+
const updated = await storage.serviceAccounts.update({
|
|
742
|
+
projectId,
|
|
743
|
+
id: "svc_ingest",
|
|
744
|
+
name: "Ingest worker v2",
|
|
745
|
+
status: "suspended",
|
|
746
|
+
updatedAt: at("2026-05-14T10:03:00.000Z"),
|
|
747
|
+
})
|
|
748
|
+
expect(updated).toMatchObject({ name: "Ingest worker v2", status: "suspended" })
|
|
749
|
+
await expect(
|
|
750
|
+
storage.serviceAccounts.list({ projectId, statuses: ["suspended"] })
|
|
751
|
+
).resolves.toMatchObject({
|
|
752
|
+
serviceAccounts: [{ id: "svc_ingest" }],
|
|
753
|
+
total: 1,
|
|
754
|
+
})
|
|
755
|
+
})
|
|
756
|
+
})
|
|
757
|
+
|
|
758
|
+
test("rejects service account memberships for missing service accounts", async () => {
|
|
759
|
+
await withStorage(async (storage) => {
|
|
760
|
+
await expectAuthError(
|
|
761
|
+
storage.serviceAccountGroupMemberships.upsert({
|
|
762
|
+
projectId,
|
|
763
|
+
serviceAccountId: "svc_missing",
|
|
764
|
+
groupId: "commercial",
|
|
765
|
+
source: "manual",
|
|
766
|
+
createdAt: at("2026-05-14T10:00:00.000Z"),
|
|
767
|
+
}),
|
|
768
|
+
"missing_service_account"
|
|
769
|
+
)
|
|
770
|
+
})
|
|
771
|
+
})
|
|
772
|
+
|
|
773
|
+
test("reconciles agent-managed service account memberships", async () => {
|
|
774
|
+
await withStorage(async (storage) => {
|
|
775
|
+
await storage.serviceAccounts.create({
|
|
776
|
+
id: "svc_agent_ops",
|
|
777
|
+
projectId,
|
|
778
|
+
name: "Ops agent",
|
|
779
|
+
createdAt: at("2026-05-14T10:00:00.000Z"),
|
|
780
|
+
})
|
|
781
|
+
await storage.serviceAccountGroupMemberships.upsert({
|
|
782
|
+
projectId,
|
|
783
|
+
serviceAccountId: "svc_agent_ops",
|
|
784
|
+
groupId: "manual-extra",
|
|
785
|
+
source: "manual",
|
|
786
|
+
createdAt: at("2026-05-14T10:01:00.000Z"),
|
|
787
|
+
})
|
|
788
|
+
await storage.serviceAccountGroupMemberships.upsert({
|
|
789
|
+
projectId,
|
|
790
|
+
serviceAccountId: "svc_agent_ops",
|
|
791
|
+
groupId: "stale-agent",
|
|
792
|
+
source: "agent",
|
|
793
|
+
createdAt: at("2026-05-14T10:02:00.000Z"),
|
|
794
|
+
})
|
|
795
|
+
|
|
796
|
+
const first = await storage.serviceAccountGroupMemberships.reconcileForServiceAccount({
|
|
797
|
+
projectId,
|
|
798
|
+
serviceAccountId: "svc_agent_ops",
|
|
799
|
+
groupIds: ["agent-runtime", "agent-runtime", "ops"],
|
|
800
|
+
source: "agent",
|
|
801
|
+
updatedAt: at("2026-05-14T10:03:00.000Z"),
|
|
802
|
+
})
|
|
803
|
+
expect(first.map((membership) => [membership.groupId, membership.source])).toEqual([
|
|
804
|
+
["agent-runtime", "agent"],
|
|
805
|
+
["manual-extra", "manual"],
|
|
806
|
+
["ops", "agent"],
|
|
807
|
+
])
|
|
808
|
+
|
|
809
|
+
const second = await storage.serviceAccountGroupMemberships.reconcileForServiceAccount({
|
|
810
|
+
projectId,
|
|
811
|
+
serviceAccountId: "svc_agent_ops",
|
|
812
|
+
groupIds: ["ops"],
|
|
813
|
+
source: "agent",
|
|
814
|
+
updatedAt: at("2026-05-14T10:04:00.000Z"),
|
|
815
|
+
})
|
|
816
|
+
expect(second.map((membership) => [membership.groupId, membership.source])).toEqual([
|
|
817
|
+
["manual-extra", "manual"],
|
|
818
|
+
["ops", "agent"],
|
|
819
|
+
])
|
|
820
|
+
})
|
|
821
|
+
})
|
|
822
|
+
|
|
823
|
+
test("creates, resolves, touches, lists, and revokes access tokens", async () => {
|
|
824
|
+
await withStorage(async (storage) => {
|
|
825
|
+
await createUser(storage)
|
|
826
|
+
await storage.serviceAccounts.create({
|
|
827
|
+
id: "svc_ingest",
|
|
828
|
+
projectId,
|
|
829
|
+
name: "Ingest worker",
|
|
830
|
+
createdAt: at("2026-05-14T10:00:00.000Z"),
|
|
831
|
+
})
|
|
832
|
+
|
|
833
|
+
const personal = await storage.accessTokens.create({
|
|
834
|
+
id: "tok_personal",
|
|
835
|
+
projectId,
|
|
836
|
+
name: "Local CLI",
|
|
837
|
+
kind: "personal",
|
|
838
|
+
subjectType: "user",
|
|
839
|
+
subjectId: "usr_1",
|
|
840
|
+
tokenHash: "hash-personal",
|
|
841
|
+
groupIds: ["commercial", "commercial", "finance"],
|
|
842
|
+
createdAt: at("2026-05-14T10:01:00.000Z"),
|
|
843
|
+
expiresAt: at("2026-05-21T10:01:00.000Z"),
|
|
844
|
+
})
|
|
845
|
+
expect(personal.groupIds).toEqual(["commercial", "finance"])
|
|
846
|
+
await expect(
|
|
847
|
+
storage.accessTokens.findValidByTokenHash({
|
|
848
|
+
projectId,
|
|
849
|
+
id: "tok_personal",
|
|
850
|
+
kind: "personal",
|
|
851
|
+
tokenHash: "hash-personal",
|
|
852
|
+
now: at("2026-05-14T10:02:00.000Z"),
|
|
853
|
+
})
|
|
854
|
+
).resolves.toMatchObject({ id: "tok_personal" })
|
|
855
|
+
await expect(
|
|
856
|
+
storage.accessTokens.findValidByTokenHash({
|
|
857
|
+
projectId,
|
|
858
|
+
id: "tok_personal",
|
|
859
|
+
kind: "personal",
|
|
860
|
+
tokenHash: "wrong",
|
|
861
|
+
now: at("2026-05-14T10:02:00.000Z"),
|
|
862
|
+
})
|
|
863
|
+
).resolves.toBeNull()
|
|
864
|
+
|
|
865
|
+
const touched = await storage.accessTokens.touch({
|
|
866
|
+
projectId,
|
|
867
|
+
id: "tok_personal",
|
|
868
|
+
lastUsedAt: at("2026-05-14T10:03:00.000Z"),
|
|
869
|
+
userAgent: "sixb-cli/0.1",
|
|
870
|
+
ipAddress: "203.0.113.10",
|
|
871
|
+
})
|
|
872
|
+
expect(touched.lastUsedAt?.toISOString()).toBe("2026-05-14T10:03:00.000Z")
|
|
873
|
+
expect(touched.lastUsedUserAgent).toBe("sixb-cli/0.1")
|
|
874
|
+
|
|
875
|
+
await storage.accessTokens.create({
|
|
876
|
+
id: "tok_service",
|
|
877
|
+
projectId,
|
|
878
|
+
name: "Sandbox agent",
|
|
879
|
+
kind: "serviceAccount",
|
|
880
|
+
subjectType: "serviceAccount",
|
|
881
|
+
subjectId: "svc_ingest",
|
|
882
|
+
tokenHash: "hash-service",
|
|
883
|
+
createdAt: at("2026-05-14T10:04:00.000Z"),
|
|
884
|
+
expiresAt: at("2026-05-21T10:04:00.000Z"),
|
|
885
|
+
})
|
|
886
|
+
await expect(
|
|
887
|
+
storage.accessTokens.list({
|
|
888
|
+
projectId,
|
|
889
|
+
subjectType: "serviceAccount",
|
|
890
|
+
subjectId: "svc_ingest",
|
|
891
|
+
})
|
|
892
|
+
).resolves.toMatchObject({
|
|
893
|
+
accessTokens: [{ id: "tok_service" }],
|
|
894
|
+
total: 1,
|
|
895
|
+
})
|
|
896
|
+
|
|
897
|
+
await storage.accessTokens.revoke({
|
|
898
|
+
projectId,
|
|
899
|
+
id: "tok_personal",
|
|
900
|
+
revokedAt: at("2026-05-14T10:05:00.000Z"),
|
|
901
|
+
})
|
|
902
|
+
await expect(
|
|
903
|
+
storage.accessTokens.findValidByTokenHash({
|
|
904
|
+
projectId,
|
|
905
|
+
id: "tok_personal",
|
|
906
|
+
kind: "personal",
|
|
907
|
+
tokenHash: "hash-personal",
|
|
908
|
+
now: at("2026-05-14T10:06:00.000Z"),
|
|
909
|
+
})
|
|
910
|
+
).resolves.toBeNull()
|
|
911
|
+
})
|
|
912
|
+
})
|
|
913
|
+
|
|
914
|
+
test("round-trips the creator principal for service accounts and access tokens", async () => {
|
|
915
|
+
await withStorage(async (storage) => {
|
|
916
|
+
await createUser(storage, { id: "usr_creator", email: "creator@acme.com" })
|
|
917
|
+
await storage.serviceAccounts.create({
|
|
918
|
+
id: "svc_creator",
|
|
919
|
+
projectId,
|
|
920
|
+
name: "Creator service account",
|
|
921
|
+
createdAt: at("2026-05-14T10:00:00.000Z"),
|
|
922
|
+
})
|
|
923
|
+
await storage.sessions.create({
|
|
924
|
+
id: "ses_creator",
|
|
925
|
+
projectId,
|
|
926
|
+
userId: "usr_creator",
|
|
927
|
+
strategyId: "magic-link",
|
|
928
|
+
audience: "atlas",
|
|
929
|
+
tokenHash: "hash-creator",
|
|
930
|
+
createdAt: at("2026-05-14T10:00:30.000Z"),
|
|
931
|
+
expiresAt: at("2026-05-21T10:00:30.000Z"),
|
|
932
|
+
})
|
|
933
|
+
|
|
934
|
+
const principals = [
|
|
935
|
+
{ type: "user", id: "usr_creator" },
|
|
936
|
+
{ type: "serviceAccount", id: "svc_creator" },
|
|
937
|
+
{ type: "system", id: "scheduler" },
|
|
938
|
+
] as const
|
|
939
|
+
|
|
940
|
+
for (const [index, principal] of principals.entries()) {
|
|
941
|
+
const accountId = `svc_by_${principal.type}`
|
|
942
|
+
const createdAccount = await storage.serviceAccounts.create({
|
|
943
|
+
id: accountId,
|
|
944
|
+
projectId,
|
|
945
|
+
name: `Service account by ${principal.type}`,
|
|
946
|
+
createdByPrincipal: principal,
|
|
947
|
+
createdBySessionId: "ses_creator",
|
|
948
|
+
createdAt: at(`2026-05-14T10:1${index}:00.000Z`),
|
|
949
|
+
})
|
|
950
|
+
expect(createdAccount.createdByPrincipal).toEqual(principal)
|
|
951
|
+
expect(createdAccount.createdBySessionId).toBe("ses_creator")
|
|
952
|
+
await expect(
|
|
953
|
+
storage.serviceAccounts.getById({ projectId, id: accountId })
|
|
954
|
+
).resolves.toMatchObject({
|
|
955
|
+
createdByPrincipal: principal,
|
|
956
|
+
createdBySessionId: "ses_creator",
|
|
957
|
+
})
|
|
958
|
+
|
|
959
|
+
const tokenId = `tok_by_${principal.type}`
|
|
960
|
+
const createdToken = await storage.accessTokens.create({
|
|
961
|
+
id: tokenId,
|
|
962
|
+
projectId,
|
|
963
|
+
name: `Token by ${principal.type}`,
|
|
964
|
+
kind: "personal",
|
|
965
|
+
subjectType: "user",
|
|
966
|
+
subjectId: "usr_creator",
|
|
967
|
+
tokenHash: `hash-${tokenId}`,
|
|
968
|
+
createdByPrincipal: principal,
|
|
969
|
+
createdBySessionId: "ses_creator",
|
|
970
|
+
createdAt: at(`2026-05-14T10:2${index}:00.000Z`),
|
|
971
|
+
expiresAt: at(`2026-05-21T10:2${index}:00.000Z`),
|
|
972
|
+
})
|
|
973
|
+
expect(createdToken.createdByPrincipal).toEqual(principal)
|
|
974
|
+
expect(createdToken.createdBySessionId).toBe("ses_creator")
|
|
975
|
+
await expect(
|
|
976
|
+
storage.accessTokens.getById({ projectId, id: tokenId })
|
|
977
|
+
).resolves.toMatchObject({
|
|
978
|
+
createdByPrincipal: principal,
|
|
979
|
+
createdBySessionId: "ses_creator",
|
|
980
|
+
})
|
|
981
|
+
}
|
|
982
|
+
|
|
983
|
+
// Omitting the creator round-trips as undefined on every backend.
|
|
984
|
+
const anonymous = await storage.serviceAccounts.create({
|
|
985
|
+
id: "svc_anonymous",
|
|
986
|
+
projectId,
|
|
987
|
+
name: "Anonymous service account",
|
|
988
|
+
createdAt: at("2026-05-14T10:30:00.000Z"),
|
|
989
|
+
})
|
|
990
|
+
expect(anonymous.createdByPrincipal).toBeUndefined()
|
|
991
|
+
expect(anonymous.createdBySessionId).toBeUndefined()
|
|
992
|
+
await expect(
|
|
993
|
+
storage.serviceAccounts.getById({ projectId, id: "svc_anonymous" })
|
|
994
|
+
).resolves.toMatchObject({ id: "svc_anonymous" })
|
|
995
|
+
})
|
|
996
|
+
})
|
|
997
|
+
|
|
998
|
+
test("touch preserves prior access-token metadata when omitted", async () => {
|
|
999
|
+
await withStorage(async (storage) => {
|
|
1000
|
+
await createUser(storage)
|
|
1001
|
+
await storage.accessTokens.create({
|
|
1002
|
+
id: "tok_touch",
|
|
1003
|
+
projectId,
|
|
1004
|
+
name: "Touch token",
|
|
1005
|
+
kind: "personal",
|
|
1006
|
+
subjectType: "user",
|
|
1007
|
+
subjectId: "usr_1",
|
|
1008
|
+
tokenHash: "hash-touch",
|
|
1009
|
+
createdAt: at("2026-05-14T10:00:00.000Z"),
|
|
1010
|
+
expiresAt: at("2026-05-21T10:00:00.000Z"),
|
|
1011
|
+
})
|
|
1012
|
+
|
|
1013
|
+
const first = await storage.accessTokens.touch({
|
|
1014
|
+
projectId,
|
|
1015
|
+
id: "tok_touch",
|
|
1016
|
+
lastUsedAt: at("2026-05-14T10:01:00.000Z"),
|
|
1017
|
+
userAgent: "sixb-cli/0.1",
|
|
1018
|
+
ipAddress: "203.0.113.10",
|
|
1019
|
+
})
|
|
1020
|
+
expect(first.lastUsedUserAgent).toBe("sixb-cli/0.1")
|
|
1021
|
+
expect(first.lastUsedIpAddress).toBe("203.0.113.10")
|
|
1022
|
+
|
|
1023
|
+
// A later touch without metadata advances lastUsedAt but keeps the
|
|
1024
|
+
// previously captured user agent and IP address.
|
|
1025
|
+
const second = await storage.accessTokens.touch({
|
|
1026
|
+
projectId,
|
|
1027
|
+
id: "tok_touch",
|
|
1028
|
+
lastUsedAt: at("2026-05-14T10:05:00.000Z"),
|
|
1029
|
+
})
|
|
1030
|
+
expect(second.lastUsedAt?.toISOString()).toBe("2026-05-14T10:05:00.000Z")
|
|
1031
|
+
expect(second.lastUsedUserAgent).toBe("sixb-cli/0.1")
|
|
1032
|
+
expect(second.lastUsedIpAddress).toBe("203.0.113.10")
|
|
1033
|
+
await expect(
|
|
1034
|
+
storage.accessTokens.getById({ projectId, id: "tok_touch" })
|
|
1035
|
+
).resolves.toMatchObject({
|
|
1036
|
+
lastUsedUserAgent: "sixb-cli/0.1",
|
|
1037
|
+
lastUsedIpAddress: "203.0.113.10",
|
|
1038
|
+
})
|
|
1039
|
+
})
|
|
1040
|
+
})
|
|
1041
|
+
|
|
1042
|
+
test("lists access tokens with revoked, order, and pagination parity", async () => {
|
|
1043
|
+
await withStorage(async (storage) => {
|
|
1044
|
+
await createUser(storage)
|
|
1045
|
+
|
|
1046
|
+
const ids = ["tok_a", "tok_b", "tok_c", "tok_d"]
|
|
1047
|
+
for (const [index, id] of ids.entries()) {
|
|
1048
|
+
await storage.accessTokens.create({
|
|
1049
|
+
id,
|
|
1050
|
+
projectId,
|
|
1051
|
+
name: `Token ${id}`,
|
|
1052
|
+
kind: "personal",
|
|
1053
|
+
subjectType: "user",
|
|
1054
|
+
subjectId: "usr_1",
|
|
1055
|
+
tokenHash: `hash-${id}`,
|
|
1056
|
+
createdAt: at(`2026-05-14T10:0${index}:00.000Z`),
|
|
1057
|
+
expiresAt: at(`2026-05-21T10:0${index}:00.000Z`),
|
|
1058
|
+
})
|
|
1059
|
+
}
|
|
1060
|
+
await storage.accessTokens.revoke({
|
|
1061
|
+
projectId,
|
|
1062
|
+
id: "tok_b",
|
|
1063
|
+
revokedAt: at("2026-05-14T11:00:00.000Z"),
|
|
1064
|
+
})
|
|
1065
|
+
|
|
1066
|
+
// includeRevoked defaults to false: the revoked token is hidden.
|
|
1067
|
+
const active = await storage.accessTokens.list({ projectId })
|
|
1068
|
+
expect(active.accessTokens.map((token) => token.id)).toEqual(["tok_a", "tok_c", "tok_d"])
|
|
1069
|
+
expect(active.total).toBe(3)
|
|
1070
|
+
expect(active.hasMore).toBe(false)
|
|
1071
|
+
|
|
1072
|
+
// includeRevoked: true surfaces it again, default order is ascending.
|
|
1073
|
+
const all = await storage.accessTokens.list({ projectId, includeRevoked: true })
|
|
1074
|
+
expect(all.accessTokens.map((token) => token.id)).toEqual([
|
|
1075
|
+
"tok_a",
|
|
1076
|
+
"tok_b",
|
|
1077
|
+
"tok_c",
|
|
1078
|
+
"tok_d",
|
|
1079
|
+
])
|
|
1080
|
+
expect(all.total).toBe(4)
|
|
1081
|
+
|
|
1082
|
+
// order: "desc" reverses by createdAt.
|
|
1083
|
+
const descending = await storage.accessTokens.list({
|
|
1084
|
+
projectId,
|
|
1085
|
+
includeRevoked: true,
|
|
1086
|
+
order: "desc",
|
|
1087
|
+
})
|
|
1088
|
+
expect(descending.accessTokens.map((token) => token.id)).toEqual([
|
|
1089
|
+
"tok_d",
|
|
1090
|
+
"tok_c",
|
|
1091
|
+
"tok_b",
|
|
1092
|
+
"tok_a",
|
|
1093
|
+
])
|
|
1094
|
+
|
|
1095
|
+
// First page reports hasMore at the page boundary.
|
|
1096
|
+
const firstPage = await storage.accessTokens.list({
|
|
1097
|
+
projectId,
|
|
1098
|
+
includeRevoked: true,
|
|
1099
|
+
limit: 2,
|
|
1100
|
+
})
|
|
1101
|
+
expect(firstPage.accessTokens.map((token) => token.id)).toEqual(["tok_a", "tok_b"])
|
|
1102
|
+
expect(firstPage.total).toBe(4)
|
|
1103
|
+
expect(firstPage.hasMore).toBe(true)
|
|
1104
|
+
|
|
1105
|
+
// Second page exhausts the result set.
|
|
1106
|
+
const secondPage = await storage.accessTokens.list({
|
|
1107
|
+
projectId,
|
|
1108
|
+
includeRevoked: true,
|
|
1109
|
+
limit: 2,
|
|
1110
|
+
offset: 2,
|
|
1111
|
+
})
|
|
1112
|
+
expect(secondPage.accessTokens.map((token) => token.id)).toEqual(["tok_c", "tok_d"])
|
|
1113
|
+
expect(secondPage.hasMore).toBe(false)
|
|
1114
|
+
|
|
1115
|
+
// A page that exactly consumes the remainder reports no more.
|
|
1116
|
+
const exactBoundary = await storage.accessTokens.list({
|
|
1117
|
+
projectId,
|
|
1118
|
+
includeRevoked: true,
|
|
1119
|
+
limit: 4,
|
|
1120
|
+
})
|
|
1121
|
+
expect(exactBoundary.accessTokens.map((token) => token.id)).toEqual(ids)
|
|
1122
|
+
expect(exactBoundary.hasMore).toBe(false)
|
|
1123
|
+
})
|
|
1124
|
+
})
|
|
1125
|
+
|
|
1126
|
+
test("lists service accounts with pagination parity", async () => {
|
|
1127
|
+
await withStorage(async (storage) => {
|
|
1128
|
+
const ids = ["svc_a", "svc_b", "svc_c"]
|
|
1129
|
+
for (const [index, id] of ids.entries()) {
|
|
1130
|
+
await storage.serviceAccounts.create({
|
|
1131
|
+
id,
|
|
1132
|
+
projectId,
|
|
1133
|
+
name: `Service account ${id}`,
|
|
1134
|
+
createdAt: at(`2026-05-14T10:0${index}:00.000Z`),
|
|
1135
|
+
})
|
|
1136
|
+
}
|
|
1137
|
+
|
|
1138
|
+
// Default order is ascending by createdAt across every backend.
|
|
1139
|
+
const all = await storage.serviceAccounts.list({ projectId })
|
|
1140
|
+
expect(all.serviceAccounts.map((account) => account.id)).toEqual(ids)
|
|
1141
|
+
expect(all.total).toBe(3)
|
|
1142
|
+
expect(all.hasMore).toBe(false)
|
|
1143
|
+
|
|
1144
|
+
const firstPage = await storage.serviceAccounts.list({ projectId, limit: 2 })
|
|
1145
|
+
expect(firstPage.serviceAccounts.map((account) => account.id)).toEqual(["svc_a", "svc_b"])
|
|
1146
|
+
expect(firstPage.total).toBe(3)
|
|
1147
|
+
expect(firstPage.hasMore).toBe(true)
|
|
1148
|
+
|
|
1149
|
+
const secondPage = await storage.serviceAccounts.list({
|
|
1150
|
+
projectId,
|
|
1151
|
+
limit: 2,
|
|
1152
|
+
offset: 2,
|
|
1153
|
+
})
|
|
1154
|
+
expect(secondPage.serviceAccounts.map((account) => account.id)).toEqual(["svc_c"])
|
|
1155
|
+
expect(secondPage.hasMore).toBe(false)
|
|
1156
|
+
})
|
|
1157
|
+
})
|
|
1158
|
+
|
|
1159
|
+
test("rejects invalid access token subjects", async () => {
|
|
1160
|
+
await withStorage(async (storage) => {
|
|
1161
|
+
await createUser(storage)
|
|
1162
|
+
|
|
1163
|
+
await expectAuthError(
|
|
1164
|
+
storage.accessTokens.create({
|
|
1165
|
+
id: "tok_bad_kind",
|
|
1166
|
+
projectId,
|
|
1167
|
+
name: "Bad kind",
|
|
1168
|
+
kind: "serviceAccount",
|
|
1169
|
+
subjectType: "user",
|
|
1170
|
+
subjectId: "usr_1",
|
|
1171
|
+
tokenHash: "hash",
|
|
1172
|
+
createdAt: at("2026-05-14T10:00:00.000Z"),
|
|
1173
|
+
expiresAt: at("2026-05-21T10:00:00.000Z"),
|
|
1174
|
+
}),
|
|
1175
|
+
"invalid_input"
|
|
1176
|
+
)
|
|
1177
|
+
await expectAuthError(
|
|
1178
|
+
storage.accessTokens.create({
|
|
1179
|
+
id: "tok_missing_subject",
|
|
1180
|
+
projectId,
|
|
1181
|
+
name: "Missing subject",
|
|
1182
|
+
kind: "serviceAccount",
|
|
1183
|
+
subjectType: "serviceAccount",
|
|
1184
|
+
subjectId: "svc_missing",
|
|
1185
|
+
tokenHash: "hash",
|
|
1186
|
+
createdAt: at("2026-05-14T10:00:00.000Z"),
|
|
1187
|
+
expiresAt: at("2026-05-21T10:00:00.000Z"),
|
|
1188
|
+
}),
|
|
1189
|
+
"missing_service_account"
|
|
1190
|
+
)
|
|
1191
|
+
})
|
|
1192
|
+
})
|
|
1193
|
+
|
|
1194
|
+
test("creates one active magic link per email and consumes it once", async () => {
|
|
1195
|
+
await withStorage(async (storage) => {
|
|
1196
|
+
await storage.magicLinks.create({
|
|
1197
|
+
id: "ml_1",
|
|
1198
|
+
projectId,
|
|
1199
|
+
strategyId: "magic-link",
|
|
1200
|
+
audience: "atlas",
|
|
1201
|
+
email: "ava@acme.com",
|
|
1202
|
+
tokenHash: "hash-1",
|
|
1203
|
+
createdAt: at("2026-05-14T10:00:00.000Z"),
|
|
1204
|
+
expiresAt: at("2026-05-14T10:15:00.000Z"),
|
|
1205
|
+
})
|
|
1206
|
+
await storage.magicLinks.create({
|
|
1207
|
+
id: "ml_2",
|
|
1208
|
+
projectId,
|
|
1209
|
+
strategyId: "magic-link",
|
|
1210
|
+
audience: "atlas",
|
|
1211
|
+
email: " ava@acme.com ",
|
|
1212
|
+
tokenHash: "hash-2",
|
|
1213
|
+
returnTo: "/dashboard",
|
|
1214
|
+
createdAt: at("2026-05-14T10:01:00.000Z"),
|
|
1215
|
+
expiresAt: at("2026-05-14T10:16:00.000Z"),
|
|
1216
|
+
})
|
|
1217
|
+
|
|
1218
|
+
await expect(storage.magicLinks.getById({ projectId, id: "ml_1" })).resolves.toMatchObject({
|
|
1219
|
+
revokedAt: at("2026-05-14T10:01:00.000Z"),
|
|
1220
|
+
})
|
|
1221
|
+
await expectAuthError(
|
|
1222
|
+
storage.magicLinks.consume({
|
|
1223
|
+
projectId,
|
|
1224
|
+
id: "ml_2",
|
|
1225
|
+
tokenHash: "wrong",
|
|
1226
|
+
consumedAt: at("2026-05-14T10:02:00.000Z"),
|
|
1227
|
+
}),
|
|
1228
|
+
"invalid_magic_link"
|
|
1229
|
+
)
|
|
1230
|
+
|
|
1231
|
+
await expect(
|
|
1232
|
+
storage.magicLinks.consume({
|
|
1233
|
+
projectId,
|
|
1234
|
+
id: "ml_2",
|
|
1235
|
+
tokenHash: "hash-2",
|
|
1236
|
+
consumedAt: at("2026-05-14T10:02:00.000Z"),
|
|
1237
|
+
})
|
|
1238
|
+
).resolves.toMatchObject({
|
|
1239
|
+
audience: "atlas",
|
|
1240
|
+
returnTo: "/dashboard",
|
|
1241
|
+
consumedAt: at("2026-05-14T10:02:00.000Z"),
|
|
1242
|
+
})
|
|
1243
|
+
await expectAuthError(
|
|
1244
|
+
storage.magicLinks.consume({
|
|
1245
|
+
projectId,
|
|
1246
|
+
id: "ml_2",
|
|
1247
|
+
tokenHash: "hash-2",
|
|
1248
|
+
consumedAt: at("2026-05-14T10:03:00.000Z"),
|
|
1249
|
+
}),
|
|
1250
|
+
"invalid_magic_link"
|
|
1251
|
+
)
|
|
1252
|
+
})
|
|
1253
|
+
})
|
|
1254
|
+
|
|
1255
|
+
test("stores OIDC attempts with one-time state consumption", async () => {
|
|
1256
|
+
await withStorage(async (storage) => {
|
|
1257
|
+
await storage.oidcAuthorizationAttempts.create({
|
|
1258
|
+
id: "oidc_1",
|
|
1259
|
+
projectId,
|
|
1260
|
+
strategyId: "okta",
|
|
1261
|
+
audience: "atlas",
|
|
1262
|
+
stateHash: "state-hash",
|
|
1263
|
+
nonceHash: "nonce-hash",
|
|
1264
|
+
codeVerifier: "verifier",
|
|
1265
|
+
returnTo: "/objects",
|
|
1266
|
+
createdAt: at("2026-05-14T10:00:00.000Z"),
|
|
1267
|
+
expiresAt: at("2026-05-14T10:10:00.000Z"),
|
|
1268
|
+
})
|
|
1269
|
+
|
|
1270
|
+
await expectAuthError(
|
|
1271
|
+
storage.oidcAuthorizationAttempts.consume({
|
|
1272
|
+
projectId,
|
|
1273
|
+
id: "oidc_1",
|
|
1274
|
+
stateHash: "wrong",
|
|
1275
|
+
consumedAt: at("2026-05-14T10:01:00.000Z"),
|
|
1276
|
+
}),
|
|
1277
|
+
"invalid_oidc_attempt"
|
|
1278
|
+
)
|
|
1279
|
+
await expect(
|
|
1280
|
+
storage.oidcAuthorizationAttempts.consume({
|
|
1281
|
+
projectId,
|
|
1282
|
+
id: "oidc_1",
|
|
1283
|
+
stateHash: "state-hash",
|
|
1284
|
+
consumedAt: at("2026-05-14T10:01:00.000Z"),
|
|
1285
|
+
})
|
|
1286
|
+
).resolves.toMatchObject({
|
|
1287
|
+
audience: "atlas",
|
|
1288
|
+
codeVerifier: "verifier",
|
|
1289
|
+
consumedAt: at("2026-05-14T10:01:00.000Z"),
|
|
1290
|
+
})
|
|
1291
|
+
await expectAuthError(
|
|
1292
|
+
storage.oidcAuthorizationAttempts.consume({
|
|
1293
|
+
projectId,
|
|
1294
|
+
id: "oidc_1",
|
|
1295
|
+
stateHash: "state-hash",
|
|
1296
|
+
consumedAt: at("2026-05-14T10:02:00.000Z"),
|
|
1297
|
+
}),
|
|
1298
|
+
"invalid_oidc_attempt"
|
|
1299
|
+
)
|
|
1300
|
+
})
|
|
1301
|
+
})
|
|
1302
|
+
|
|
1303
|
+
test("completes magic-link sign-in for an existing user", async () => {
|
|
1304
|
+
await withStorage(async (storage) => {
|
|
1305
|
+
await createUser(storage)
|
|
1306
|
+
await storage.sessions.create({
|
|
1307
|
+
id: "ses_old",
|
|
1308
|
+
projectId,
|
|
1309
|
+
userId: "usr_1",
|
|
1310
|
+
strategyId: "magic-link",
|
|
1311
|
+
audience: "atlas",
|
|
1312
|
+
tokenHash: "old-hash",
|
|
1313
|
+
createdAt: at("2026-05-14T10:00:00.000Z"),
|
|
1314
|
+
expiresAt: at("2026-05-21T10:00:00.000Z"),
|
|
1315
|
+
})
|
|
1316
|
+
await storage.magicLinks.create({
|
|
1317
|
+
id: "ml_1",
|
|
1318
|
+
projectId,
|
|
1319
|
+
strategyId: "magic-link",
|
|
1320
|
+
audience: "atlas",
|
|
1321
|
+
email: "ava@acme.com",
|
|
1322
|
+
tokenHash: "link-hash",
|
|
1323
|
+
createdAt: at("2026-05-14T10:01:00.000Z"),
|
|
1324
|
+
expiresAt: at("2026-05-14T10:16:00.000Z"),
|
|
1325
|
+
})
|
|
1326
|
+
|
|
1327
|
+
const result = await storage.completeMagicLinkSignIn({
|
|
1328
|
+
projectId,
|
|
1329
|
+
magicLinkId: "ml_1",
|
|
1330
|
+
tokenHash: "link-hash",
|
|
1331
|
+
completedAt: at("2026-05-14T10:02:00.000Z"),
|
|
1332
|
+
newUserId: "usr_unused",
|
|
1333
|
+
session: sessionInput("ses_new", "session-hash", "atlas", at("2026-06-21T10:10:00.000Z")),
|
|
1334
|
+
})
|
|
1335
|
+
|
|
1336
|
+
expect(result.user.id).toBe("usr_1")
|
|
1337
|
+
expect(result.session).toMatchObject({
|
|
1338
|
+
id: "ses_new",
|
|
1339
|
+
strategyId: "magic-link",
|
|
1340
|
+
tokenHash: "session-hash",
|
|
1341
|
+
absoluteExpiresAt: at("2026-06-21T10:10:00.000Z"),
|
|
1342
|
+
})
|
|
1343
|
+
// Signing in again keeps the user's existing session active; concurrent
|
|
1344
|
+
// sessions are allowed.
|
|
1345
|
+
const oldSession = await storage.sessions.getById({ projectId, id: "ses_old" })
|
|
1346
|
+
expect(oldSession?.revokedAt).toBeUndefined()
|
|
1347
|
+
await expectAuthError(
|
|
1348
|
+
storage.completeMagicLinkSignIn({
|
|
1349
|
+
projectId,
|
|
1350
|
+
magicLinkId: "ml_1",
|
|
1351
|
+
tokenHash: "link-hash",
|
|
1352
|
+
completedAt: at("2026-05-14T10:03:00.000Z"),
|
|
1353
|
+
newUserId: "usr_unused_2",
|
|
1354
|
+
session: sessionInput("ses_replay"),
|
|
1355
|
+
}),
|
|
1356
|
+
"invalid_magic_link"
|
|
1357
|
+
)
|
|
1358
|
+
})
|
|
1359
|
+
})
|
|
1360
|
+
|
|
1361
|
+
test("creates invited users through magic-link completion and applies groups once", async () => {
|
|
1362
|
+
await withStorage(async (storage) => {
|
|
1363
|
+
await storage.invitations.createOrUpdateActive({
|
|
1364
|
+
id: "inv_1",
|
|
1365
|
+
projectId,
|
|
1366
|
+
email: "ava@acme.com",
|
|
1367
|
+
groupIds: ["commercial", "finance"],
|
|
1368
|
+
createdAt: at("2026-05-14T10:00:00.000Z"),
|
|
1369
|
+
expiresAt: at("2026-05-21T10:00:00.000Z"),
|
|
1370
|
+
})
|
|
1371
|
+
await storage.magicLinks.create({
|
|
1372
|
+
id: "ml_1",
|
|
1373
|
+
projectId,
|
|
1374
|
+
strategyId: "magic-link",
|
|
1375
|
+
audience: "atlas",
|
|
1376
|
+
email: "ava@acme.com",
|
|
1377
|
+
tokenHash: "link-hash",
|
|
1378
|
+
createdAt: at("2026-05-14T10:02:00.000Z"),
|
|
1379
|
+
expiresAt: at("2026-05-14T10:17:00.000Z"),
|
|
1380
|
+
})
|
|
1381
|
+
|
|
1382
|
+
const result = await storage.completeMagicLinkSignIn({
|
|
1383
|
+
projectId,
|
|
1384
|
+
magicLinkId: "ml_1",
|
|
1385
|
+
tokenHash: "link-hash",
|
|
1386
|
+
completedAt: at("2026-05-14T10:03:00.000Z"),
|
|
1387
|
+
newUserId: "usr_new",
|
|
1388
|
+
manualGroupIds: ["security-admins"],
|
|
1389
|
+
session: sessionInput("ses_new"),
|
|
1390
|
+
})
|
|
1391
|
+
|
|
1392
|
+
expect(result.invitation).toMatchObject({
|
|
1393
|
+
id: "inv_1",
|
|
1394
|
+
status: "accepted",
|
|
1395
|
+
})
|
|
1396
|
+
const memberships = await storage.groupMemberships.listForUser({
|
|
1397
|
+
projectId,
|
|
1398
|
+
userId: "usr_new",
|
|
1399
|
+
})
|
|
1400
|
+
expect(memberships.map((membership) => [membership.groupId, membership.source])).toEqual([
|
|
1401
|
+
["commercial", "invitation"],
|
|
1402
|
+
["finance", "invitation"],
|
|
1403
|
+
["security-admins", "manual"],
|
|
1404
|
+
])
|
|
1405
|
+
})
|
|
1406
|
+
})
|
|
1407
|
+
|
|
1408
|
+
test("preserves existing membership source when accepting an invitation", async () => {
|
|
1409
|
+
await withStorage(async (storage) => {
|
|
1410
|
+
await createUser(storage, { id: "usr_existing", email: "ava@acme.com" })
|
|
1411
|
+
await storage.invitations.createOrUpdateActive({
|
|
1412
|
+
id: "inv_1",
|
|
1413
|
+
projectId,
|
|
1414
|
+
email: "ava@acme.com",
|
|
1415
|
+
groupIds: ["commercial", "finance"],
|
|
1416
|
+
createdAt: at("2026-05-14T10:00:00.000Z"),
|
|
1417
|
+
expiresAt: at("2026-05-21T10:00:00.000Z"),
|
|
1418
|
+
})
|
|
1419
|
+
await storage.groupMemberships.upsert({
|
|
1420
|
+
projectId,
|
|
1421
|
+
userId: "usr_existing",
|
|
1422
|
+
groupId: "commercial",
|
|
1423
|
+
source: "manual",
|
|
1424
|
+
createdAt: at("2026-05-14T10:01:00.000Z"),
|
|
1425
|
+
})
|
|
1426
|
+
await storage.magicLinks.create({
|
|
1427
|
+
id: "ml_1",
|
|
1428
|
+
projectId,
|
|
1429
|
+
strategyId: "magic-link",
|
|
1430
|
+
audience: "atlas",
|
|
1431
|
+
email: "ava@acme.com",
|
|
1432
|
+
tokenHash: "link-hash",
|
|
1433
|
+
createdAt: at("2026-05-14T10:02:00.000Z"),
|
|
1434
|
+
expiresAt: at("2026-05-14T10:17:00.000Z"),
|
|
1435
|
+
})
|
|
1436
|
+
|
|
1437
|
+
await storage.completeMagicLinkSignIn({
|
|
1438
|
+
projectId,
|
|
1439
|
+
magicLinkId: "ml_1",
|
|
1440
|
+
tokenHash: "link-hash",
|
|
1441
|
+
completedAt: at("2026-05-14T10:03:00.000Z"),
|
|
1442
|
+
newUserId: "usr_unused",
|
|
1443
|
+
session: sessionInput("ses_existing"),
|
|
1444
|
+
})
|
|
1445
|
+
|
|
1446
|
+
const memberships = await storage.groupMemberships.listForUser({
|
|
1447
|
+
projectId,
|
|
1448
|
+
userId: "usr_existing",
|
|
1449
|
+
})
|
|
1450
|
+
expect(memberships.map((membership) => [membership.groupId, membership.source])).toEqual([
|
|
1451
|
+
["commercial", "manual"],
|
|
1452
|
+
["finance", "invitation"],
|
|
1453
|
+
])
|
|
1454
|
+
})
|
|
1455
|
+
})
|
|
1456
|
+
|
|
1457
|
+
test("does not create missing users when invitation eligibility disappeared", async () => {
|
|
1458
|
+
await withStorage(async (storage) => {
|
|
1459
|
+
await storage.invitations.createOrUpdateActive({
|
|
1460
|
+
id: "inv_1",
|
|
1461
|
+
projectId,
|
|
1462
|
+
email: "ava@acme.com",
|
|
1463
|
+
createdAt: at("2026-05-14T10:00:00.000Z"),
|
|
1464
|
+
expiresAt: at("2026-05-21T10:00:00.000Z"),
|
|
1465
|
+
})
|
|
1466
|
+
await storage.magicLinks.create({
|
|
1467
|
+
id: "ml_1",
|
|
1468
|
+
projectId,
|
|
1469
|
+
strategyId: "magic-link",
|
|
1470
|
+
audience: "atlas",
|
|
1471
|
+
email: "ava@acme.com",
|
|
1472
|
+
tokenHash: "link-hash",
|
|
1473
|
+
createdAt: at("2026-05-14T10:01:00.000Z"),
|
|
1474
|
+
expiresAt: at("2026-05-14T10:16:00.000Z"),
|
|
1475
|
+
})
|
|
1476
|
+
await storage.invitations.revoke({
|
|
1477
|
+
projectId,
|
|
1478
|
+
id: "inv_1",
|
|
1479
|
+
revokedAt: at("2026-05-14T10:02:00.000Z"),
|
|
1480
|
+
})
|
|
1481
|
+
|
|
1482
|
+
await expectAuthError(
|
|
1483
|
+
storage.completeMagicLinkSignIn({
|
|
1484
|
+
projectId,
|
|
1485
|
+
magicLinkId: "ml_1",
|
|
1486
|
+
tokenHash: "link-hash",
|
|
1487
|
+
completedAt: at("2026-05-14T10:03:00.000Z"),
|
|
1488
|
+
newUserId: "usr_new",
|
|
1489
|
+
session: sessionInput("ses_new"),
|
|
1490
|
+
}),
|
|
1491
|
+
"user_creation_not_allowed"
|
|
1492
|
+
)
|
|
1493
|
+
await expect(
|
|
1494
|
+
storage.users.getByEmail({ projectId, email: "ava@acme.com" })
|
|
1495
|
+
).resolves.toBeNull()
|
|
1496
|
+
await expect(storage.magicLinks.getById({ projectId, id: "ml_1" })).resolves.toMatchObject({
|
|
1497
|
+
consumedAt: at("2026-05-14T10:03:00.000Z"),
|
|
1498
|
+
})
|
|
1499
|
+
})
|
|
1500
|
+
})
|
|
1501
|
+
|
|
1502
|
+
test("allows explicit bootstrap creation through magic-link completion", async () => {
|
|
1503
|
+
await withStorage(async (storage) => {
|
|
1504
|
+
await storage.magicLinks.create({
|
|
1505
|
+
id: "ml_1",
|
|
1506
|
+
projectId,
|
|
1507
|
+
strategyId: "magic-link",
|
|
1508
|
+
audience: "atlas",
|
|
1509
|
+
email: "founder@acme.com",
|
|
1510
|
+
tokenHash: "link-hash",
|
|
1511
|
+
createdAt: at("2026-05-14T10:01:00.000Z"),
|
|
1512
|
+
expiresAt: at("2026-05-14T10:16:00.000Z"),
|
|
1513
|
+
})
|
|
1514
|
+
|
|
1515
|
+
const result = await storage.completeMagicLinkSignIn({
|
|
1516
|
+
projectId,
|
|
1517
|
+
magicLinkId: "ml_1",
|
|
1518
|
+
tokenHash: "link-hash",
|
|
1519
|
+
completedAt: at("2026-05-14T10:03:00.000Z"),
|
|
1520
|
+
newUserId: "usr_founder",
|
|
1521
|
+
allowUserCreationWithoutInvitation: true,
|
|
1522
|
+
manualGroupIds: ["security-admins"],
|
|
1523
|
+
session: sessionInput("ses_founder"),
|
|
1524
|
+
})
|
|
1525
|
+
|
|
1526
|
+
expect(result.user).toMatchObject({
|
|
1527
|
+
id: "usr_founder",
|
|
1528
|
+
email: "founder@acme.com",
|
|
1529
|
+
})
|
|
1530
|
+
await expect(
|
|
1531
|
+
storage.groupMemberships.listForUser({ projectId, userId: "usr_founder" })
|
|
1532
|
+
).resolves.toMatchObject([{ groupId: "security-admins", source: "manual" }])
|
|
1533
|
+
})
|
|
1534
|
+
})
|
|
1535
|
+
|
|
1536
|
+
test("closes bootstrap user creation when an active user already exists", async () => {
|
|
1537
|
+
await withStorage(async (storage) => {
|
|
1538
|
+
await createUser(storage, {
|
|
1539
|
+
id: "usr_existing",
|
|
1540
|
+
email: "existing@acme.com",
|
|
1541
|
+
})
|
|
1542
|
+
await storage.magicLinks.create({
|
|
1543
|
+
id: "ml_1",
|
|
1544
|
+
projectId,
|
|
1545
|
+
strategyId: "magic-link",
|
|
1546
|
+
audience: "atlas",
|
|
1547
|
+
email: "founder@acme.com",
|
|
1548
|
+
tokenHash: "link-hash",
|
|
1549
|
+
createdAt: at("2026-05-14T10:01:00.000Z"),
|
|
1550
|
+
expiresAt: at("2026-05-14T10:16:00.000Z"),
|
|
1551
|
+
})
|
|
1552
|
+
|
|
1553
|
+
await expectAuthError(
|
|
1554
|
+
storage.completeMagicLinkSignIn({
|
|
1555
|
+
projectId,
|
|
1556
|
+
magicLinkId: "ml_1",
|
|
1557
|
+
tokenHash: "link-hash",
|
|
1558
|
+
completedAt: at("2026-05-14T10:03:00.000Z"),
|
|
1559
|
+
newUserId: "usr_founder",
|
|
1560
|
+
allowUserCreationWithoutInvitation: true,
|
|
1561
|
+
requireNoActiveUsersForUserCreation: true,
|
|
1562
|
+
session: sessionInput("ses_founder"),
|
|
1563
|
+
}),
|
|
1564
|
+
"user_creation_not_allowed"
|
|
1565
|
+
)
|
|
1566
|
+
await expect(
|
|
1567
|
+
storage.users.getByEmail({ projectId, email: "founder@acme.com" })
|
|
1568
|
+
).resolves.toBeNull()
|
|
1569
|
+
await expect(storage.magicLinks.getById({ projectId, id: "ml_1" })).resolves.toMatchObject({
|
|
1570
|
+
consumedAt: at("2026-05-14T10:03:00.000Z"),
|
|
1571
|
+
})
|
|
1572
|
+
})
|
|
1573
|
+
})
|
|
1574
|
+
|
|
1575
|
+
test("does not apply the bootstrap closure guard to invited user creation", async () => {
|
|
1576
|
+
await withStorage(async (storage) => {
|
|
1577
|
+
await createUser(storage, {
|
|
1578
|
+
id: "usr_existing",
|
|
1579
|
+
email: "existing@acme.com",
|
|
1580
|
+
})
|
|
1581
|
+
await storage.invitations.createOrUpdateActive({
|
|
1582
|
+
id: "inv_1",
|
|
1583
|
+
projectId,
|
|
1584
|
+
email: "invited@acme.com",
|
|
1585
|
+
groupIds: ["commercial"],
|
|
1586
|
+
createdAt: at("2026-05-14T10:00:00.000Z"),
|
|
1587
|
+
expiresAt: at("2026-05-21T10:00:00.000Z"),
|
|
1588
|
+
})
|
|
1589
|
+
await storage.magicLinks.create({
|
|
1590
|
+
id: "ml_1",
|
|
1591
|
+
projectId,
|
|
1592
|
+
strategyId: "magic-link",
|
|
1593
|
+
audience: "atlas",
|
|
1594
|
+
email: "invited@acme.com",
|
|
1595
|
+
tokenHash: "link-hash",
|
|
1596
|
+
createdAt: at("2026-05-14T10:01:00.000Z"),
|
|
1597
|
+
expiresAt: at("2026-05-14T10:16:00.000Z"),
|
|
1598
|
+
})
|
|
1599
|
+
|
|
1600
|
+
const result = await storage.completeMagicLinkSignIn({
|
|
1601
|
+
projectId,
|
|
1602
|
+
magicLinkId: "ml_1",
|
|
1603
|
+
tokenHash: "link-hash",
|
|
1604
|
+
completedAt: at("2026-05-14T10:03:00.000Z"),
|
|
1605
|
+
newUserId: "usr_invited",
|
|
1606
|
+
requireNoActiveUsersForUserCreation: true,
|
|
1607
|
+
session: sessionInput("ses_invited"),
|
|
1608
|
+
})
|
|
1609
|
+
|
|
1610
|
+
expect(result.user).toMatchObject({
|
|
1611
|
+
id: "usr_invited",
|
|
1612
|
+
email: "invited@acme.com",
|
|
1613
|
+
})
|
|
1614
|
+
expect(result.invitation).toMatchObject({
|
|
1615
|
+
id: "inv_1",
|
|
1616
|
+
status: "accepted",
|
|
1617
|
+
})
|
|
1618
|
+
})
|
|
1619
|
+
})
|
|
1620
|
+
|
|
1621
|
+
test("consumes valid magic links when an existing user is suspended", async () => {
|
|
1622
|
+
await withStorage(async (storage) => {
|
|
1623
|
+
await createUser(storage, { status: "suspended" })
|
|
1624
|
+
await storage.magicLinks.create({
|
|
1625
|
+
id: "ml_1",
|
|
1626
|
+
projectId,
|
|
1627
|
+
strategyId: "magic-link",
|
|
1628
|
+
audience: "atlas",
|
|
1629
|
+
email: "ava@acme.com",
|
|
1630
|
+
tokenHash: "link-hash",
|
|
1631
|
+
createdAt: at("2026-05-14T10:01:00.000Z"),
|
|
1632
|
+
expiresAt: at("2026-05-14T10:16:00.000Z"),
|
|
1633
|
+
})
|
|
1634
|
+
|
|
1635
|
+
await expectAuthError(
|
|
1636
|
+
storage.completeMagicLinkSignIn({
|
|
1637
|
+
projectId,
|
|
1638
|
+
magicLinkId: "ml_1",
|
|
1639
|
+
tokenHash: "link-hash",
|
|
1640
|
+
completedAt: at("2026-05-14T10:02:00.000Z"),
|
|
1641
|
+
newUserId: "usr_unused",
|
|
1642
|
+
session: sessionInput("ses_new"),
|
|
1643
|
+
}),
|
|
1644
|
+
"suspended_user"
|
|
1645
|
+
)
|
|
1646
|
+
await expect(storage.magicLinks.getById({ projectId, id: "ml_1" })).resolves.toMatchObject({
|
|
1647
|
+
consumedAt: at("2026-05-14T10:02:00.000Z"),
|
|
1648
|
+
})
|
|
1649
|
+
})
|
|
1650
|
+
})
|
|
1651
|
+
|
|
1652
|
+
test("completes OIDC sign-in through an existing identity", async () => {
|
|
1653
|
+
await withStorage(async (storage) => {
|
|
1654
|
+
await createUser(storage, { id: "usr_oidc", email: "ava@acme.com" })
|
|
1655
|
+
await storage.identities.upsert({
|
|
1656
|
+
projectId,
|
|
1657
|
+
strategyId: "okta",
|
|
1658
|
+
subject: "00u1",
|
|
1659
|
+
userId: "usr_oidc",
|
|
1660
|
+
claims: { email: "ava@acme.com" },
|
|
1661
|
+
createdAt: at("2026-05-14T10:00:00.000Z"),
|
|
1662
|
+
})
|
|
1663
|
+
await storage.oidcAuthorizationAttempts.create({
|
|
1664
|
+
id: "oidc_1",
|
|
1665
|
+
projectId,
|
|
1666
|
+
strategyId: "okta",
|
|
1667
|
+
audience: "atlas",
|
|
1668
|
+
stateHash: "state-hash",
|
|
1669
|
+
nonceHash: "nonce-hash",
|
|
1670
|
+
codeVerifier: "verifier",
|
|
1671
|
+
createdAt: at("2026-05-14T10:01:00.000Z"),
|
|
1672
|
+
expiresAt: at("2026-05-14T10:11:00.000Z"),
|
|
1673
|
+
})
|
|
1674
|
+
|
|
1675
|
+
const result = await storage.completeOidcSignIn({
|
|
1676
|
+
projectId,
|
|
1677
|
+
oidcAuthorizationAttemptId: "oidc_1",
|
|
1678
|
+
stateHash: "state-hash",
|
|
1679
|
+
completedAt: at("2026-05-14T10:02:00.000Z"),
|
|
1680
|
+
subject: "00u1",
|
|
1681
|
+
email: "renamed@acme.com",
|
|
1682
|
+
emailVerified: true,
|
|
1683
|
+
claims: { email: "renamed@acme.com" },
|
|
1684
|
+
newUserId: "usr_unused",
|
|
1685
|
+
session: sessionInput("ses_oidc"),
|
|
1686
|
+
})
|
|
1687
|
+
|
|
1688
|
+
expect(result.identity).toMatchObject({
|
|
1689
|
+
strategyId: "okta",
|
|
1690
|
+
subject: "00u1",
|
|
1691
|
+
userId: "usr_oidc",
|
|
1692
|
+
claims: { email: "renamed@acme.com" },
|
|
1693
|
+
})
|
|
1694
|
+
await expect(storage.users.getById({ projectId, id: "usr_oidc" })).resolves.toMatchObject({
|
|
1695
|
+
email: "ava@acme.com",
|
|
1696
|
+
})
|
|
1697
|
+
})
|
|
1698
|
+
})
|
|
1699
|
+
|
|
1700
|
+
test("auto-links OIDC by verified email only when explicitly allowed", async () => {
|
|
1701
|
+
await withStorage(async (storage) => {
|
|
1702
|
+
await createUser(storage, { id: "usr_existing", email: "ava@acme.com" })
|
|
1703
|
+
await storage.oidcAuthorizationAttempts.create({
|
|
1704
|
+
id: "oidc_blocked",
|
|
1705
|
+
projectId,
|
|
1706
|
+
strategyId: "okta",
|
|
1707
|
+
audience: "atlas",
|
|
1708
|
+
stateHash: "blocked-state",
|
|
1709
|
+
nonceHash: "nonce-hash",
|
|
1710
|
+
codeVerifier: "verifier",
|
|
1711
|
+
createdAt: at("2026-05-14T10:00:00.000Z"),
|
|
1712
|
+
expiresAt: at("2026-05-14T10:10:00.000Z"),
|
|
1713
|
+
})
|
|
1714
|
+
|
|
1715
|
+
await expectAuthError(
|
|
1716
|
+
storage.completeOidcSignIn({
|
|
1717
|
+
projectId,
|
|
1718
|
+
oidcAuthorizationAttemptId: "oidc_blocked",
|
|
1719
|
+
stateHash: "blocked-state",
|
|
1720
|
+
completedAt: at("2026-05-14T10:01:00.000Z"),
|
|
1721
|
+
subject: "00u1",
|
|
1722
|
+
email: "ava@acme.com",
|
|
1723
|
+
emailVerified: false,
|
|
1724
|
+
autoLinkByVerifiedEmail: true,
|
|
1725
|
+
newUserId: "usr_unused",
|
|
1726
|
+
session: sessionInput("ses_blocked"),
|
|
1727
|
+
}),
|
|
1728
|
+
"email_link_not_allowed"
|
|
1729
|
+
)
|
|
1730
|
+
|
|
1731
|
+
await storage.oidcAuthorizationAttempts.create({
|
|
1732
|
+
id: "oidc_allowed",
|
|
1733
|
+
projectId,
|
|
1734
|
+
strategyId: "okta",
|
|
1735
|
+
audience: "atlas",
|
|
1736
|
+
stateHash: "allowed-state",
|
|
1737
|
+
nonceHash: "nonce-hash",
|
|
1738
|
+
codeVerifier: "verifier",
|
|
1739
|
+
createdAt: at("2026-05-14T10:02:00.000Z"),
|
|
1740
|
+
expiresAt: at("2026-05-14T10:12:00.000Z"),
|
|
1741
|
+
})
|
|
1742
|
+
const result = await storage.completeOidcSignIn({
|
|
1743
|
+
projectId,
|
|
1744
|
+
oidcAuthorizationAttemptId: "oidc_allowed",
|
|
1745
|
+
stateHash: "allowed-state",
|
|
1746
|
+
completedAt: at("2026-05-14T10:03:00.000Z"),
|
|
1747
|
+
subject: "00u1",
|
|
1748
|
+
email: "ava@acme.com",
|
|
1749
|
+
emailVerified: true,
|
|
1750
|
+
autoLinkByVerifiedEmail: true,
|
|
1751
|
+
newUserId: "usr_unused",
|
|
1752
|
+
session: sessionInput("ses_allowed"),
|
|
1753
|
+
})
|
|
1754
|
+
|
|
1755
|
+
expect(result.user.id).toBe("usr_existing")
|
|
1756
|
+
expect(result.identity).toMatchObject({
|
|
1757
|
+
userId: "usr_existing",
|
|
1758
|
+
})
|
|
1759
|
+
})
|
|
1760
|
+
})
|
|
1761
|
+
|
|
1762
|
+
test("creates new OIDC users through active invitations and applies groups", async () => {
|
|
1763
|
+
await withStorage(async (storage) => {
|
|
1764
|
+
await storage.invitations.createOrUpdateActive({
|
|
1765
|
+
id: "inv_oidc",
|
|
1766
|
+
projectId,
|
|
1767
|
+
email: "ava@acme.com",
|
|
1768
|
+
groupIds: ["commercial"],
|
|
1769
|
+
createdAt: at("2026-05-14T09:59:00.000Z"),
|
|
1770
|
+
expiresAt: at("2026-05-21T10:00:00.000Z"),
|
|
1771
|
+
})
|
|
1772
|
+
await storage.oidcAuthorizationAttempts.create({
|
|
1773
|
+
id: "oidc_1",
|
|
1774
|
+
projectId,
|
|
1775
|
+
strategyId: "okta",
|
|
1776
|
+
audience: "atlas",
|
|
1777
|
+
stateHash: "state-hash",
|
|
1778
|
+
nonceHash: "nonce-hash",
|
|
1779
|
+
codeVerifier: "verifier",
|
|
1780
|
+
createdAt: at("2026-05-14T10:00:00.000Z"),
|
|
1781
|
+
expiresAt: at("2026-05-14T10:10:00.000Z"),
|
|
1782
|
+
})
|
|
1783
|
+
|
|
1784
|
+
const result = await storage.completeOidcSignIn({
|
|
1785
|
+
projectId,
|
|
1786
|
+
oidcAuthorizationAttemptId: "oidc_1",
|
|
1787
|
+
stateHash: "state-hash",
|
|
1788
|
+
completedAt: at("2026-05-14T10:01:00.000Z"),
|
|
1789
|
+
subject: "00u1",
|
|
1790
|
+
email: "ava@acme.com",
|
|
1791
|
+
displayName: "Ava Chen",
|
|
1792
|
+
emailVerified: true,
|
|
1793
|
+
newUserId: "usr_oidc",
|
|
1794
|
+
session: sessionInput("ses_oidc"),
|
|
1795
|
+
})
|
|
1796
|
+
|
|
1797
|
+
expect(result.user).toMatchObject({
|
|
1798
|
+
id: "usr_oidc",
|
|
1799
|
+
email: "ava@acme.com",
|
|
1800
|
+
displayName: "Ava Chen",
|
|
1801
|
+
})
|
|
1802
|
+
expect(result.invitation).toMatchObject({
|
|
1803
|
+
id: "inv_oidc",
|
|
1804
|
+
status: "accepted",
|
|
1805
|
+
})
|
|
1806
|
+
expect(result.identity).toMatchObject({
|
|
1807
|
+
strategyId: "okta",
|
|
1808
|
+
subject: "00u1",
|
|
1809
|
+
userId: "usr_oidc",
|
|
1810
|
+
})
|
|
1811
|
+
await expect(
|
|
1812
|
+
storage.groupMemberships.listForUser({ projectId, userId: "usr_oidc" })
|
|
1813
|
+
).resolves.toMatchObject([{ groupId: "commercial", source: "invitation" }])
|
|
1814
|
+
})
|
|
1815
|
+
})
|
|
1816
|
+
|
|
1817
|
+
test("does not create new OIDC users without invitation or bootstrap eligibility", async () => {
|
|
1818
|
+
await withStorage(async (storage) => {
|
|
1819
|
+
await storage.oidcAuthorizationAttempts.create({
|
|
1820
|
+
id: "oidc_1",
|
|
1821
|
+
projectId,
|
|
1822
|
+
strategyId: "okta",
|
|
1823
|
+
audience: "atlas",
|
|
1824
|
+
stateHash: "state-hash",
|
|
1825
|
+
nonceHash: "nonce-hash",
|
|
1826
|
+
codeVerifier: "verifier",
|
|
1827
|
+
createdAt: at("2026-05-14T10:00:00.000Z"),
|
|
1828
|
+
expiresAt: at("2026-05-14T10:10:00.000Z"),
|
|
1829
|
+
})
|
|
1830
|
+
|
|
1831
|
+
await expectAuthError(
|
|
1832
|
+
storage.completeOidcSignIn({
|
|
1833
|
+
projectId,
|
|
1834
|
+
oidcAuthorizationAttemptId: "oidc_1",
|
|
1835
|
+
stateHash: "state-hash",
|
|
1836
|
+
completedAt: at("2026-05-14T10:01:00.000Z"),
|
|
1837
|
+
subject: "00u1",
|
|
1838
|
+
email: "ava@acme.com",
|
|
1839
|
+
emailVerified: true,
|
|
1840
|
+
newUserId: "usr_oidc",
|
|
1841
|
+
session: sessionInput("ses_oidc"),
|
|
1842
|
+
}),
|
|
1843
|
+
"user_creation_not_allowed"
|
|
1844
|
+
)
|
|
1845
|
+
await expect(
|
|
1846
|
+
storage.users.getByEmail({ projectId, email: "ava@acme.com" })
|
|
1847
|
+
).resolves.toBeNull()
|
|
1848
|
+
})
|
|
1849
|
+
})
|
|
1850
|
+
|
|
1851
|
+
test("allows first OIDC bootstrap user creation with manual groups", async () => {
|
|
1852
|
+
await withStorage(async (storage) => {
|
|
1853
|
+
await storage.oidcAuthorizationAttempts.create({
|
|
1854
|
+
id: "oidc_bootstrap",
|
|
1855
|
+
projectId,
|
|
1856
|
+
strategyId: "okta",
|
|
1857
|
+
audience: "atlas",
|
|
1858
|
+
stateHash: "bootstrap-state",
|
|
1859
|
+
nonceHash: "nonce-hash",
|
|
1860
|
+
codeVerifier: "verifier",
|
|
1861
|
+
createdAt: at("2026-05-14T10:00:00.000Z"),
|
|
1862
|
+
expiresAt: at("2026-05-14T10:10:00.000Z"),
|
|
1863
|
+
})
|
|
1864
|
+
|
|
1865
|
+
const result = await storage.completeOidcSignIn({
|
|
1866
|
+
projectId,
|
|
1867
|
+
oidcAuthorizationAttemptId: "oidc_bootstrap",
|
|
1868
|
+
stateHash: "bootstrap-state",
|
|
1869
|
+
completedAt: at("2026-05-14T10:01:00.000Z"),
|
|
1870
|
+
subject: "00u1",
|
|
1871
|
+
email: "founder@acme.com",
|
|
1872
|
+
emailVerified: true,
|
|
1873
|
+
allowUserCreationWithoutInvitation: true,
|
|
1874
|
+
requireNoActiveUsersForUserCreation: true,
|
|
1875
|
+
manualGroupIds: ["security-admins"],
|
|
1876
|
+
newUserId: "usr_founder",
|
|
1877
|
+
session: sessionInput("ses_oidc_bootstrap"),
|
|
1878
|
+
})
|
|
1879
|
+
|
|
1880
|
+
expect(result.user).toMatchObject({
|
|
1881
|
+
id: "usr_founder",
|
|
1882
|
+
email: "founder@acme.com",
|
|
1883
|
+
})
|
|
1884
|
+
await expect(
|
|
1885
|
+
storage.groupMemberships.listForUser({ projectId, userId: "usr_founder" })
|
|
1886
|
+
).resolves.toMatchObject([{ groupId: "security-admins", source: "manual" }])
|
|
1887
|
+
})
|
|
1888
|
+
})
|
|
1889
|
+
|
|
1890
|
+
test("suspends users and revokes active sessions immediately", async () => {
|
|
1891
|
+
await withStorage(async (storage) => {
|
|
1892
|
+
await createUser(storage)
|
|
1893
|
+
await storage.sessions.create({
|
|
1894
|
+
id: "ses_1",
|
|
1895
|
+
projectId,
|
|
1896
|
+
userId: "usr_1",
|
|
1897
|
+
strategyId: "magic-link",
|
|
1898
|
+
audience: "atlas",
|
|
1899
|
+
tokenHash: "hash-1",
|
|
1900
|
+
createdAt: at("2026-05-14T10:00:00.000Z"),
|
|
1901
|
+
expiresAt: at("2026-05-21T10:00:00.000Z"),
|
|
1902
|
+
})
|
|
1903
|
+
await storage.sessions.create({
|
|
1904
|
+
id: "ses_app",
|
|
1905
|
+
projectId,
|
|
1906
|
+
userId: "usr_1",
|
|
1907
|
+
strategyId: "magic-link",
|
|
1908
|
+
audience: "app",
|
|
1909
|
+
tokenHash: "hash-app",
|
|
1910
|
+
createdAt: at("2026-05-14T10:01:00.000Z"),
|
|
1911
|
+
expiresAt: at("2026-05-21T10:01:00.000Z"),
|
|
1912
|
+
})
|
|
1913
|
+
|
|
1914
|
+
const suspended = await storage.suspendUserAndRevokeSessions({
|
|
1915
|
+
projectId,
|
|
1916
|
+
userId: "usr_1",
|
|
1917
|
+
suspendedAt: at("2026-05-14T10:05:00.000Z"),
|
|
1918
|
+
})
|
|
1919
|
+
|
|
1920
|
+
expect(suspended.status).toBe("suspended")
|
|
1921
|
+
await expect(storage.sessions.getById({ projectId, id: "ses_1" })).resolves.toMatchObject({
|
|
1922
|
+
revokedAt: at("2026-05-14T10:05:00.000Z"),
|
|
1923
|
+
})
|
|
1924
|
+
await expect(storage.sessions.getById({ projectId, id: "ses_app" })).resolves.toMatchObject(
|
|
1925
|
+
{
|
|
1926
|
+
revokedAt: at("2026-05-14T10:05:00.000Z"),
|
|
1927
|
+
}
|
|
1928
|
+
)
|
|
1929
|
+
})
|
|
1930
|
+
})
|
|
1931
|
+
})
|
|
1932
|
+
}
|