@dads-framework/spicedb-access 0.0.0-stage → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +21 -0
- package/README.md +80 -2
- package/bin/dads-import-spicedb.mjs +139 -0
- package/dist/authz-journal/index.d.ts +3 -0
- package/dist/authz-journal/index.d.ts.map +1 -0
- package/dist/authz-journal/index.js +3 -0
- package/dist/authz-journal/index.js.map +1 -0
- package/dist/authz-journal/migration-journal.access.d.ts +11 -0
- package/dist/authz-journal/migration-journal.access.d.ts.map +1 -0
- package/dist/authz-journal/migration-journal.access.js +16 -0
- package/dist/authz-journal/migration-journal.access.js.map +1 -0
- package/dist/authz-journal/migration-version.access.d.ts +7 -0
- package/dist/authz-journal/migration-version.access.d.ts.map +1 -0
- package/dist/authz-journal/migration-version.access.js +11 -0
- package/dist/authz-journal/migration-version.access.js.map +1 -0
- package/dist/index.d.ts +44 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +43 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/access/check-all.d.ts +8 -0
- package/dist/lib/access/check-all.d.ts.map +1 -0
- package/dist/lib/access/check-all.js +11 -0
- package/dist/lib/access/check-all.js.map +1 -0
- package/dist/lib/access/guarded-authorization.d.ts +71 -0
- package/dist/lib/access/guarded-authorization.d.ts.map +1 -0
- package/dist/lib/access/guarded-authorization.js +162 -0
- package/dist/lib/access/guarded-authorization.js.map +1 -0
- package/dist/lib/access/list-only-visible.d.ts +23 -0
- package/dist/lib/access/list-only-visible.d.ts.map +1 -0
- package/dist/lib/access/list-only-visible.js +21 -0
- package/dist/lib/access/list-only-visible.js.map +1 -0
- package/dist/lib/access/logic/spice-db-empty-schema.d.ts +3 -0
- package/dist/lib/access/logic/spice-db-empty-schema.d.ts.map +1 -0
- package/dist/lib/access/logic/spice-db-empty-schema.js +17 -0
- package/dist/lib/access/logic/spice-db-empty-schema.js.map +1 -0
- package/dist/lib/access/logic/spice-db-security.d.ts +4 -0
- package/dist/lib/access/logic/spice-db-security.d.ts.map +1 -0
- package/dist/lib/access/logic/spice-db-security.js +8 -0
- package/dist/lib/access/logic/spice-db-security.js.map +1 -0
- package/dist/lib/access/logic/spice-db-write-retry.d.ts +22 -0
- package/dist/lib/access/logic/spice-db-write-retry.d.ts.map +1 -0
- package/dist/lib/access/logic/spice-db-write-retry.js +35 -0
- package/dist/lib/access/logic/spice-db-write-retry.js.map +1 -0
- package/dist/lib/access/missing-ownership-tuples.d.ts +19 -0
- package/dist/lib/access/missing-ownership-tuples.d.ts.map +1 -0
- package/dist/lib/access/missing-ownership-tuples.js +12 -0
- package/dist/lib/access/missing-ownership-tuples.js.map +1 -0
- package/dist/lib/access/newest-written-token.d.ts +37 -0
- package/dist/lib/access/newest-written-token.d.ts.map +1 -0
- package/dist/lib/access/newest-written-token.js +56 -0
- package/dist/lib/access/newest-written-token.js.map +1 -0
- package/dist/lib/access/one-write-at-a-time.d.ts +14 -0
- package/dist/lib/access/one-write-at-a-time.d.ts.map +1 -0
- package/dist/lib/access/one-write-at-a-time.js +18 -0
- package/dist/lib/access/one-write-at-a-time.js.map +1 -0
- package/dist/lib/access/spice-db-authorization.d.ts +102 -0
- package/dist/lib/access/spice-db-authorization.d.ts.map +1 -0
- package/dist/lib/access/spice-db-authorization.js +275 -0
- package/dist/lib/access/spice-db-authorization.js.map +1 -0
- package/dist/lib/access/spice-db-clients.d.ts +19 -0
- package/dist/lib/access/spice-db-clients.d.ts.map +1 -0
- package/dist/lib/access/spice-db-clients.js +27 -0
- package/dist/lib/access/spice-db-clients.js.map +1 -0
- package/dist/lib/access/spice-db-consistency.d.ts +24 -0
- package/dist/lib/access/spice-db-consistency.d.ts.map +1 -0
- package/dist/lib/access/spice-db-consistency.js +44 -0
- package/dist/lib/access/spice-db-consistency.js.map +1 -0
- package/dist/lib/access/spice-db-permission-checks.d.ts +21 -0
- package/dist/lib/access/spice-db-permission-checks.d.ts.map +1 -0
- package/dist/lib/access/spice-db-permission-checks.js +102 -0
- package/dist/lib/access/spice-db-permission-checks.js.map +1 -0
- package/dist/lib/access/spice-db-relationship-read.d.ts +5 -0
- package/dist/lib/access/spice-db-relationship-read.d.ts.map +1 -0
- package/dist/lib/access/spice-db-relationship-read.js +21 -0
- package/dist/lib/access/spice-db-relationship-read.js.map +1 -0
- package/dist/lib/access/spice-db-write-deadline.d.ts +23 -0
- package/dist/lib/access/spice-db-write-deadline.d.ts.map +1 -0
- package/dist/lib/access/spice-db-write-deadline.js +41 -0
- package/dist/lib/access/spice-db-write-deadline.js.map +1 -0
- package/dist/lib/access/tallied-authorization.d.ts +31 -0
- package/dist/lib/access/tallied-authorization.d.ts.map +1 -0
- package/dist/lib/access/tallied-authorization.js +62 -0
- package/dist/lib/access/tallied-authorization.js.map +1 -0
- package/dist/lib/access/testing/acting-company-fixture.d.ts +46 -0
- package/dist/lib/access/testing/acting-company-fixture.d.ts.map +1 -0
- package/dist/lib/access/testing/acting-company-fixture.js +74 -0
- package/dist/lib/access/testing/acting-company-fixture.js.map +1 -0
- package/dist/lib/access-changes/access-change.ids.d.ts +5 -0
- package/dist/lib/access-changes/access-change.ids.d.ts.map +1 -0
- package/dist/lib/access-changes/access-change.ids.js +4 -0
- package/dist/lib/access-changes/access-change.ids.js.map +1 -0
- package/dist/lib/access-changes/apply-after-commit.d.ts +25 -0
- package/dist/lib/access-changes/apply-after-commit.d.ts.map +1 -0
- package/dist/lib/access-changes/apply-after-commit.js +91 -0
- package/dist/lib/access-changes/apply-after-commit.js.map +1 -0
- package/dist/lib/access-changes/apply.d.ts +60 -0
- package/dist/lib/access-changes/apply.d.ts.map +1 -0
- package/dist/lib/access-changes/apply.js +133 -0
- package/dist/lib/access-changes/apply.js.map +1 -0
- package/dist/lib/access-changes/claim.d.ts +79 -0
- package/dist/lib/access-changes/claim.d.ts.map +1 -0
- package/dist/lib/access-changes/claim.js +3 -0
- package/dist/lib/access-changes/claim.js.map +1 -0
- package/dist/lib/access-changes/complete.d.ts +38 -0
- package/dist/lib/access-changes/complete.d.ts.map +1 -0
- package/dist/lib/access-changes/complete.js +129 -0
- package/dist/lib/access-changes/complete.js.map +1 -0
- package/dist/lib/access-changes/completion-status.d.ts +21 -0
- package/dist/lib/access-changes/completion-status.d.ts.map +1 -0
- package/dist/lib/access-changes/completion-status.js +7 -0
- package/dist/lib/access-changes/completion-status.js.map +1 -0
- package/dist/lib/access-changes/enqueue.d.ts +14 -0
- package/dist/lib/access-changes/enqueue.d.ts.map +1 -0
- package/dist/lib/access-changes/enqueue.js +5 -0
- package/dist/lib/access-changes/enqueue.js.map +1 -0
- package/dist/lib/access-changes/logic/claim-rules.d.ts +49 -0
- package/dist/lib/access-changes/logic/claim-rules.d.ts.map +1 -0
- package/dist/lib/access-changes/logic/claim-rules.js +48 -0
- package/dist/lib/access-changes/logic/claim-rules.js.map +1 -0
- package/dist/lib/access-changes/postgres/access-changes.tables.d.ts +342 -0
- package/dist/lib/access-changes/postgres/access-changes.tables.d.ts.map +1 -0
- package/dist/lib/access-changes/postgres/access-changes.tables.js +36 -0
- package/dist/lib/access-changes/postgres/access-changes.tables.js.map +1 -0
- package/dist/lib/access-changes/postgres/claim.d.ts +43 -0
- package/dist/lib/access-changes/postgres/claim.d.ts.map +1 -0
- package/dist/lib/access-changes/postgres/claim.js +132 -0
- package/dist/lib/access-changes/postgres/claim.js.map +1 -0
- package/dist/lib/access-changes/postgres/completion-status.d.ts +27 -0
- package/dist/lib/access-changes/postgres/completion-status.d.ts.map +1 -0
- package/dist/lib/access-changes/postgres/completion-status.js +64 -0
- package/dist/lib/access-changes/postgres/completion-status.js.map +1 -0
- package/dist/lib/access-changes/postgres/enqueue.d.ts +30 -0
- package/dist/lib/access-changes/postgres/enqueue.d.ts.map +1 -0
- package/dist/lib/access-changes/postgres/enqueue.js +92 -0
- package/dist/lib/access-changes/postgres/enqueue.js.map +1 -0
- package/dist/lib/access-changes/postgres/migrations/20260828163001_authorization_outbox.migration.d.ts +4 -0
- package/dist/lib/access-changes/postgres/migrations/20260828163001_authorization_outbox.migration.d.ts.map +1 -0
- package/dist/lib/access-changes/postgres/migrations/20260828163001_authorization_outbox.migration.js +43 -0
- package/dist/lib/access-changes/postgres/migrations/20260828163001_authorization_outbox.migration.js.map +1 -0
- package/dist/lib/access-changes/postgres/owner-lock.d.ts +85 -0
- package/dist/lib/access-changes/postgres/owner-lock.d.ts.map +1 -0
- package/dist/lib/access-changes/postgres/owner-lock.js +219 -0
- package/dist/lib/access-changes/postgres/owner-lock.js.map +1 -0
- package/dist/lib/access-changes/postgres/requeue-failed.d.ts +17 -0
- package/dist/lib/access-changes/postgres/requeue-failed.d.ts.map +1 -0
- package/dist/lib/access-changes/postgres/requeue-failed.js +25 -0
- package/dist/lib/access-changes/postgres/requeue-failed.js.map +1 -0
- package/dist/lib/access-changes/revoke.d.ts +104 -0
- package/dist/lib/access-changes/revoke.d.ts.map +1 -0
- package/dist/lib/access-changes/revoke.js +48 -0
- package/dist/lib/access-changes/revoke.js.map +1 -0
- package/dist/lib/access-changes/synced-row-relationships.d.ts +56 -0
- package/dist/lib/access-changes/synced-row-relationships.d.ts.map +1 -0
- package/dist/lib/access-changes/synced-row-relationships.js +111 -0
- package/dist/lib/access-changes/synced-row-relationships.js.map +1 -0
- package/dist/lib/catalog-sizes/audit-catalog-sizes.job.d.ts +41 -0
- package/dist/lib/catalog-sizes/audit-catalog-sizes.job.d.ts.map +1 -0
- package/dist/lib/catalog-sizes/audit-catalog-sizes.job.js +77 -0
- package/dist/lib/catalog-sizes/audit-catalog-sizes.job.js.map +1 -0
- package/dist/lib/catalog-sizes/catalog-size-reader.d.ts +15 -0
- package/dist/lib/catalog-sizes/catalog-size-reader.d.ts.map +1 -0
- package/dist/lib/catalog-sizes/catalog-size-reader.js +41 -0
- package/dist/lib/catalog-sizes/catalog-size-reader.js.map +1 -0
- package/dist/lib/catalog-sizes/catalog-tables.d.ts +38 -0
- package/dist/lib/catalog-sizes/catalog-tables.d.ts.map +1 -0
- package/dist/lib/catalog-sizes/catalog-tables.js +52 -0
- package/dist/lib/catalog-sizes/catalog-tables.js.map +1 -0
- package/dist/lib/schema-migrate/clone-spice-db-datastore.d.ts +9 -0
- package/dist/lib/schema-migrate/clone-spice-db-datastore.d.ts.map +1 -0
- package/dist/lib/schema-migrate/clone-spice-db-datastore.js +47 -0
- package/dist/lib/schema-migrate/clone-spice-db-datastore.js.map +1 -0
- package/dist/lib/schema-migrate/parse-authorization-schema-migration-environment.d.ts +31 -0
- package/dist/lib/schema-migrate/parse-authorization-schema-migration-environment.d.ts.map +1 -0
- package/dist/lib/schema-migrate/parse-authorization-schema-migration-environment.js +26 -0
- package/dist/lib/schema-migrate/parse-authorization-schema-migration-environment.js.map +1 -0
- package/dist/lib/scoped-lists/keep-permitted.d.ts +24 -0
- package/dist/lib/scoped-lists/keep-permitted.d.ts.map +1 -0
- package/dist/lib/scoped-lists/keep-permitted.js +29 -0
- package/dist/lib/scoped-lists/keep-permitted.js.map +1 -0
- package/dist/lib/scoped-lists/scope-predicate.d.ts +18 -0
- package/dist/lib/scoped-lists/scope-predicate.d.ts.map +1 -0
- package/dist/lib/scoped-lists/scope-predicate.js +96 -0
- package/dist/lib/scoped-lists/scope-predicate.js.map +1 -0
- package/dist/lib/scoped-lists/scope-sql-bindings.d.ts +64 -0
- package/dist/lib/scoped-lists/scope-sql-bindings.d.ts.map +1 -0
- package/dist/lib/scoped-lists/scope-sql-bindings.js +45 -0
- package/dist/lib/scoped-lists/scope-sql-bindings.js.map +1 -0
- package/dist/lib/scoped-lists/testing/scoped-list-fixture.d.ts +369 -0
- package/dist/lib/scoped-lists/testing/scoped-list-fixture.d.ts.map +1 -0
- package/dist/lib/scoped-lists/testing/scoped-list-fixture.js +145 -0
- package/dist/lib/scoped-lists/testing/scoped-list-fixture.js.map +1 -0
- package/dist/migration/definition-changes.d.mts +28 -0
- package/dist/migration/definition-changes.d.mts.map +1 -0
- package/dist/migration/definition-changes.mjs +282 -0
- package/dist/migration/definition-changes.mjs.map +1 -0
- package/dist/migration/index.d.ts +15 -0
- package/dist/migration/index.d.ts.map +1 -0
- package/dist/migration/index.js +14 -0
- package/dist/migration/index.js.map +1 -0
- package/dist/migration/lib/access-migrations/assert-access-migrations-up-to-date.d.ts +26 -0
- package/dist/migration/lib/access-migrations/assert-access-migrations-up-to-date.d.ts.map +1 -0
- package/dist/migration/lib/access-migrations/assert-access-migrations-up-to-date.js +57 -0
- package/dist/migration/lib/access-migrations/assert-access-migrations-up-to-date.js.map +1 -0
- package/dist/migration/lib/access-migrations/define-access-migration.d.ts +51 -0
- package/dist/migration/lib/access-migrations/define-access-migration.d.ts.map +1 -0
- package/dist/migration/lib/access-migrations/define-access-migration.js +63 -0
- package/dist/migration/lib/access-migrations/define-access-migration.js.map +1 -0
- package/dist/migration/lib/access-migrations/diff-access-models-format.d.ts +12 -0
- package/dist/migration/lib/access-migrations/diff-access-models-format.d.ts.map +1 -0
- package/dist/migration/lib/access-migrations/diff-access-models-format.js +81 -0
- package/dist/migration/lib/access-migrations/diff-access-models-format.js.map +1 -0
- package/dist/migration/lib/access-migrations/diff-access-models.d.ts +79 -0
- package/dist/migration/lib/access-migrations/diff-access-models.d.ts.map +1 -0
- package/dist/migration/lib/access-migrations/diff-access-models.js +197 -0
- package/dist/migration/lib/access-migrations/diff-access-models.js.map +1 -0
- package/dist/migration/lib/access-migrations/index.d.ts +8 -0
- package/dist/migration/lib/access-migrations/index.d.ts.map +1 -0
- package/dist/migration/lib/access-migrations/index.js +8 -0
- package/dist/migration/lib/access-migrations/index.js.map +1 -0
- package/dist/migration/lib/access-migrations/run-postgres-access-migrations.d.ts +17 -0
- package/dist/migration/lib/access-migrations/run-postgres-access-migrations.d.ts.map +1 -0
- package/dist/migration/lib/access-migrations/run-postgres-access-migrations.js +105 -0
- package/dist/migration/lib/access-migrations/run-postgres-access-migrations.js.map +1 -0
- package/dist/migration/lib/access-migrations/run-spicedb-access-migrations.d.ts +21 -0
- package/dist/migration/lib/access-migrations/run-spicedb-access-migrations.d.ts.map +1 -0
- package/dist/migration/lib/access-migrations/run-spicedb-access-migrations.js +64 -0
- package/dist/migration/lib/access-migrations/run-spicedb-access-migrations.js.map +1 -0
- package/dist/migration/lib/access-migrations/run-sqlite-access-migrations.d.ts +18 -0
- package/dist/migration/lib/access-migrations/run-sqlite-access-migrations.d.ts.map +1 -0
- package/dist/migration/lib/access-migrations/run-sqlite-access-migrations.js +102 -0
- package/dist/migration/lib/access-migrations/run-sqlite-access-migrations.js.map +1 -0
- package/dist/migration/lib/access-migrations/sql-migration-types.d.ts +52 -0
- package/dist/migration/lib/access-migrations/sql-migration-types.d.ts.map +1 -0
- package/dist/migration/lib/access-migrations/sql-migration-types.js +57 -0
- package/dist/migration/lib/access-migrations/sql-migration-types.js.map +1 -0
- package/dist/migration/lib/journal/authorization-change-files.d.ts +7 -0
- package/dist/migration/lib/journal/authorization-change-files.d.ts.map +1 -0
- package/dist/migration/lib/journal/authorization-change-files.js +94 -0
- package/dist/migration/lib/journal/authorization-change-files.js.map +1 -0
- package/dist/migration/lib/journal/journal-entry.d.ts +47 -0
- package/dist/migration/lib/journal/journal-entry.d.ts.map +1 -0
- package/dist/migration/lib/journal/journal-entry.js +2 -0
- package/dist/migration/lib/journal/journal-entry.js.map +1 -0
- package/dist/migration/lib/journal/load-authorization-changes.d.ts +9 -0
- package/dist/migration/lib/journal/load-authorization-changes.d.ts.map +1 -0
- package/dist/migration/lib/journal/load-authorization-changes.js +32 -0
- package/dist/migration/lib/journal/load-authorization-changes.js.map +1 -0
- package/dist/migration/lib/journal/load-journal.d.ts +21 -0
- package/dist/migration/lib/journal/load-journal.d.ts.map +1 -0
- package/dist/migration/lib/journal/load-journal.js +73 -0
- package/dist/migration/lib/journal/load-journal.js.map +1 -0
- package/dist/migration/lib/journal/read-authorization-migration-status.d.ts +10 -0
- package/dist/migration/lib/journal/read-authorization-migration-status.d.ts.map +1 -0
- package/dist/migration/lib/journal/read-authorization-migration-status.js +64 -0
- package/dist/migration/lib/journal/read-authorization-migration-status.js.map +1 -0
- package/dist/migration/lib/logic/authorization-change-history.d.ts +22 -0
- package/dist/migration/lib/logic/authorization-change-history.d.ts.map +1 -0
- package/dist/migration/lib/logic/authorization-change-history.js +103 -0
- package/dist/migration/lib/logic/authorization-change-history.js.map +1 -0
- package/dist/migration/lib/logic/classify-schema-diff.d.ts +26 -0
- package/dist/migration/lib/logic/classify-schema-diff.d.ts.map +1 -0
- package/dist/migration/lib/logic/classify-schema-diff.js +104 -0
- package/dist/migration/lib/logic/classify-schema-diff.js.map +1 -0
- package/dist/migration/lib/postgres-to-spicedb/authzed-target-adapter.d.ts +62 -0
- package/dist/migration/lib/postgres-to-spicedb/authzed-target-adapter.d.ts.map +1 -0
- package/dist/migration/lib/postgres-to-spicedb/authzed-target-adapter.js +63 -0
- package/dist/migration/lib/postgres-to-spicedb/authzed-target-adapter.js.map +1 -0
- package/dist/migration/lib/postgres-to-spicedb/column-relation-outbox-triggers.d.ts +45 -0
- package/dist/migration/lib/postgres-to-spicedb/column-relation-outbox-triggers.d.ts.map +1 -0
- package/dist/migration/lib/postgres-to-spicedb/column-relation-outbox-triggers.js +140 -0
- package/dist/migration/lib/postgres-to-spicedb/column-relation-outbox-triggers.js.map +1 -0
- package/dist/migration/lib/postgres-to-spicedb/index.d.ts +4 -0
- package/dist/migration/lib/postgres-to-spicedb/index.d.ts.map +1 -0
- package/dist/migration/lib/postgres-to-spicedb/index.js +4 -0
- package/dist/migration/lib/postgres-to-spicedb/index.js.map +1 -0
- package/dist/migration/lib/postgres-to-spicedb/migrate-postgres-to-spicedb.d.ts +47 -0
- package/dist/migration/lib/postgres-to-spicedb/migrate-postgres-to-spicedb.d.ts.map +1 -0
- package/dist/migration/lib/postgres-to-spicedb/migrate-postgres-to-spicedb.js +199 -0
- package/dist/migration/lib/postgres-to-spicedb/migrate-postgres-to-spicedb.js.map +1 -0
- package/dist/migration/lib/run-authorization-changes.d.ts +5 -0
- package/dist/migration/lib/run-authorization-changes.d.ts.map +1 -0
- package/dist/migration/lib/run-authorization-changes.js +159 -0
- package/dist/migration/lib/run-authorization-changes.js.map +1 -0
- package/dist/migration/lib/run-authorization-migrations.d.ts +47 -0
- package/dist/migration/lib/run-authorization-migrations.d.ts.map +1 -0
- package/dist/migration/lib/run-authorization-migrations.js +202 -0
- package/dist/migration/lib/run-authorization-migrations.js.map +1 -0
- package/dist/migration/lib/scaffold/build-migration-bridge-schema.d.ts +7 -0
- package/dist/migration/lib/scaffold/build-migration-bridge-schema.d.ts.map +1 -0
- package/dist/migration/lib/scaffold/build-migration-bridge-schema.js +83 -0
- package/dist/migration/lib/scaffold/build-migration-bridge-schema.js.map +1 -0
- package/dist/migration/lib/scaffold/renumber-migration.d.ts +69 -0
- package/dist/migration/lib/scaffold/renumber-migration.d.ts.map +1 -0
- package/dist/migration/lib/scaffold/renumber-migration.js +170 -0
- package/dist/migration/lib/scaffold/renumber-migration.js.map +1 -0
- package/dist/migration/lib/scaffold/scaffold-authorization-change.d.ts +19 -0
- package/dist/migration/lib/scaffold/scaffold-authorization-change.d.ts.map +1 -0
- package/dist/migration/lib/scaffold/scaffold-authorization-change.js +47 -0
- package/dist/migration/lib/scaffold/scaffold-authorization-change.js.map +1 -0
- package/dist/migration/lib/scaffold/scaffold-migration.d.ts +32 -0
- package/dist/migration/lib/scaffold/scaffold-migration.d.ts.map +1 -0
- package/dist/migration/lib/scaffold/scaffold-migration.js +89 -0
- package/dist/migration/lib/scaffold/scaffold-migration.js.map +1 -0
- package/dist/migration/lib/spicedb-to-postgres/access-model-from-ir.d.ts +8 -0
- package/dist/migration/lib/spicedb-to-postgres/access-model-from-ir.d.ts.map +1 -0
- package/dist/migration/lib/spicedb-to-postgres/access-model-from-ir.js +10 -0
- package/dist/migration/lib/spicedb-to-postgres/access-model-from-ir.js.map +1 -0
- package/dist/migration/lib/spicedb-to-postgres/authzed-client-adapter.d.ts +94 -0
- package/dist/migration/lib/spicedb-to-postgres/authzed-client-adapter.d.ts.map +1 -0
- package/dist/migration/lib/spicedb-to-postgres/authzed-client-adapter.js +100 -0
- package/dist/migration/lib/spicedb-to-postgres/authzed-client-adapter.js.map +1 -0
- package/dist/migration/lib/spicedb-to-postgres/cli-args.d.ts +30 -0
- package/dist/migration/lib/spicedb-to-postgres/cli-args.d.ts.map +1 -0
- package/dist/migration/lib/spicedb-to-postgres/cli-args.js +208 -0
- package/dist/migration/lib/spicedb-to-postgres/cli-args.js.map +1 -0
- package/dist/migration/lib/spicedb-to-postgres/cli-format.d.ts +16 -0
- package/dist/migration/lib/spicedb-to-postgres/cli-format.d.ts.map +1 -0
- package/dist/migration/lib/spicedb-to-postgres/cli-format.js +77 -0
- package/dist/migration/lib/spicedb-to-postgres/cli-format.js.map +1 -0
- package/dist/migration/lib/spicedb-to-postgres/cli.d.ts +47 -0
- package/dist/migration/lib/spicedb-to-postgres/cli.d.ts.map +1 -0
- package/dist/migration/lib/spicedb-to-postgres/cli.js +165 -0
- package/dist/migration/lib/spicedb-to-postgres/cli.js.map +1 -0
- package/dist/migration/lib/spicedb-to-postgres/index.d.ts +8 -0
- package/dist/migration/lib/spicedb-to-postgres/index.d.ts.map +1 -0
- package/dist/migration/lib/spicedb-to-postgres/index.js +8 -0
- package/dist/migration/lib/spicedb-to-postgres/index.js.map +1 -0
- package/dist/migration/lib/spicedb-to-postgres/migrate-spicedb-to-postgres.d.ts +36 -0
- package/dist/migration/lib/spicedb-to-postgres/migrate-spicedb-to-postgres.d.ts.map +1 -0
- package/dist/migration/lib/spicedb-to-postgres/migrate-spicedb-to-postgres.js +129 -0
- package/dist/migration/lib/spicedb-to-postgres/migrate-spicedb-to-postgres.js.map +1 -0
- package/dist/migration/lib/spicedb-to-postgres/postgres-relationship-ddl.d.ts +13 -0
- package/dist/migration/lib/spicedb-to-postgres/postgres-relationship-ddl.d.ts.map +1 -0
- package/dist/migration/lib/spicedb-to-postgres/postgres-relationship-ddl.js +60 -0
- package/dist/migration/lib/spicedb-to-postgres/postgres-relationship-ddl.js.map +1 -0
- package/dist/migration/lib/spicedb-to-postgres/verify-parity.d.ts +51 -0
- package/dist/migration/lib/spicedb-to-postgres/verify-parity.d.ts.map +1 -0
- package/dist/migration/lib/spicedb-to-postgres/verify-parity.js +174 -0
- package/dist/migration/lib/spicedb-to-postgres/verify-parity.js.map +1 -0
- package/dist/migration/testing/fake-schema-store.d.ts +31 -0
- package/dist/migration/testing/fake-schema-store.d.ts.map +1 -0
- package/dist/migration/testing/fake-schema-store.js +79 -0
- package/dist/migration/testing/fake-schema-store.js.map +1 -0
- package/dist/spicedb-access.tsbuildinfo +1 -0
- package/dist/testing/create-shared-test-spice-db.d.ts +4 -0
- package/dist/testing/create-shared-test-spice-db.d.ts.map +1 -0
- package/dist/testing/create-shared-test-spice-db.js +9 -0
- package/dist/testing/create-shared-test-spice-db.js.map +1 -0
- package/dist/testing/fake-apply-after-commit.d.ts +29 -0
- package/dist/testing/fake-apply-after-commit.d.ts.map +1 -0
- package/dist/testing/fake-apply-after-commit.js +50 -0
- package/dist/testing/fake-apply-after-commit.js.map +1 -0
- package/dist/testing/fake-claim.d.ts +50 -0
- package/dist/testing/fake-claim.d.ts.map +1 -0
- package/dist/testing/fake-claim.js +187 -0
- package/dist/testing/fake-claim.js.map +1 -0
- package/dist/testing/fake-enqueue.d.ts +37 -0
- package/dist/testing/fake-enqueue.d.ts.map +1 -0
- package/dist/testing/fake-enqueue.js +84 -0
- package/dist/testing/fake-enqueue.js.map +1 -0
- package/dist/testing/in-memory-owner-lock.d.ts +7 -0
- package/dist/testing/in-memory-owner-lock.d.ts.map +1 -0
- package/dist/testing/in-memory-owner-lock.js +25 -0
- package/dist/testing/in-memory-owner-lock.js.map +1 -0
- package/dist/testing/index.d.ts +11 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +11 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/testing/prove-scope-matches-lookup.d.ts +22 -0
- package/dist/testing/prove-scope-matches-lookup.d.ts.map +1 -0
- package/dist/testing/prove-scope-matches-lookup.js +67 -0
- package/dist/testing/prove-scope-matches-lookup.js.map +1 -0
- package/dist/testing/start-test-spice-db.d.ts +31 -0
- package/dist/testing/start-test-spice-db.d.ts.map +1 -0
- package/dist/testing/start-test-spice-db.js +73 -0
- package/dist/testing/start-test-spice-db.js.map +1 -0
- package/dist/testing/tuned-spice-db-benchmark.d.ts +22 -0
- package/dist/testing/tuned-spice-db-benchmark.d.ts.map +1 -0
- package/dist/testing/tuned-spice-db-benchmark.js +148 -0
- package/dist/testing/tuned-spice-db-benchmark.js.map +1 -0
- package/package.json +73 -4
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { TestSpiceDb } from "./start-test-spice-db.js";
|
|
2
|
+
/** Each caller owns a datastore token, never the shared server's lifetime. */
|
|
3
|
+
export declare function createSharedTestSpiceDb(endpoint: string, createUniqueToken: () => string): TestSpiceDb;
|
|
4
|
+
//# sourceMappingURL=create-shared-test-spice-db.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-shared-test-spice-db.d.ts","sourceRoot":"","sources":["../../src/testing/create-shared-test-spice-db.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAE5D,8EAA8E;AAC9E,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,MAAM,GAAG,WAAW,CAMtG"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** Each caller owns a datastore token, never the shared server's lifetime. */
|
|
2
|
+
export function createSharedTestSpiceDb(endpoint, createUniqueToken) {
|
|
3
|
+
return {
|
|
4
|
+
endpoint,
|
|
5
|
+
presharedKey: `dads-test-${createUniqueToken()}`,
|
|
6
|
+
stop: () => Promise.resolve(),
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=create-shared-test-spice-db.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-shared-test-spice-db.js","sourceRoot":"","sources":["../../src/testing/create-shared-test-spice-db.ts"],"names":[],"mappings":"AAEA,8EAA8E;AAC9E,MAAM,UAAU,uBAAuB,CAAC,QAAgB,EAAE,iBAA+B;IACvF,OAAO;QACL,QAAQ;QACR,YAAY,EAAE,aAAa,iBAAiB,EAAE,EAAE;QAChD,IAAI,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,EAAE;KAC9B,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ApplyAccessChangesAfterCommit } from "../lib/access-changes/apply-after-commit.js";
|
|
2
|
+
import type { AccessChange } from "../lib/access-changes/enqueue.js";
|
|
3
|
+
import type { Authorization } from "@dads-framework/access/runtime";
|
|
4
|
+
/**
|
|
5
|
+
* Projects enqueued facts straight into a `FakeAuthorization`, so a mutation
|
|
6
|
+
* unit test sees what the product sees: create, and the tuple is there.
|
|
7
|
+
*
|
|
8
|
+
* `paused` is the interesting setting. It reproduces a dispatch that never
|
|
9
|
+
* ran — the crash the outbox exists for — so a test can assert the row was
|
|
10
|
+
* still enqueued, then run a real projector and watch the tuple appear. That
|
|
11
|
+
* is the wave's demo milestone in unit form.
|
|
12
|
+
*
|
|
13
|
+
* **Do not copy this shape into production.** It reaches the graph directly,
|
|
14
|
+
* which `createApplyAccessChangesAfterCommit` deliberately does not: the real
|
|
15
|
+
* one delegates to the projector so that claim and settle stay projector-only
|
|
16
|
+
* (INV-AUTHORIZATION-4). Here there is no store to claim from, and a fake that
|
|
17
|
+
* pretended otherwise would be testing the fake.
|
|
18
|
+
*/
|
|
19
|
+
export declare class FakeApplyAccessChangesAfterCommit extends ApplyAccessChangesAfterCommit {
|
|
20
|
+
private readonly authorization;
|
|
21
|
+
/** When true, dispatch records the call and projects nothing. */
|
|
22
|
+
paused: boolean;
|
|
23
|
+
private readonly seen;
|
|
24
|
+
constructor(authorization: Authorization);
|
|
25
|
+
dispatch(entries: readonly AccessChange[]): Promise<void>;
|
|
26
|
+
/** Everything handed to dispatch so far, in order. */
|
|
27
|
+
get dispatched(): readonly AccessChange[];
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=fake-apply-after-commit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fake-apply-after-commit.d.ts","sourceRoot":"","sources":["../../src/testing/fake-apply-after-commit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,6BAA6B,EAAE,MAAM,6CAA6C,CAAC;AAC5F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAEpE;;;;;;;;;;;;;;GAcG;AACH,qBAAa,iCAAkC,SAAQ,6BAA6B;IAMtE,OAAO,CAAC,QAAQ,CAAC,aAAa;IAL1C,iEAAiE;IACjE,MAAM,UAAS;IAEf,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAsB;IAE3C,YAA6B,aAAa,EAAE,aAAa,EAExD;IAEK,QAAQ,CAAC,OAAO,EAAE,SAAS,YAAY,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAgB9D;IAED,sDAAsD;IACtD,IAAI,UAAU,IAAI,SAAS,YAAY,EAAE,CAExC;CACF"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { ApplyAccessChangesAfterCommit } from "../lib/access-changes/apply-after-commit.js";
|
|
2
|
+
/**
|
|
3
|
+
* Projects enqueued facts straight into a `FakeAuthorization`, so a mutation
|
|
4
|
+
* unit test sees what the product sees: create, and the tuple is there.
|
|
5
|
+
*
|
|
6
|
+
* `paused` is the interesting setting. It reproduces a dispatch that never
|
|
7
|
+
* ran — the crash the outbox exists for — so a test can assert the row was
|
|
8
|
+
* still enqueued, then run a real projector and watch the tuple appear. That
|
|
9
|
+
* is the wave's demo milestone in unit form.
|
|
10
|
+
*
|
|
11
|
+
* **Do not copy this shape into production.** It reaches the graph directly,
|
|
12
|
+
* which `createApplyAccessChangesAfterCommit` deliberately does not: the real
|
|
13
|
+
* one delegates to the projector so that claim and settle stay projector-only
|
|
14
|
+
* (INV-AUTHORIZATION-4). Here there is no store to claim from, and a fake that
|
|
15
|
+
* pretended otherwise would be testing the fake.
|
|
16
|
+
*/
|
|
17
|
+
export class FakeApplyAccessChangesAfterCommit extends ApplyAccessChangesAfterCommit {
|
|
18
|
+
authorization;
|
|
19
|
+
/** When true, dispatch records the call and projects nothing. */
|
|
20
|
+
paused = false;
|
|
21
|
+
seen = [];
|
|
22
|
+
constructor(authorization) {
|
|
23
|
+
super();
|
|
24
|
+
this.authorization = authorization;
|
|
25
|
+
}
|
|
26
|
+
async dispatch(entries) {
|
|
27
|
+
this.seen.push(...entries);
|
|
28
|
+
if (this.paused)
|
|
29
|
+
return;
|
|
30
|
+
for (const entry of entries) {
|
|
31
|
+
if (entry.operation === "WRITE") {
|
|
32
|
+
await this.authorization.writeRelationships([entry.relationship]);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
const { resource, relation, subject } = entry.relationship;
|
|
36
|
+
await this.authorization.deleteRelationships({
|
|
37
|
+
resourceType: resource.type,
|
|
38
|
+
resourceId: resource.id,
|
|
39
|
+
relation,
|
|
40
|
+
subject,
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
/** Everything handed to dispatch so far, in order. */
|
|
46
|
+
get dispatched() {
|
|
47
|
+
return [...this.seen];
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=fake-apply-after-commit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fake-apply-after-commit.js","sourceRoot":"","sources":["../../src/testing/fake-apply-after-commit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,6BAA6B,EAAE,MAAM,6CAA6C,CAAC;AAI5F;;;;;;;;;;;;;;GAcG;AACH,MAAM,OAAO,iCAAkC,SAAQ,6BAA6B;IAMrD,aAAa;IAL1C,iEAAiE;IACjE,MAAM,GAAG,KAAK,CAAC;IAEE,IAAI,GAAmB,EAAE,CAAC;IAE3C,YAA6B,aAA4B;QACvD,KAAK,EAAE,CAAC;6BADmB,aAAa;IAE1C,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,OAAgC;QAC7C,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,CAAC;QAC3B,IAAI,IAAI,CAAC,MAAM;YAAE,OAAO;QACxB,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;YAC5B,IAAI,KAAK,CAAC,SAAS,KAAK,OAAO,EAAE,CAAC;gBAChC,MAAM,IAAI,CAAC,aAAa,CAAC,kBAAkB,CAAC,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC;YACpE,CAAC;iBAAM,CAAC;gBACN,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,KAAK,CAAC,YAAY,CAAC;gBAC3D,MAAM,IAAI,CAAC,aAAa,CAAC,mBAAmB,CAAC;oBAC3C,YAAY,EAAE,QAAQ,CAAC,IAAI;oBAC3B,UAAU,EAAE,QAAQ,CAAC,EAAE;oBACvB,QAAQ;oBACR,OAAO;iBACR,CAAC,CAAC;YACL,CAAC;QACH,CAAC;IACH,CAAC;IAED,sDAAsD;IACtD,IAAI,UAAU;QACZ,OAAO,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC;IACxB,CAAC;CACF"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { type AccessChangeId } from "../lib/access-changes/access-change.ids.js";
|
|
2
|
+
import { ClaimAccessChanges, type ClaimedOutboxRow, type OutboxClaim, type OutboxCounts, type OutboxHeldKeysQuery, type OutboxKeyClaim } from "../lib/access-changes/claim.js";
|
|
3
|
+
import type { AccessChange, OutboxStatus } from "../lib/access-changes/enqueue.js";
|
|
4
|
+
/**
|
|
5
|
+
* A stable `AccessChangeId` for a human-readable test label ("r1"), so a
|
|
6
|
+
* suite can seed a row by name and reference the SAME row later without
|
|
7
|
+
* inventing a real UUID by hand.
|
|
8
|
+
*/
|
|
9
|
+
export declare function testAccessChangeId(label: string): AccessChangeId;
|
|
10
|
+
/**
|
|
11
|
+
* In-memory projector store for unit tests. It reproduces the ONE behaviour
|
|
12
|
+
* the projector's correctness depends on — which rows a claim may take: PENDING
|
|
13
|
+
* rows that are either unlocked or whose lock is older than the cutoff the
|
|
14
|
+
* caller passed. Real exclusion between concurrent workers is a database
|
|
15
|
+
* guarantee (`FOR UPDATE SKIP LOCKED`) and is proved against Postgres, not
|
|
16
|
+
* imitated here.
|
|
17
|
+
*/
|
|
18
|
+
export declare class FakeClaimAccessChanges extends ClaimAccessChanges {
|
|
19
|
+
private readonly rows;
|
|
20
|
+
private lastCutoff;
|
|
21
|
+
seed(...rows: readonly ClaimedOutboxRow[]): void;
|
|
22
|
+
/**
|
|
23
|
+
* Seed from PRODUCER-side entries — what a writer just committed — flattened
|
|
24
|
+
* the way the table holds them. This is how a domain test replays the facts
|
|
25
|
+
* its own create enqueued, without hand-building storage rows.
|
|
26
|
+
*/
|
|
27
|
+
seedEntries(...entries: readonly AccessChange[]): void;
|
|
28
|
+
/** Put a row back the way an expired lease or a retry would. */
|
|
29
|
+
rePend(id: AccessChangeId): void;
|
|
30
|
+
/** Stamp a row as held, to fabricate a live or a crashed worker's claim. */
|
|
31
|
+
claimBy(id: AccessChangeId, workerId: string, at: Date): void;
|
|
32
|
+
statusOf(id: AccessChangeId): OutboxStatus | undefined;
|
|
33
|
+
attemptsOf(id: AccessChangeId): number | undefined;
|
|
34
|
+
errorOf(id: AccessChangeId): string | null | undefined;
|
|
35
|
+
lockedByOf(id: AccessChangeId): string | null | undefined;
|
|
36
|
+
/** The cutoff the projector asked for — proof it applied its lease. */
|
|
37
|
+
lastClaimCutoff(): Date | null;
|
|
38
|
+
claim(claim: OutboxClaim): Promise<readonly ClaimedOutboxRow[]>;
|
|
39
|
+
claimByKeys(claim: OutboxKeyClaim): Promise<readonly ClaimedOutboxRow[]>;
|
|
40
|
+
private take;
|
|
41
|
+
heldByLiveClaim(query: OutboxHeldKeysQuery): Promise<readonly string[]>;
|
|
42
|
+
isClaimOwned(id: AccessChangeId, workerId: string): Promise<boolean>;
|
|
43
|
+
markProjected(ids: readonly AccessChangeId[], at: Date, workerId: string): Promise<boolean>;
|
|
44
|
+
markFailed(id: AccessChangeId, outcome: {
|
|
45
|
+
status: "PENDING" | "FAILED";
|
|
46
|
+
attempts: number;
|
|
47
|
+
}, lastError: string, workerId: string): Promise<boolean>;
|
|
48
|
+
counts(): Promise<OutboxCounts>;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=fake-claim.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fake-claim.d.ts","sourceRoot":"","sources":["../../src/testing/fake-claim.ts"],"names":[],"mappings":"AAEA,OAAO,EAAwB,KAAK,cAAc,EAAE,MAAM,4CAA4C,CAAC;AACvG,OAAO,EACL,kBAAkB,EAClB,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,mBAAmB,EACxB,KAAK,cAAc,EACpB,MAAM,gCAAgC,CAAC;AACxC,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAUnF;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,cAAc,CAEhE;AAED;;;;;;;GAOG;AACH,qBAAa,sBAAuB,SAAQ,kBAAkB;IAC5D,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAwC;IAC7D,OAAO,CAAC,UAAU,CAAqB;IAEvC,IAAI,CAAC,GAAG,IAAI,EAAE,SAAS,gBAAgB,EAAE,GAAG,IAAI,CAU/C;IAED;;;;OAIG;IACH,WAAW,CAAC,GAAG,OAAO,EAAE,SAAS,YAAY,EAAE,GAAG,IAAI,CA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AAM,GACf,OAAO,CAAC,OAAO,CAAC,CAWlB;IAED,MAAM,IAAI,OAAO,CAAC,YAAY,CAAC,CAQ9B;CACF"}
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import { deterministicUuid } from "@dads-framework/postgres/testing/deterministic-uuid";
|
|
2
|
+
import { accessChangeIdSchema } from "../lib/access-changes/access-change.ids.js";
|
|
3
|
+
import { ClaimAccessChanges, } from "../lib/access-changes/claim.js";
|
|
4
|
+
/**
|
|
5
|
+
* A stable `AccessChangeId` for a human-readable test label ("r1"), so a
|
|
6
|
+
* suite can seed a row by name and reference the SAME row later without
|
|
7
|
+
* inventing a real UUID by hand.
|
|
8
|
+
*/
|
|
9
|
+
export function testAccessChangeId(label) {
|
|
10
|
+
return accessChangeIdSchema.parse(deterministicUuid(label, 0));
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* In-memory projector store for unit tests. It reproduces the ONE behaviour
|
|
14
|
+
* the projector's correctness depends on — which rows a claim may take: PENDING
|
|
15
|
+
* rows that are either unlocked or whose lock is older than the cutoff the
|
|
16
|
+
* caller passed. Real exclusion between concurrent workers is a database
|
|
17
|
+
* guarantee (`FOR UPDATE SKIP LOCKED`) and is proved against Postgres, not
|
|
18
|
+
* imitated here.
|
|
19
|
+
*/
|
|
20
|
+
export class FakeClaimAccessChanges extends ClaimAccessChanges {
|
|
21
|
+
rows = new Map();
|
|
22
|
+
lastCutoff = null;
|
|
23
|
+
seed(...rows) {
|
|
24
|
+
for (const row of rows) {
|
|
25
|
+
this.rows.set(row.id, {
|
|
26
|
+
...row,
|
|
27
|
+
status: "PENDING",
|
|
28
|
+
lockedBy: null,
|
|
29
|
+
lockedAt: null,
|
|
30
|
+
lastError: null,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Seed from PRODUCER-side entries — what a writer just committed — flattened
|
|
36
|
+
* the way the table holds them. This is how a domain test replays the facts
|
|
37
|
+
* its own create enqueued, without hand-building storage rows.
|
|
38
|
+
*/
|
|
39
|
+
seedEntries(...entries) {
|
|
40
|
+
for (const [index, entry] of entries.entries()) {
|
|
41
|
+
const { resource, relation, subject } = entry.relationship;
|
|
42
|
+
this.seed({
|
|
43
|
+
id: testAccessChangeId(`seeded-${index}-${entry.idempotencyKey}`),
|
|
44
|
+
idempotencyKey: entry.idempotencyKey,
|
|
45
|
+
operation: entry.operation,
|
|
46
|
+
resourceType: resource.type,
|
|
47
|
+
resourceId: resource.id,
|
|
48
|
+
relation,
|
|
49
|
+
subjectType: subject.type,
|
|
50
|
+
subjectId: subject.id,
|
|
51
|
+
subjectRelation: subject.relation ?? null,
|
|
52
|
+
ownerPartitionId: entry.ownerPartitionId,
|
|
53
|
+
attempts: 0,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
/** Put a row back the way an expired lease or a retry would. */
|
|
58
|
+
rePend(id) {
|
|
59
|
+
const row = this.rows.get(id);
|
|
60
|
+
if (!row)
|
|
61
|
+
throw new Error(`No such row ${id}`);
|
|
62
|
+
row.status = "PENDING";
|
|
63
|
+
row.lockedBy = null;
|
|
64
|
+
row.lockedAt = null;
|
|
65
|
+
}
|
|
66
|
+
/** Stamp a row as held, to fabricate a live or a crashed worker's claim. */
|
|
67
|
+
claimBy(id, workerId, at) {
|
|
68
|
+
const row = this.rows.get(id);
|
|
69
|
+
if (!row)
|
|
70
|
+
throw new Error(`No such row ${id}`);
|
|
71
|
+
row.lockedBy = workerId;
|
|
72
|
+
row.lockedAt = at;
|
|
73
|
+
}
|
|
74
|
+
statusOf(id) {
|
|
75
|
+
return this.rows.get(id)?.status;
|
|
76
|
+
}
|
|
77
|
+
attemptsOf(id) {
|
|
78
|
+
return this.rows.get(id)?.attempts;
|
|
79
|
+
}
|
|
80
|
+
errorOf(id) {
|
|
81
|
+
return this.rows.get(id)?.lastError;
|
|
82
|
+
}
|
|
83
|
+
lockedByOf(id) {
|
|
84
|
+
return this.rows.get(id)?.lockedBy;
|
|
85
|
+
}
|
|
86
|
+
/** The cutoff the projector asked for — proof it applied its lease. */
|
|
87
|
+
lastClaimCutoff() {
|
|
88
|
+
return this.lastCutoff;
|
|
89
|
+
}
|
|
90
|
+
claim(claim) {
|
|
91
|
+
this.lastCutoff = claim.leaseCutoff;
|
|
92
|
+
return Promise.resolve(this.take(claim, () => true, claim.batchSize));
|
|
93
|
+
}
|
|
94
|
+
claimByKeys(claim) {
|
|
95
|
+
this.lastCutoff = claim.leaseCutoff;
|
|
96
|
+
const wanted = new Set(claim.idempotencyKeys);
|
|
97
|
+
return Promise.resolve(this.take(claim, (row) => wanted.has(row.idempotencyKey), Infinity));
|
|
98
|
+
}
|
|
99
|
+
take(claim, wanted, batchSize) {
|
|
100
|
+
const taken = [];
|
|
101
|
+
for (const row of this.rows.values()) {
|
|
102
|
+
if (taken.length >= batchSize)
|
|
103
|
+
break;
|
|
104
|
+
if (row.status !== "PENDING")
|
|
105
|
+
continue;
|
|
106
|
+
if (!wanted(row))
|
|
107
|
+
continue;
|
|
108
|
+
const free = row.lockedAt === null || row.lockedAt.getTime() <= claim.leaseCutoff.getTime();
|
|
109
|
+
if (!free)
|
|
110
|
+
continue;
|
|
111
|
+
row.lockedBy = claim.workerId;
|
|
112
|
+
row.lockedAt = claim.now;
|
|
113
|
+
taken.push({
|
|
114
|
+
id: row.id,
|
|
115
|
+
idempotencyKey: row.idempotencyKey,
|
|
116
|
+
operation: row.operation,
|
|
117
|
+
resourceType: row.resourceType,
|
|
118
|
+
resourceId: row.resourceId,
|
|
119
|
+
relation: row.relation,
|
|
120
|
+
subjectType: row.subjectType,
|
|
121
|
+
subjectId: row.subjectId,
|
|
122
|
+
subjectRelation: row.subjectRelation,
|
|
123
|
+
ownerPartitionId: row.ownerPartitionId,
|
|
124
|
+
attempts: row.attempts,
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
return taken;
|
|
128
|
+
}
|
|
129
|
+
heldByLiveClaim(query) {
|
|
130
|
+
const wanted = new Set(query.idempotencyKeys);
|
|
131
|
+
const held = [];
|
|
132
|
+
for (const row of this.rows.values()) {
|
|
133
|
+
if (row.status !== "PENDING" || !wanted.has(row.idempotencyKey))
|
|
134
|
+
continue;
|
|
135
|
+
if (row.lockedAt === null)
|
|
136
|
+
continue;
|
|
137
|
+
if (row.lockedAt.getTime() <= query.leaseCutoff.getTime())
|
|
138
|
+
continue;
|
|
139
|
+
held.push(row.idempotencyKey);
|
|
140
|
+
}
|
|
141
|
+
return Promise.resolve(held);
|
|
142
|
+
}
|
|
143
|
+
isClaimOwned(id, workerId) {
|
|
144
|
+
const row = this.rows.get(id);
|
|
145
|
+
return Promise.resolve(row?.status === "PENDING" && row.lockedBy === workerId);
|
|
146
|
+
}
|
|
147
|
+
markProjected(ids, at, workerId) {
|
|
148
|
+
let settled = 0;
|
|
149
|
+
for (const id of ids) {
|
|
150
|
+
const row = this.rows.get(id);
|
|
151
|
+
if (row?.status !== "PENDING" || row.lockedBy !== workerId) {
|
|
152
|
+
continue;
|
|
153
|
+
}
|
|
154
|
+
row.status = "PROJECTED";
|
|
155
|
+
row.lockedBy = null;
|
|
156
|
+
row.lockedAt = null;
|
|
157
|
+
row.lastError = null;
|
|
158
|
+
settled += 1;
|
|
159
|
+
void at;
|
|
160
|
+
}
|
|
161
|
+
return Promise.resolve(settled === ids.length);
|
|
162
|
+
}
|
|
163
|
+
markFailed(id, outcome, lastError, workerId) {
|
|
164
|
+
const row = this.rows.get(id);
|
|
165
|
+
if (row?.status === "PENDING" && row.lockedBy === workerId) {
|
|
166
|
+
row.status = outcome.status;
|
|
167
|
+
row.attempts = outcome.attempts;
|
|
168
|
+
row.lastError = lastError;
|
|
169
|
+
row.lockedBy = null;
|
|
170
|
+
row.lockedAt = null;
|
|
171
|
+
return Promise.resolve(true);
|
|
172
|
+
}
|
|
173
|
+
return Promise.resolve(false);
|
|
174
|
+
}
|
|
175
|
+
counts() {
|
|
176
|
+
let pending = 0;
|
|
177
|
+
let failed = 0;
|
|
178
|
+
for (const row of this.rows.values()) {
|
|
179
|
+
if (row.status === "PENDING")
|
|
180
|
+
pending += 1;
|
|
181
|
+
if (row.status === "FAILED")
|
|
182
|
+
failed += 1;
|
|
183
|
+
}
|
|
184
|
+
return Promise.resolve({ pending, failed });
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
//# sourceMappingURL=fake-claim.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fake-claim.js","sourceRoot":"","sources":["../../src/testing/fake-claim.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qDAAqD,CAAC;AAExF,OAAO,EAAE,oBAAoB,EAAuB,MAAM,4CAA4C,CAAC;AACvG,OAAO,EACL,kBAAkB,GAMnB,MAAM,gCAAgC,CAAC;AAWxC;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAAa;IAC9C,OAAO,oBAAoB,CAAC,KAAK,CAAC,iBAAiB,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC;AACjE,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,OAAO,sBAAuB,SAAQ,kBAAkB;IAC3C,IAAI,GAAG,IAAI,GAAG,EAA6B,CAAC;IACrD,UAAU,GAAgB,IAAI,CAAC;IAEvC,IAAI,CAAC,GAAG,IAAiC;QACvC,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;YACvB,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,EAAE;gBACpB,GAAG,GAAG;gBACN,MAAM,EAAE,SAAS;gBACjB,QAAQ,EAAE,IAAI;gBACd,QAAQ,EAAE,IAAI;gBACd,SAAS,EAAE,IAAI;aAChB,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED;;;;OAIG;IACH,WAAW,CAAC,GAAG,OAAgC;QAC7C,KAAK,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,OAAO,CAAC,OAAO,EAA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essChanges, type AccessChange, type OutboxTx } from "../lib/access-changes/enqueue.js";
|
|
2
|
+
import type { OwnerLockLease } from "@dads-framework/access/runtime";
|
|
3
|
+
/**
|
|
4
|
+
* In-memory outbox for unit tests, mirroring FakeLiveEnvironmentActionRunWriter. The enqueued
|
|
5
|
+
* entries are readable as an array so a mutation test can assert the exact
|
|
6
|
+
* authorization intent it produced without a database.
|
|
7
|
+
*
|
|
8
|
+
* The `tx` argument is accepted and ignored: a fake has no transaction, and
|
|
9
|
+
* pretending otherwise would test the fake rather than the mutation. What the
|
|
10
|
+
* transaction actually buys — the row and the entry committing together — is
|
|
11
|
+
* proved once, against a real Postgres, in the adapter's integration test.
|
|
12
|
+
*
|
|
13
|
+
* Deduplicates on `idempotencyKey` exactly as the unique index does, so a test
|
|
14
|
+
* that enqueues the same fact twice sees what production would see.
|
|
15
|
+
*/
|
|
16
|
+
export declare class FakeEnqueueAccessChanges extends EnqueueAccessChanges {
|
|
17
|
+
private readonly entries;
|
|
18
|
+
/**
|
|
19
|
+
* Fails when set, so a test can prove that a durable-record failure DOES
|
|
20
|
+
* fail the caller — the opposite of the synchronous graph delete, which is
|
|
21
|
+
* swallowed (`revokeAccess`).
|
|
22
|
+
*/
|
|
23
|
+
failNext: boolean;
|
|
24
|
+
append(newEntries: readonly AccessChange[]): Promise<void>;
|
|
25
|
+
enqueue(newEntries: readonly AccessChange[]): Promise<void>;
|
|
26
|
+
enqueueReplacingOpposite(newEntries: readonly AccessChange[], _tx: OutboxTx, lease: OwnerLockLease): Promise<void>;
|
|
27
|
+
/**
|
|
28
|
+
* The same replacement without a transaction handle, for a fake store that
|
|
29
|
+
* stands in for the row transaction. Rejects before touching anything when
|
|
30
|
+
* `failNext` is set, so a failed "transaction" leaves the outbox unchanged.
|
|
31
|
+
*/
|
|
32
|
+
replaceOpposite(newEntries: readonly AccessChange[], lease: OwnerLockLease): Promise<void>;
|
|
33
|
+
/** Everything enqueued so far, in order. */
|
|
34
|
+
get enqueued(): readonly AccessChange[];
|
|
35
|
+
clear(): void;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=fake-enqueue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fake-enqueue.d.ts","sourceRoot":"","sources":["../../src/testing/fake-enqueue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,KAAK,YAAY,EAAE,KAAK,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AAC1G,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAErE;;;;;;;;;;;;GAYG;AACH,qBAAa,wBAAyB,SAAQ,oBAAoB;IAChE,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAsB;IAE9C;;;;OAIG;IACH,QAAQ,UAAS;IAEjB,MAAM,CAAC,UAAU,EAAE,SAAS,YAAY,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAEzD;IAED,OAAO,CAAC,UAAU,EAAE,SAAS,YAAY,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAS1D;IAED,wBAAwB,CAAC,UAAU,EAAE,SAAS,YAAY,EAAE,EAAE,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAEjH;IAED;;;;OAIG;IACH,eAAe,CAAC,UAAU,EAAE,SAAS,YAAY,EAAE,EAAE,KAAK,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAmBzF;IAED,4CAA4C;IAC5C,IAAI,QAAQ,IAAI,SAAS,YAAY,EAAE,CAEtC;IAED,KAAK,IAAI,IAAI,CAEZ;CACF"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { EnqueueAccessChanges } from "../lib/access-changes/enqueue.js";
|
|
2
|
+
/**
|
|
3
|
+
* In-memory outbox for unit tests, mirroring FakeLiveEnvironmentActionRunWriter. The enqueued
|
|
4
|
+
* entries are readable as an array so a mutation test can assert the exact
|
|
5
|
+
* authorization intent it produced without a database.
|
|
6
|
+
*
|
|
7
|
+
* The `tx` argument is accepted and ignored: a fake has no transaction, and
|
|
8
|
+
* pretending otherwise would test the fake rather than the mutation. What the
|
|
9
|
+
* transaction actually buys — the row and the entry committing together — is
|
|
10
|
+
* proved once, against a real Postgres, in the adapter's integration test.
|
|
11
|
+
*
|
|
12
|
+
* Deduplicates on `idempotencyKey` exactly as the unique index does, so a test
|
|
13
|
+
* that enqueues the same fact twice sees what production would see.
|
|
14
|
+
*/
|
|
15
|
+
export class FakeEnqueueAccessChanges extends EnqueueAccessChanges {
|
|
16
|
+
entries = [];
|
|
17
|
+
/**
|
|
18
|
+
* Fails when set, so a test can prove that a durable-record failure DOES
|
|
19
|
+
* fail the caller — the opposite of the synchronous graph delete, which is
|
|
20
|
+
* swallowed (`revokeAccess`).
|
|
21
|
+
*/
|
|
22
|
+
failNext = false;
|
|
23
|
+
append(newEntries) {
|
|
24
|
+
return this.enqueue(newEntries);
|
|
25
|
+
}
|
|
26
|
+
enqueue(newEntries) {
|
|
27
|
+
if (this.failNext) {
|
|
28
|
+
return Promise.reject(new Error("outbox unavailable"));
|
|
29
|
+
}
|
|
30
|
+
for (const entry of newEntries) {
|
|
31
|
+
const known = this.entries.some((existing) => existing.idempotencyKey === entry.idempotencyKey);
|
|
32
|
+
if (!known)
|
|
33
|
+
this.entries.push(entry);
|
|
34
|
+
}
|
|
35
|
+
return Promise.resolve();
|
|
36
|
+
}
|
|
37
|
+
enqueueReplacingOpposite(newEntries, _tx, lease) {
|
|
38
|
+
return this.replaceOpposite(newEntries, lease);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* The same replacement without a transaction handle, for a fake store that
|
|
42
|
+
* stands in for the row transaction. Rejects before touching anything when
|
|
43
|
+
* `failNext` is set, so a failed "transaction" leaves the outbox unchanged.
|
|
44
|
+
*/
|
|
45
|
+
replaceOpposite(newEntries, lease) {
|
|
46
|
+
if (this.failNext) {
|
|
47
|
+
return Promise.reject(new Error("outbox unavailable"));
|
|
48
|
+
}
|
|
49
|
+
for (const entry of newEntries) {
|
|
50
|
+
if (entry.ownerPartitionId === null) {
|
|
51
|
+
return Promise.reject(new Error("replacement facts require an owner partition"));
|
|
52
|
+
}
|
|
53
|
+
lease.assertPartition(entry.ownerPartitionId);
|
|
54
|
+
}
|
|
55
|
+
for (const entry of newEntries) {
|
|
56
|
+
for (let index = this.entries.length - 1; index >= 0; index -= 1) {
|
|
57
|
+
const existing = this.entries[index];
|
|
58
|
+
if (existing !== undefined && existing.operation !== entry.operation && sameExactFact(existing, entry)) {
|
|
59
|
+
this.entries.splice(index, 1);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return this.enqueue(newEntries);
|
|
64
|
+
}
|
|
65
|
+
/** Everything enqueued so far, in order. */
|
|
66
|
+
get enqueued() {
|
|
67
|
+
return [...this.entries];
|
|
68
|
+
}
|
|
69
|
+
clear() {
|
|
70
|
+
this.entries.length = 0;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
function sameExactFact(left, right) {
|
|
74
|
+
const leftRelationship = left.relationship;
|
|
75
|
+
const rightRelationship = right.relationship;
|
|
76
|
+
return (left.ownerPartitionId === right.ownerPartitionId &&
|
|
77
|
+
leftRelationship.resource.type === rightRelationship.resource.type &&
|
|
78
|
+
leftRelationship.resource.id === rightRelationship.resource.id &&
|
|
79
|
+
leftRelationship.relation === rightRelationship.relation &&
|
|
80
|
+
leftRelationship.subject.type === rightRelationship.subject.type &&
|
|
81
|
+
leftRelationship.subject.id === rightRelationship.subject.id &&
|
|
82
|
+
leftRelationship.subject.relation === rightRelationship.subject.relation);
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=fake-enqueue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fake-enqueue.js","sourceRoot":"","sources":["../../src/testing/fake-enqueue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAoC,MAAM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AC9D,gBAAgB,CAAC,QAAQ,KAAK,iBAAiB,CAAC,QAAQ;QACxD,gBAAgB,CAAC,OAAO,CAAC,IAAI,KAAK,iBAAiB,CAAC,OAAO,CAAC,IAAI;QAChE,gBAAgB,CAAC,OAAO,CAAC,EAAE,KAAK,iBAAiB,CAAC,OAAO,CAAC,EAAE;QAC5D,gBAAgB,CAAC,OAAO,CAAC,QAAQ,KAAK,iBAAiB,CAAC,OAAO,CAAC,QAAQ,CACzE,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { OwnerLock } from "@dads-framework/access/runtime";
|
|
2
|
+
/** Deterministic process-local equivalent of the Postgres partition lock. */
|
|
3
|
+
export declare class InMemoryOwnerLock extends OwnerLock {
|
|
4
|
+
private readonly tails;
|
|
5
|
+
protected runLocked<T>(ownerPartitionId: string, operation: () => Promise<T>): Promise<T>;
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=in-memory-owner-lock.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"in-memory-owner-lock.d.ts","sourceRoot":"","sources":["../../src/testing/in-memory-owner-lock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAE3D,6EAA6E;AAC7E,qBAAa,iBAAkB,SAAQ,SAAS;IAC9C,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAoC;IAE1D,UAAgB,SAAS,CAAC,CAAC,EAAE,gBAAgB,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAiB9F;CACF"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { OwnerLock } from "@dads-framework/access/runtime";
|
|
2
|
+
/** Deterministic process-local equivalent of the Postgres partition lock. */
|
|
3
|
+
export class InMemoryOwnerLock extends OwnerLock {
|
|
4
|
+
tails = new Map();
|
|
5
|
+
async runLocked(ownerPartitionId, operation) {
|
|
6
|
+
const previous = this.tails.get(ownerPartitionId) ?? Promise.resolve();
|
|
7
|
+
let release = () => undefined;
|
|
8
|
+
const current = new Promise((resolve) => {
|
|
9
|
+
release = resolve;
|
|
10
|
+
});
|
|
11
|
+
const tail = previous.then(() => current);
|
|
12
|
+
this.tails.set(ownerPartitionId, tail);
|
|
13
|
+
await previous;
|
|
14
|
+
try {
|
|
15
|
+
return await operation();
|
|
16
|
+
}
|
|
17
|
+
finally {
|
|
18
|
+
release();
|
|
19
|
+
if (this.tails.get(ownerPartitionId) === tail) {
|
|
20
|
+
this.tails.delete(ownerPartitionId);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=in-memory-owner-lock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"in-memory-owner-lock.js","sourceRoot":"","sources":["../../src/testing/in-memory-owner-lock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAE3D,6EAA6E;AAC7E,MAAM,OAAO,iBAAkB,SAAQ,SAAS;IAC7B,KAAK,GAAG,IAAI,GAAG,EAAyB,CAAC;IAEhD,KAAK,CAAC,SAAS,CAAI,gBAAwB,EAAE,SAA2B;QAChF,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,gBAAgB,CAAC,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;QACvE,IAAI,OAAO,GAAG,GAAS,EAAE,CAAC,SAAS,CAAC;QACpC,MAAM,OAAO,GAAG,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE;YAC5C,OAAO,GAAG,OAAO,CAAC;QACpB,CAAC,CAAC,CAAC;QACH,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,CAAC;QAC1C,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,gBAAgB,EAAE,IAAI,CAAC,CAAC;QACvC,MAAM,QAAQ,CAAC;QACf,IAAI,CAAC;YACH,OAAO,MAAM,SAAS,EAAE,CAAC;QAC3B,CAAC;gBAAS,CAAC;YACT,OAAO,EAAE,CAAC;YACV,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,gBAAgB,CAAC,KAAK,IAAI,EAAE,CAAC;gBAC9C,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;YACtC,CAAC;QACH,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { FakeApplyAccessChangesAfterCommit } from "./fake-apply-after-commit.js";
|
|
2
|
+
export { FakeAuthorization } from "@dads-framework/access/testing";
|
|
3
|
+
export { RecordingAuthorization } from "@dads-framework/access/testing";
|
|
4
|
+
export { FakeClaimAccessChanges } from "./fake-claim.js";
|
|
5
|
+
export { FakeEnqueueAccessChanges } from "./fake-enqueue.js";
|
|
6
|
+
export { InMemoryOwnerLock } from "./in-memory-owner-lock.js";
|
|
7
|
+
export { proveScopeMatchesLookup } from "./prove-scope-matches-lookup.js";
|
|
8
|
+
export { SHARED_TEST_SPICE_DB_ENDPOINT, startSharedTestSpiceDb, startTestSpiceDb, type TestSpiceDb, } from "./start-test-spice-db.js";
|
|
9
|
+
export { createTunedSpiceDbClient, startTunedSpiceDb, type TunedSpiceDbClient, type TunedSpiceDbConsistency, } from "./tuned-spice-db-benchmark.js";
|
|
10
|
+
export { runOutsideHeldPartitions } from "@dads-framework/access/testing";
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/testing/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iCAAiC,EAAE,MAAM,8BAA8B,CAAC;AACjF,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AACxE,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAC1E,OAAO,EACL,6BAA6B,EAC7B,sBAAsB,EACtB,gBAAgB,EAChB,KAAK,WAAW,GACjB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,wBAAwB,EACxB,iBAAiB,EACjB,KAAK,kBAAkB,EACvB,KAAK,uBAAuB,GAC7B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { FakeApplyAccessChangesAfterCommit } from "./fake-apply-after-commit.js";
|
|
2
|
+
export { FakeAuthorization } from "@dads-framework/access/testing";
|
|
3
|
+
export { RecordingAuthorization } from "@dads-framework/access/testing";
|
|
4
|
+
export { FakeClaimAccessChanges } from "./fake-claim.js";
|
|
5
|
+
export { FakeEnqueueAccessChanges } from "./fake-enqueue.js";
|
|
6
|
+
export { InMemoryOwnerLock } from "./in-memory-owner-lock.js";
|
|
7
|
+
export { proveScopeMatchesLookup } from "./prove-scope-matches-lookup.js";
|
|
8
|
+
export { SHARED_TEST_SPICE_DB_ENDPOINT, startSharedTestSpiceDb, startTestSpiceDb, } from "./start-test-spice-db.js";
|
|
9
|
+
export { createTunedSpiceDbClient, startTunedSpiceDb, } from "./tuned-spice-db-benchmark.js";
|
|
10
|
+
export { runOutsideHeldPartitions } from "@dads-framework/access/testing";
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/testing/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iCAAiC,EAAE,MAAM,8BAA8B,CAAC;AACjF,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AACxE,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAC1E,OAAO,EACL,6BAA6B,EAC7B,sBAAsB,EACtB,gBAAgB,GAEjB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,wBAAwB,EACxB,iBAAiB,GAGlB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { AccessModel } from "@dads-framework/access";
|
|
2
|
+
import type { DrizzleHandle } from "@dads-framework/postgres";
|
|
3
|
+
import type { SubjectRef } from "@dads-framework/access/runtime";
|
|
4
|
+
import { type ScopeLookups } from "@dads-framework/access/runtime";
|
|
5
|
+
import type { ScopeSqlBindings } from "../lib/scoped-lists/scope-sql-bindings.js";
|
|
6
|
+
/**
|
|
7
|
+
* The proof every adopting model carries: over a seeded world, for each
|
|
8
|
+
* subject, the ids `scopePredicate` selects equal (as a set) the ids
|
|
9
|
+
* `lookupResources` returns. Throws one readable diff covering every subject
|
|
10
|
+
* that disagrees, with the plan that was rendered.
|
|
11
|
+
*/
|
|
12
|
+
export declare function proveScopeMatchesLookup(input: {
|
|
13
|
+
readonly db: DrizzleHandle;
|
|
14
|
+
readonly model: AccessModel;
|
|
15
|
+
readonly authorization: ScopeLookups;
|
|
16
|
+
readonly wireName: string;
|
|
17
|
+
readonly permission: string;
|
|
18
|
+
readonly sqlBindings: ScopeSqlBindings;
|
|
19
|
+
readonly relatedSqlBindings?: readonly ScopeSqlBindings[];
|
|
20
|
+
readonly subjects: readonly SubjectRef[];
|
|
21
|
+
}): Promise<void>;
|
|
22
|
+
//# sourceMappingURL=prove-scope-matches-lookup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prove-scope-matches-lookup.d.ts","sourceRoot":"","sources":["../../src/testing/prove-scope-matches-lookup.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAE1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAE9D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAA+B,KAAK,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAEhG,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2CAA2C,CAAC;AAWlF;;;;;GAKG;AACH,wBAAsB,uBAAuB,CAAC,KAAK,EAAE;IACnD,QAAQ,CAAC,EAAE,EAAE,aAAa,CAAC;IAC3B,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC;IAC5B,QAAQ,CAAC,aAAa,EAAE,YAAY,CAAC;IACrC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,WAAW,EAAE,gBAAgB,CAAC;IACvC,QAAQ,CAAC,kBAAkB,CAAC,EAAE,SAAS,gBAAgB,EAAE,CAAC;IAC1D,QAAQ,CAAC,QAAQ,EAAE,SAAS,UAAU,EAAE,CAAC;CAC1C,GAAG,OAAO,CAAC,IAAI,CAAC,CAwChB"}
|